- OS:CentOS Linux release 7.6.1810 (Core)
- nginx :1.16.1
- mysql:5.6
- php:7.3.11
我们可以通过https://lnmp.org/auto.html这个网站一键化部署
将命令复制下来粘贴到服务器上,等待40分钟左右即可
wget http://soft.vpser.net/lnmp/lnmp1.6.tar.gz -cO lnmp1.6.tar.gz && tar zxf lnmp1.6.tar.gz && cd lnmp1.6 && LNMP_Auto="y" DBSelect="3" DB_Root_Password="root" InstallInnodb="y" PHPSelect="9" SelectMalloc="1" ./install.sh lnmp
通过自动安装编译后的配置文件是在/usr/local/nginx/conf/nginx.conf
vim /usr/local/nginx/conf/vhost/wordpress.conf
#添加以下内容
server {
listen 8080;
root /usr/local/nginx/html/wordpress;
server_name localhost;
location / {
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/nginx/html/wordpress;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
重启nginx
nginx -s reload
查看端口
[root@192 conf]# netstat -antp|grep nginx
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 50340/nginx: master
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 50340/nginx: master
查看安装路径
[root@192 conf]# whereis php
php: /usr/bin/php /usr/local/php
配置PHP SESSION存储路径
vim /usr/local/php/etc/php.ini
#第1362行
session.save_path = "/usr/local/php/session"
创建目录
mkdir -p /usr/local/php/session
配置9000端口
vim /usr/local/php/etc/php-fpm.conf
#配置如下
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
#listen = /tmp/php-cgi.sock
listen = 9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 20
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.max_requests = 1024
pm.process_idle_timeout = 10s
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log
重启php-fpm
[root@192 etc]# service php-fpm restart
Gracefully shutting down php-fpm warning, no pid file found - php-fpm is not running ?
Starting php-fpm done
查看端口状态
[root@192 etc]# netstat -anpt|grep 9000
tcp6 0 0 :::9000 :::* LISTEN 53129/php-fpm: mast
登录数据库
mysql -uroot -proot
创建wordpress数据库
mysql> CREATE DATABASE wordpress;
创建WordPress用户
mysql> CREATE USER wordpress@localhost;
给WordPress用户设置密码
SET PASSWORD FOR wordpress@localhost=PASSWORD("wordpress");
给WordPress用户权限
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO wordpress@localhost IDENTIFIED BY 'wordpress';
刷新权限
mysql> FLUSH PRIVILEGES;
下载WordPress
官网网站
下载完成后上传到服务器上并解压到/usr/local/nginx/html
下
将默认的html文件移动到其他目录
cd /usr/local/nginx/html/
mv *.html /tmp/
解压安装包
tar -zxf wordpress-5.4.1-zh_CN.tar.gz -C /usr/local/nginx/html
重命名配置文件
mv wp-config-sample.php wp-config.php
编辑配置文件
[root@192 wordpress]# vim wp-config.php
#以下部分需修改
define( 'DB_NAME', 'wordpress' );
/** MySQL数据库用户名 */
define( 'DB_USER', 'wordpress' );
/** MySQL数据库密码 */
define( 'DB_PASSWORD', 'wordpress' );
/** MySQL主机 */
define( 'DB_HOST', 'localhost:3306' );
浏览器访问http://192.168.29.129:8080/
,出现以下界面
配置好后直接点安装,等待一会即可安装完成
登录
首次登录比较慢,等待一会。。。
完成!