CentOS 7 安装 WordPress,PHP,Nginx,MySQL(MariaDB),FTP
主要资料参考:https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-71、安装 nginx:
yum install nginx使用 yum 安装
systemctl start nginx.service开启 nginx 服务
systemctl enable nginx.service跟随系统启动
2、安装 MySQL(MariaDB)
yum install mariadb-server mariadb使用 yum 安装
systemctl start mariadb启动数据库
systemctl enable mariadb开机启动
mysql_secure_installation设置安全策略,会询问以下5个问题
a)为root用户设置密码
b)删除匿名账号
c)取消root用户远程登录
d)删除test库和对test库的访问权限
e)刷新授权表使修改生效
mysql -u root -p连接数据库
create database wordpress;连接数据库后使用命令操作数据库
3、安装 PHP
yum install php php-mysql php-fpm安装 PHP 和必须的连接 MySQL 和 Nginx 的扩展
vi /etc/php.ini配置 PHP:
cgi.fix_pathinfo=0这行前的分号去掉,将1改为0
vi /etc/php-fpm.d/www.conf编辑服务器连接配置:
listen = /var/run/php-fpm/php-fpm.sock将 listen 的值改为此值
listen.owner = nobody这行前的分号去掉
listen.group = nobody这行前的分号去掉
user = nginx
group = nginx将这两行的值由 apache 改为 nginx
systemctl start php-fpm
systemctl enable php-fpm
4、配置 Nginx 到 PHP
vi /etc/nginx/conf.d/wordpress.conf
server { listen
80; server_nametirion.me www.tirion.me;
# note that these lines are originally from the
"location /" block root
/home/web/wordpress;# 配置 wordpress 的目录路径
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
systemctl restart nginx
5、安装 FTP
yum install vsftpd安装 FTP 服务
systemctl start vsftpd.service
systemctl enable vsftpd.service
vi /etc/vsftpd/vsftpd.conf修改 FTP 配置:
anonymous_enable=NO这行改为 NO,不允许匿名登录
允许 root 用户使用 FTP:
去掉或注释掉 /etc/vsftpd/ftpusers 中的root
去掉或注释掉 /etc/vsftpd/user_list 中的root
配置 iptables:
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
systemctl restart vsftpd.service重启 FTP 服务
6、安装 WordPress
1) 从 https://cn.wordpress.org/ 下载 WordPress 安装包,解压后通过 FTP 上传到服务器相应的目录,这里就是 /home/web/wordpress
2) chmod 777 -R wordpress给 WordPress 权限
3) 通过 url 访问:http://tirion.me/wp-admin/install.php 进行自动安装
4) 根据需要进行配置 MySQL 连接的用户名、密码、使用的数据库名,进行安装即可
页:
[1]