安装nginx前,我们首先要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件
#插件安装
yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
#解压安装
tar -zxvf nginx
进入目录
./configure --prefix=/usr/local/server/nginx
make
make install
#安装完毕
nginx 目录下新建 配置文件中 error.log access.log
#配置防火墙
vi + /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#重启防火墙
service iptables restart
启动
#方法1
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#方法2
cd /usr/local/nginx/sbin ./nginx
平滑重启
/usr/local/nginx/sbin/nginx -s reload
时间: 2024-10-09 13:54:45