一、搭建nginx
1、配置nginx源
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.
yum search nginx
2、安装nginx
yum install -y pcre-devel openssl-devel 安装nginx依赖包
yum install -y nginx
3、实现PHP联动
配置nginx的/etc/nginx/conf.d/default.conf文件
4、添加域名**(将localhost添加到可访问的网址里)**
需要修改配置文件,将localhost写入文件里
vim /etc/hosts
添加:127.0.0.1 localhost
5、启动nginx并设置开机自启
systemctl start nginx #启动nginx服务
systemctl enable nginx #设置linux开机自动启动nginx
6、nginx上面挂两个域名并且能够通过域名访问
首先修改/etc/nginx/conf.d/default.conf
vim /etc/nginx/conf.d/default.conf
修改内容
然后接下来要把新加入的域名添加到/ect/hosts里
vim /etc/hosts
最后一步创建域名对应的站点目录及文件,也就是要写新的展示页面html文件
cd /usr/share/nginx/html/
mkdir hl01
echo "我是www.hl01.com">>hl01.html
mkdir hl02
cd hl02
echo "我是www.hl02.com">> hl02.html
重启nginx服务
systemctl restart nginx
二、搭建PHP
1、配置PHP源
rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
2、安装PHP-fpm所属需要的包
yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64 php72w-gd
3、启动PHP-fpm并设置开机自启
systemctl start php-fpm.service
systemctl enable php-fpm.service
三、安装Mysql
RPM包安装方式 下载5.7.36 RPM bundle版本并上传至服务器(xshell)
1、解压到/usr/local
tar -xvf mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar -C /usr/local/
2、安装依赖包
yum install zlib-devel gcc-c++ ncurses ncurses-devel libaio-devel -y
3、安装libs库
rpm -ivh mysql-community-libs-5.7.36-1.el7.x86_64.rpm --force --nodeps
(--force 强制安装,--nodeps 不查询依赖包,直接安装)
4、安装客户端
rpm -ivh mysql-community-client-5.7.36-1.el7.x86_64.rpm
5、安服务器
rpm -ivh mysql-community-common-5.7.36-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-devel-5.7.36-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-embedded-5.7.36-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-embedded-compat-5.7.36-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-embedded-devel-5.7.36-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-5.7.36-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-test-5.7.36-1.el7.x86_64.rpm --force --nodeps
6、启动mysql服务
systemctl start mysqld
7、查看mysqld服务
ps -aux |grep mysqld
netstat -atunp |grep mysqld
8、登录mysql
查看密码
cat /var/log/mysqld.log |grep password
mysql -uroot -p
9、密码有安全限制。可以通过如下命令修改:
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
10、然后可以改密码了
set password for root@localhost=password('123456');
firewall-cmd --zone=public --add-port=3306/tcp --permanent #开放3306端口
firewall-cmd --reload #刷新
四、安装wordpress
1、WordPress官方网站下载WorldPress-5.0.4中文版本
wget https://cn.wordpress.org/latest-zh_CN.tar.gz
tar zxvf latest-zh_CN.tar.gz -C /usr/share/nginx/html
2、配置数据库
mysql -u root -p
create database wordpress;
3、创建wordpress用户并设置密码
CREATE USER 'root'@'%' IDENTIFIED BY 'password';
4、给用户授权
grant all privileges on *.* to 'root';
5、刷新权限
flush privileges;
exit #退出
6、写入数据库信息
进入 WordPress 安装目录,将wp-config-sample.php文件复制到wp-config.php文件中,并将原先的示例配置文件保留作为备份
cd /usr/share/nginx/html/wordpress/
cp wp-config-sample.php wp-config.php
7、打开wp-config.php,将已配置好的数据库相关信息写入
vim wp-config.php
测试时关闭防火墙
systemctl stop firewalld