安装Nginx

直接运行安装命令

apt-get install nginx

启动nginx

systemctl restart nginx.service

安装PHP

安装php时同时把需要的插件也补上

apt-get install php7.0 
apt-get install libapache2-mod-php7.0 
apt-get install php7.0-mysql
apt-get install php7.0-curl

安装MySQL

直接执行安装命令

apt-get install mysql-server mysql-client

创建wordpress指向的数据库

CREATE DATABASE `数据库` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;

配置Nginx

默认配置如下

server {
    listen 80;
    listen [::]:80;

    root /var/www/wordpress;

    # Add index.php to the list if you are using PHP
    index index.html index.php index.nginx-debian.html;

    server_name lubaogui.com;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
    
    #   # With php7.0-cgi alone:
    #   fastcgi_pass 127.0.0.1:9000;
    #   # With php7.0-fpm:
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}
}

默认配置里的域名和网站文件记得自行修改,重启nginx生效

systemctl restart nginx.service

配置WordPress

在wordpress文件中找到并修改wp-config.php文件

/** WordPress数据库的名称 */
define('DB_NAME', '数据库');

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

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

/** MySQL主机 */
define('DB_HOST', 'localhost');

/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');

/** 数据库整理类型。如不确定请勿更改 */
define('DB_COLLATE', '');

配置FTP

由于wordpress在后台上传主题和插件需要使用到ftp,在此贴下FTP操作链接。

Ubuntu FTP配置

当然如果不想配置FTP可以直接免掉FTP,修改wp-config.php文件,

#增加以下三条代码
define("FS_METHOD","direct");
 
define("FS_CHMOD_DIR", 0777);
 
define("FS_CHMOD_FILE", 0777);