nginx1.14.2部署

 
                               nginx 官网  http://nginx.org/download
 
一:下载
二:配置
三:启动

                一:下载

wget http://nginx.org/download/nginx-1.14.2.tar.gz
 
2.安装依赖
yum install pcre pcre-devel openssl openssl-devel zlib zlib-devel -y
3.解压
解压并安装nginx(注意定制的安装路径根据自己的需求自行更改 ):
 tar -zxvf nginx-1.14.2.tar.gz  && cd nginx-1.14.2/     
 

                二:配置

4.配置(注意,一定要进入到nginx目录中去  --prefix的可以理解为编译指定的到具体的data目录,跟解压后的nginx压缩包的路径没关系)
nginx模块编译如果用不到那么多模块,可以不用,组件多了,容易被攻击。
编译:
./configure --prefix=/data/nginx --http-client-body-temp-path=/data/nginx/cache/nginx/client_temp --http-proxy-temp-path=/data/nginx/cache/nginx/proxy_temp --http-fastcgi-temp-path=/data/nginx/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/data/nginx/cache/nginx/uwsgi_temp --http-scgi-temp-path=/data/nginx/cache/nginx/scgi_temp --user=forest --group=forest --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-pcre --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
make && make install
 
5.添加环境变量到系统:
vim /etc/profile.d/nginx.sh 
PATH=$PATH:/data/nginx/bin/:/data/nginx/sbin
 
source /etc/profile
6.添加启动脚本
### 3.1 编写nginx启动脚本:
[root@localhost ~]# vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
 
[Service]
Type=forking
ExecStart=/data/nginx/sbin/nginx
ExecReload=/data/nginx/sbin/nginx -s reload
ExecStop=/data/nginx/sbin/nginx -s quit
PrivateTmp=true
#EnvironmentFile=/etc/sysconfig/rdisc
#ExecStart=/sbin/rdisc $RDISCOPTS
 
[Install]
WantedBy=multi-user.target
 
### 3.2 添加开启启动:
systemctl enable nginx

              三:启动

 
启动
3.3 查看nginx服务状态:
systemctl start nginx
systemctl status nginx
参考文章:
https://www.cnblogs.com/zhenxing06/p/12706897.html
 
posted @   名字长的像一只老山羊  阅读(733)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示