|
环境准备
[root@CenOS-7 ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
[root@CenOS-7 ~]# uname -r
3.10.0-693.el7.x86_64
下载LNMP软件包
[root@CenOS-7 ~]# yum install -y nginx mariadb-server php-mysql php-fpm
启动LNMP服务
[root@CenOS-7 ~]# systemctl start nginx.service mariadb.service php-fpm.service
[root@CenOS-7 ~]# systemctl enable nginx.service mariadb.service php-fpm.service
检查LNMP服务是否启动
[root@CenOS-7 ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0: LISTEN 1726/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 1173/sshd
tcp 0 0 127.0.0.1:9000 0.0.0.0: LISTEN 1682/php-fpm: maste
tcp 0 0 0.0.0.0:3306 0.0.0.0: LISTEN 1934/mysqld
tcp6 0 0 :::80 ::: LISTEN 1726/nginx: master
tcp6 0 0 :::22 ::: LISTEN 1173/sshd
udp 0 0 127.0.0.1:323 0.0.0.0: 713/chronyd
udp6 0 0 ::1:323 ::: 713/chronyd
编写nginx配置文件
[root@CenOS-7 ~]# cat /etc/nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
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;
}
}
}
创建wordpress用户,并授权
[root@CenOS-7 ~]# mysql
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on wordpress. to ‘wordpress’@’localhost’ identified by ‘123456’;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
将wordpress导入到nginx站点目录下
[root@CenOS-7 ~]# mv wordpress/ /usr/share/nginx/html/
重启nginx服务
[root@CenOS-7 ~]# systemctl restart nginx.service
登录浏览器访问测试
手动配置wp-config.php到站点目录下
[root@CenOS-7 ~]# cat /usr/share/nginx/html/wp-config.php |
|
|