Linux / MySQL / 服务器 2019-05-11
1、安装软件包:
sudo apt-get install nginx mariadb-server php-fpm php php-mysql
cd /var/www
wget https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
rm latest.tar.gz
2、配置mariadb:
sudo passwd //设置系统root密码
su //切换root用户
mysql_secure_installlation //初始化数据库
mysql //进入mysql终端
insert into mysql.user(Host,User,Password) values(“localhost”,”admin”,password(“admin”)); //创建名为:admin 密码为:admin 的用户。
flush privileges;//刷新系统权限表
create database mydb;//授权admin用户拥有mydb数据库的所有权限。
grant all privileges on mydb.* to admin@localhost identified by ‘admin’;//刷新系统权限表
flush privileges;//刷新系统权限表
3、配置wordpress:
su yourname //退出root账户
mv /usr/share/wordpress /var/www/wordpress //移动wordpress到常用的web目录下
cd /var/www/wordpress
cp wp-config-sample.php wp-config.php //用wp-config-sample.php覆盖掉debain自己弄的 wp-config.php
nano wp-config.php //设置上一步里的数据库、用户名和密码
- Example:
define('DB_NAME', 'wpdb'); /** MySQL database username */ define('DB_USER', 'user'); /** MySQL database password */ define('DB_PASSWORD', 'user1234'); /** MySQL hostname */ define('DB_HOST', 'localhost');
4、配置nginx
cd /etc/nginx/conf.d
sudo nano default.conf//设置网点目录等
- Example:
server {
listen 80;
root /var/www/wordpress;
index index.php index.html index.htm;
server_name yourdomain www.yourdomain;location / {
try_files $uri $uri/ /index.php?$args;
}location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; //这里依据php版本修改
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
5、设置wordpress文件夹nginx的权限:
cd /var/www/wordpress
chown -R www-data:www-data *
chmod 755 *
6、重启nginx
systemctl restart nginx