centos6.9 部署wordpress
用centos6.9搭建wordpress
Linux、Nginx、Mariadb(Mysql)、PHP
1
yum install nginx mariadb php php-fpm php-mysql
nginx与mariadb需要添加源
cd /etc/yum.repos.d/
vim nginx.repo
填写如下内容:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
mariadb类似,在centos7.0自带MariaDB源
2
获取最新的wordpress安装程序,解压到/var/www/html/目录下。
wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz
tar -xvf wordpress-4.8.1-zh_CN.tar.gz -C /var/www/html/
cd /var/www/html/
ls
wordpress
3
权限配置
vi /etc/php-fpm.d/www.conf #编辑
user = nginx #修改用户为nginx
group = nginx #修改组为nginx
chown nginx.nginx /usr/share/nginx/html/ -R #设置目录所有者
chmod 755 /usr/share/nginx/html/ -R #设置目录权限
4
配置nginx根路径
location / {
#root /usr/share/nginx/html;
root /var/www/html;
index index.html index.htm index.php;
}
配置nginx转发支持php
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
5
配置完成后重新加载配置
nginx -s reload
启动php-fpm
service php-fpm start
6
linux防火墙,iptables,与selinux
centos6.9
关闭iptables
service iptables stop #临时
chkconfig iptables off #永久
可以配置iptables开放端口
关闭selinux,
setenforce 0 #临时
修改/etc/selinux/config 文件永久关闭
将SELINUX=enforcing改为SELINUX=disabled
也可以配置策略
没有关闭selinux可能提示access denied
nginx错误打印FastCGI sent in stderr: "Unable to open primary script
7
数据库配置
mysql -uroot
create database wordpress;
grant all on wordpress.* to sqladmin@localhost identified by "123456";
8 浏览器访问http://ip/wordpress
根据提示完成数据库与用户设置