注意,本教程安装环境为centos7,使用nginx官网压缩包编译安装(非rpm或apt),本人亲测有效~
service nginx stop
chkconfig nginx off
yum remove nginx
rm -rf /usr/sbin/nginx
rm -rf /etc/nginx
rm -rf /etc/init.d/nginx
- `yum update`
- `yum install gc gcc gcc-c++ pcre-devel zlib-devel make wget openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel gperftools gperftools-devel libatomic_ops-devel perl-ExtUtils-Embed`下载
tar -xvzf nginx-1.18.0.tar.gz
useradd nginx
usermod -s /sbin/nologin nginx
cd nginx-1.18.0
./configure --help
./configure --user=nginx --group=nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-select_module --with-poll_module --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-cpp_test_module --with-cpu-opt=CPU --with-pcre --with-pcre-jit --with-zlib-asm=CPU --with-libatomic --with-debug --with-ld-opt="-Wl,-E"
注意不同版本的nginx其参数可能会有差异,具体请使用--help查看
make && make install
/usr/sbin/nginx -c /etc/nginx/nginx.conf
/usr/sbin/nginx -s stop
or kill -9 xxx
/usr/sbin/nginx -s reload
ps -ef|grep nginx
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone= public --query-port=80/tcp
-- 以上安装步骤较为简要,如有谬误之处请留言哈?--