一、安装nginx

1
2
3
4
5
6
7
8
9
# dnf==优化的yum
dnf install nginx -y

# 开机并自启
systemctl start nginx
systemctl enable nginx

# 一键部署LNMP(非常慢)
wget http://soft.vpser.net/lnmp/lnmp1.9.tar.gz -cO lnmp1.9.tar.gz && tar zxf lnmp1.9.tar.gz && cd lnmp1.9 && ./install.sh lnmp

二、安装数据库

1
2
3
4
5
6
7
8
9
# 安装mariadb数据库
yum -y install mariadb mariadb-server

# 重启并设置开机自启
systemctl start mariadb
systemctl enable mariadb

# 数据库初始化
mysql_secure_installation

三、安装PHP

1
2
3
4
5
6
# 安装网站需要的PHP环境(一班网页基于PHP写的),不晓得需求的组件就安装全部
dnf -y install php*

# 开机并自启
systemctl start php-fpm
systemctl enable php-fpm

四、修改Nginx的配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 配置文件目录
vim /etc/nginx/nginx.conf
# 站点目录

# ‘/’此处表示根路径,即/usr/share/nginx/html/
server{
root: /var/www/html
}
location / {
index index.php index.html index.htm;
}

# 修改配置文件重启生效
systemactl restart nginx

五、下载PHP网站代码并安装插件

1
2
3
4
5
6
7
8
9
10
11
# 安装解压和上传的组件
yum -y install unzip
yum -y install lrzsz

# 命令行输入如下回车(第三方连接软件里(CRT))
rz #在cn.wordpress.org下载好word press上传到/var/www/html 下

# 将wordpress目录下的文件复制上来,以便直接输入IP就能访问
cp -r wordpress/* ./ #把wordpress目录下的文件移动到当前目录
chown apache:apache -R ./ #将当前目录下的东西归属给apache
chmod 755 -R ./ #权限提升

六、数据库创建和用户添加

1
2
3
4
5
6
7
8
9
mysql -uroot -p #回车输入密码

create database wordpress; #创建数据库

create user wordpress@localhost identified by '123456'; #创建用户和密码

grant all privileges on wordpress.* to wordpress@localhost; #赋予权限

flush privileges; #刷新权限