菜单

Mina
发布于 2024-12-19 / 10 阅读

Nginx源码编译安装方式

1.安装依赖

yum -y install gcc zlib zlib-devel pcre pcre-devel openssl openssl-devel

2.下载nginx源码包

wget https://nginx.org/download/nginx-1.26.2.tar.gz

3.解压源码包

tar zxvf nginx-1.26.2.tar.gz

cd nginx-1.26.2

4.编译

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http

make -j2

make install

5.启动

cd /usr/local/nginx/sbin

./nginx

6.配置nginx.service

7.centos7防火墙相关命令

firewall-cmd --zone=public --add-port=80/tcp --permanent

firewall-cmd --reload

systemctl stop|start firewalld

systemctl disable|enable firewalld

systemctl daemon-reload

//卸载(需要先停止nginx并取消自动启动)

find / -name nginx*

rm -rf /usr/local/nginx