腾讯云 Centos7-nginx-mariadb-php-fpm-wordpress

目录 Linux, 工具

安装所需程序

yum install php php-mysql php-fpm lrzsz nginx mariadb mariadb-server -y

Cenos 7 启动服务

systemctl start nginx
systemctl start mariadb
systemctl start php-fpm

服务开机启动

systemctl enable nginx
systemctl enable mariadb
systemctl enable php-fpm

登录mysql并创建wordpress数据库,创建成功后退出数据库

mysql -u root -p
create database wordpress;
quit

创建存放worpress的文件夹:

mkdir /home/www/web

到worpress目录去

cd /home/www/web

下载wordpress文件

wget https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz

解压wordpress文件到当前目录

tar -zxvf wordpress-4.7.4-zh_CN.tar.gz

修改目录的所有者

chown -R apache:apache /home/www/web

修改目录的权限

chmod -R 777 /home/www/web

创建nginx配置文件:内容在文件末尾

vim /etc/nginx/conf.d/wordpress.conf

验证配置:

nginx -t

输出以下内容表示配置没有问题:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

重启nginx服务

systemctl reload nginx

打开浏览器,地址栏输入:
119.29.183.161
点击现在就开始;
数据库中:wordpress
用户名:root
密码:空
提交:
切回到xshell应用解决WordPress升级需要输入FTP信息wp-config.php文件最后加上下面这句:define(‘FS_METHOD’, “direct”);

vim /home/www/web/wordpress/wp-config.php

在文件末尾增加:

define(‘FS_METHOD’, “direct”);

保存文件
重启nginx服务

systemctl reload nginx
wordpress.conf

server {
    listen 80;
    server_name 119.29.183.161;
    root /home/www/web/wordpress;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
        index index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        access_log off; log_not_found off; expires max;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

备份转载自:http://www.testpub.cn/t/81