环境说明
主机名 |
IP |
服务 |
wyt1 |
192.168.179.128 |
nginx mysql php |
部署
关闭防火墙及selinux
[root@wyt1 ~]# systemctl disable --now firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@wyt1 ~]# setenforce 0
[root@wyt1 ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
配置网络源
[root@wyt1 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@wyt1 ~]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
[root@wyt1 ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@wyt1 ~]# yum -y install vim wget
[root@wyt1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
1.安装nginx
创建nginx服务的用户和组
[root@wyt1 ~]# useradd -r -M -s /sbin/nologin nginx
[root@wyt1 ~]# id nginx
uid=997(nginx) gid=995(nginx) 组=995(nginx)
安装开发工具包
[root@wyt1 ~]# yum -y groups mark install 'Development Tools'
安装依赖包
[root@wyt1 ~]# yum -y install pcre-devel openssl openssl-devel gd gd-devel gcc gcc-c++
创建日志存放目录
[root@wyt1 ~]# mkdir -p /var/log/nginx
[root@wyt1 ~]# chown -R nginx.nginx /var/log/nginx
下载nginx解压
[root@wyt1 ~]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
[root@wyt1 ~]# tar xf nginx-1.18.0.tar.gz
[root@wyt1 ~]# ls
anaconda-ks.cfg nginx-1.18.0 nginx-1.18.0.tar.gz
编译安装
[root@wyt1 ~]# cd nginx-1.18.0
[root@wyt1 nginx-1.18.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log
[root@wyt1 nginx-1.18.0]# make -j `nproc`
[root@wyt1 nginx-1.18.0]# make install
配置环境变量
[root@wyt1 ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@wyt1 ~]# source /etc/profile.d/nginx.sh
[root@wyt1 ~]# echo $PATH
/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin