环境下载
Centos有YUM安装功能,所以NGINX、PHP、MYSQL安装都很简单
yum install nginx
yum install php-*
yum install mysql
下载WorkPress时要特别注意,由于下载了最新版导致反复折腾两天。之后才发现默认安装的php-fpm版本不够高导致,php编译异常;
我下载的是wordpress-5.1.6.tar.gz
下载地址是:https://wordpress.org/wordpress-5.1.6.tar.gz
安装配置
#解压到网站目录,我的是/home/wordpress
tar zxf wordpress-5.1.6.tar.gz
#授权这里要注意,nginx默认用户是nginx,php的默认用户是apache,所以要授权给apache
chmod 750 /home/wordpress
chown -R apache:apache /home/wordpress
创建Nginx配置文件
server {
listen 80;
server_name www.lingx.com;
root /home/wordpress;
index index.html index.htm index.php;
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/wordpress/gb35658$fastcgi_script_name;
include fastcgi_params;
}
}
service nginx restart
service php-fpm restart
service mysql restart
启动以上三项服务
设置数据库密码并创建数据库
use mysql;
update user set password=password("password") where user="root";
flush privileges;
create database wordpress;
此时,可以在网页上使用域名访问nginx运行的wordpress网站了。这需要在浏览器中输入:https://www.lingx.com