关闭防火墙
[root@base2 ~]# systemctl stop firewalld
关闭selinux
[root@base2 yum.repos.d]# setenforce 0
一、安装Nginx
使用Nginx官方提供的rpm包
[root@base2 ~]# cd /etc/yum.repos.d
[root@base2 yum.repos.d]# vim nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
[root@base2 yum.repos.d]# yum -y install nginx
[root@base2 yum.repos.d]# systemctl start nginx
[root@base2 yum.repos.d]# systemctl enable nginx
二、使用第三方扩展epel源安装PHP7.2
获取epel拓展源
[root@base2 yum.repos.d]# yum -y install epel-release
[root@base2 yum.repos.d]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装php72版本
[root@base2 yum.repos.d]# yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache
[root@base2 yum.repos.d]# systemctl start php-fpm
[root@base2 yum.repos.d]# systemctl enable php-fpm
三、安装mysql
[root@base2 yum.repos.d]# rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-release-el7-5.noarch.rpm
[root@base2 yum.repos.d]# yum -y install mysql-community-server
[root@base2 yum.repos.d]# systemctl start mysqld
[root@base2 yum.repos.d]# systemctl enable mysqld
修改mysql密码
[root@base2 yum.repos.d]# mysql_secure_installation
四、搭建wordpress
1.下载wordpress源码包
2.复制wordpress安装包,到虚拟机/,解压并赋权
[root@base2 /]# unzip wordpress-4.9.4-zh_CN.zip
[root@base2 /]# chmod -R 777 /wordpress
3.创建虚拟主机配置文件
[root@base2 /]# vim /etc/nginx/conf.d/blog.conf
server {
listen 80;
server_name blog.benet.com;
root /wordpress;
index index.php index.html;
location ~ \.php$ {
root /wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[root@base2 /]# systemctl reload nginx
4.创建blog数据库和管理用户
[root@base2 /]# mysql -uroot -pasd123
mysql> create database blog;
mysql> grant all on blog.* to zj@localhost identified by 'asd123';
5.客户端通过域名访问blog,安装并配置
修改/etc/hosts下的文件,提供域名解析。
[root@base2 /]# vim /etc/hosts
客户端IP blog.benet.com
客户端访问域名
http://blog.benet.com
登录后台
http://blog.benet.com/wp-admin
五、搭建知乎wecenter
1.下载wecenter源码包
2.复制wecenter安装包,到虚拟机/zh目录下,赋权
[root@base2 /]# mkdir /zh
[root@base2 /]# cd /zh
[root@base2 zh]# unzip wecenter_3-3-4.zip
[root@base2 zh]# chmod -R 777 /zh
3.创建虚拟主机配置文件
[root@base2 zh]# vim /etc/nginx/conf.d/zh.conf
server {
listen 80;
server_name zh.benet.com;
root /zh;
index index.php index.html;
location ~ \.php$ {
root /zh;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[root@base2 zh]# systemctl reload nginx
4.创建zh数据库和管理用户
登录数据库
[root@base2 zh]# mysql -uroot -pasd123
mysql> create database zh;
mysql> grant all on zh.* to li@localhost identified by 'asd123';
5.客户端通过域名访问zh,安装并配置
修改/etc/hosts/下的文件
[root@base2 zh]# vim /etc/hosts
客户端IP zh.benet.com
客户端访问域名
http://zh.benet.com
登录后台
http://zh.benet.com/?/admin