服务器系统优化
1.关闭防火墙
systemctl disable firewalld
systemctl stop firewalld
2.关闭SELINUX
永久关闭SElinux
/etc/selinux/config selinux的配置文件
SELINUX=enforcing 修改为SELINUX=disabled 重启系统生效
**2.**部署nginx服务
1.采用官方源安装nginx yum安装
添加eple源:
yum -y install epel-* 或
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
第一步:编写yum源文件
[root@web01 ~]# vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
第二步:清除yum缓存信息
yum clean all
第三步:yum安装软件
yum install -y nginx
3.部署php服务
1.准备yum安装软件扩展源信息
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
2.安装php服务相关软件
yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-mcrypt php71w-pecl-memcached php71w-pecl-mongodb php71w-pecl-redis
**4.**部署mariadb服务
1.yum安装mariadb服务
yum -y install mariadb-server mariadb
2.设置数据库密码
systemctl restart mariadb
mysqladmin password 123
**5.**搭建www网站
1.启动nginx php mariadb 服务
systemctl restart nginx php-fpm mariadb
2.编写nginx主配置文件,修改启动用户为cheng
[root@web01 ~]# vim /etc/nginx/nginx.conf
error_log /var/log/nginx/error.log warn;
user cheng;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
...
3.编写php配置文件,修改启动用户为cheng
[root@web01 ~]# vim /etc/php-fpm.d/cheng.conf
user = cheng
group = cheng
...
4.创建www站点配置文件
[root@web01 ~]# cd /etc/nginx/conf.d/
[root@web01 conf.d]# touch cheng.conf (名字随便,必须以.conf结尾)
[root@web01 conf.d]# vim cheng.conf
server {
listen 80;
server_name www.cheng.com;
location / {
root /html/cheng;
index index.php index.html ;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
root /html/cheng;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param HTTPS on;
include fastcgi_params;
}
}
systemctl restart nginx
5.创建站点目录
检查有没有cheng用户
id cheng
没有创建
useradd cheng
[root@web01 ~]# mkdir /html/cheng -p
将准备的好的wordpress程序包传输到站点目录下
解压压缩包,注意解压出来的文件目录层级不一样,需要把站点程序文件全放在/html/cheng下
将blog站点目录权限属主属组设置为cheng 需要递归设置
[root@web01 html]# chown -R cheng.cheng cheng
6.配置数据库
登录数据库
[root@web01 html]# mysql -uroot -p123456
创建新的数据库: create database cheng;
创建数据库管理用户: grant all on cheng.* to ‘cheng’@‘localhost’ identified by ‘123456’;
重启数据库服务
systemctl restart mariadb
在电脑c盘进行域名解析
c/windows/system32/drivers/etc/hosts进行修改
7.访问域名站点网址进行配置
…
完成
第二个网站配置
4.创建站点配置文件
[root@web01 ~]# cd /etc/nginx/conf.d/
[root@web01 conf.d]# touch hello.conf
[root@web01 conf.d]# vim hello.conf
server {
listen 80;
server_name www.hello.com;
location / {
root /html/hello;
index index.php index.html ;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
root /html/hello;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param HTTPS on;
include fastcgi_params;
}
}
#重启nginx
5.创建站点目录
[root@web01 ~]# mkdir /html/hello -p
将准备的好的wordpress程序包传输到站点目录下
解压压缩包,注意解压出来的文件目录层级不一样,需要把站点程序文件全放在/html/hello下
将www站点目录权限属主属组设置为www 需要递归设置
[root@web01 html]# chown -R cheng.cheng hello
6.配置数据库
登录数据库
[root@web01 html]# mysql -uroot -p123456
创建新的数据库: create database hello;
创建数据库管理用户: grant all on hello.* to ‘hello’@‘localhost’ identified by ‘123456’;
重启数据库服务
systemctl restart mariadb