原文地址:http://www.hangzai.net/debian-9-php-7-1-nginx-mysql-5-7-wordpress/php
第一步安装须要的依赖包
apt install nginx mysql-server php7.1-fpm php7.1-mysql php7.1-json php7.1-mcrypt php7.1-curl php7.1-opcache php7.1-mbstring php7.1-readline
第二步修改nginx配置文件
修改文件html
nano hangzai.net.conf
mysql
server { server_name www.hangzai.net; access_log /data/www/hangzai.net/logs/access.log; error_log /data/www/hangzai.net/logs/error.log; root /data/www/hangzai.net/htdocs; location / { index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
第三步权限
cat /etc/passwd chown -R www-data:www-data /data/www
第四步配置WordPress
配置数据库部分
写博客固然得先建好数据库,下面咱们来配置一下MySQL数据库。nginx
进入MySQL:sql
mysql -uroot -p
输入root用户的密码进入数据库。接下来就须要建立WordPress数据库了:数据库
CREATE DATABASE wordpress;
接下来为wordpress建立一个新用户:json
CREATE USER wpuser@localhost;
为此用户设置密码,好比把密码设置成wordpresspassword
:浏览器
SET PASSWORD FOR wpuser@localhost=PASSWORD("wordpresspassword");
还要为此用户设置访问wordpress数据库的权限:php7
GRANT ALL PRIVILEGES ON wordpress.* TO wpuser@localhost IDENTIFIED BY 'wordpresspassword';
最后将权限生效:curl
FLUSH PRIVILEGES;
下载wordpress 安装包
wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.zip
解压wordpress 安装包
upzip wordpress-4.8.1-zh_CN.zip
目录更名为 htdocs
mv wordpress htdocs
经过浏览器直接访问域名,填写数据库信息,而后下一步,会把配置文件信息输出在页面的文本框,把文本框内容所有复制下来,在htdocs目录建立新文件wp-config.php,把内容粘贴到里边,再下一步设置站点信息和帐户。