WordPress 安装教程

847Views
No Comments

WordPress 运行的环境我使用 Linux + Nginx + Php + Mysql

下面就是基本的环境安装

install nginx and vhost

安装 Nginx 和 创建虚拟主机

sudo apt-get install nginx
sudo mkdir -p /var/www/example.com/html
sudo chown -R $USER:$USER /var/www/example.com/html
sudo chmod -R 755 /var/www
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com

设置如下配置:

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

    root /var/www/example.com/html;
    index index.html index.htm index.nginx-debian.html;

    server_name example.com www.example.com;

    location / {
        try_files $uri $uri/ =404;
    }
}

启用虚拟主机

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

测试 Nginx 配置

sudo nginx -t

重启 Nginx

sudo systemctl restart nginx

访问站点 http://example.com

mysql

安装MySQL

sudo apt-get install mysql-server

然后登录 mysql 创建表和用户

mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost;
FLUSH PRIVILEGES;
exit

php

sudo apt-get install php-fpm php-mysql

修改php配置

sudo vim /etc/php/7.0/fpm/php.ini

将下面的配置修改为 0

cgi.fix_pathinfo=0

重启 php

sudo systemctl restart php7.0-fpm

修改 nginx conf

server {
   listen 80 default_server;
   listen [::]:80 default_server;
   root /var/www/html;
   index index.php index.html index.htm index.nginx-debian.html;
   server_name server_domain_or_IP;
   location / {
       try_files $uri $uri/ =404;
   }
   location ~ \.php$ {
       include snippets/fastcgi-php.conf;
       fastcgi_pass unix:/run/php/php7.0-fpm.sock;
   }
   location ~ /\.ht {
       deny all;
   }
}

测试 PHP 安装

sudo vim /var/www/html/info.php

输入以下内容

<?php
phpinfo(); ?>

install

下载代码

wget http://wordpress.org/latest.tar.gz

解压

tar xzvf latest.tar.gz

修改配置

cp wp-config-sample.php wp-config.php

修改 config file

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wordpressuser');
/** MySQL database password */
define('DB_PASSWORD', 'password');

访问站点。

正文完
 
Comment(No Comments)