LNMP build WordPress

ready:

① One Centos7.6, I use Alibaba Cloud server

② Wordpress installation file

Link: https://pan.baidu.com/s/1G5I9AGD-y8LnYGVk1xyX2A Extraction code: lpcq 

③ Upgrade yum source

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
 
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

④ Turn off the firewall, turn off selinux

⑤ Cloud server security group release ports, including related ports such as 80 3306 

 1. Install mariadb and create a WordPress backend database

# 安装mariadb
yum install  mariadb  mariadb-server

# 启动
systemctl  start   mariadb

# 初始化数据库,用户名root,密码123456
mysql_secure_installation

# 登录
mysql  -uroot  -p

# 登录数据库后创建(WordPress)的数据库,数据命名为wenlong
create  database  wenlong;

# 授权可以远程访问,用户名root,密码123456
grant all on  *.* to  root@'%' identified by '123456';

#刷新权限
flush  privileges;

2. Install php components such as php70w and php-fpm

# 安装php70w和相关组件
yum -y install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64

# 安装fpm、opcache组件
yum -y install php70w-fpm php70w-opcache

# 启动fpm
systemctl start php-fpm

# 查看php的版本
php  -v

# 查看9000(fpm)、3306(mysql)、80(httpd)端口是否正常
netstat  -antp

Three, install nginx

3.1 install nginx

# 安装nginx
yum install  nginx

# 启动
systemctl  start nginx

3.2 Edit the nginx configuration file, add the configuration in the server node, and restart nginx

vim  /etc/nginx/nginx.conf
location / {
     root   html;
     index index.php  index.html index.htm;
}

location ~ \.php$ {
     root           html;
     fastcgi_pass   127.0.0.1:9000;
     fastcgi_index  index.php;
     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
     include        fastcgi_params;
}
# 重启nginx
systemctl  restart  nginx

# 查看监控端口情况3306    9000    80
netstat  -anpt

 3.3 Create a new index.php homepage in the root directory of the  site

# 编辑index.php,插入下边代码并保存退出
vim   /usr/share/nginx/html/index.php
<?php
    phpinfo();
?>

3.4 Enter http://your ip/ in the browser to check whether the installation of nginx and php is successful

 Fourth, install WordPress

# 上传WordPress安装文件到云服务器,解压
tar  -zxvf   wordpress-5.4.2.tar.gz

# 将解压后的文件移动到nginx站点根目录
mv  wordpress   /usr/share/nginx/html/

# 进入到WordPress,修改配置文件
cd  /usr/share/nginx/html/wordpress/

# 重命名配置文件,让nginx能够识别
mv   wp-config-sample.php wp-config.php

# 配置后台数据库对应的库、用户名和密码
vim  wp-config.php
# 后台数据库名
define( 'DB_NAME', 'wenlong' );

/**数据库用户名 */
define( 'DB_USER', 'root' );

/** 数据库密码 */
define( 'DB_PASSWORD', '123456' );

5. Initialize WordPress, first restart nginx

# 修改nginx配置文件,修改WordPress后都应该重启nginx
# 重启nginx
systemctl  restart nginx

Browser enter the webpage installation address: http://your ip address/wordpress/wp-admin/install.php

Fill in the installation information and click the button install WordPress

Enter the user and password registered above to log in


 Appendix: If the firewall and selinux are turned on, modify the firewall rules, the selinux context generally does not need to be changed

# 防火墙放开80端口,nginx默认使用80
# --permanent重启后仍然有效
firewall-cmd  --add-port=80/tcp  --permanent

# 也可放通mysql默认的端口3306
firewall-cmd  --add-port=3306/tcp  --permanent

# 重新加载防火墙配置规则
firewall-cmd  --reload

Cloud server security group releases corresponding ports such as 80 and 3306

Guess you like

Origin blog.csdn.net/qq_29644709/article/details/109315991