首页 > 技术文章 > Nginx编译安装

xiaofengchu 2018-10-23 11:19 原文

# 准备安装环境

yum groupinstall '开发工具' -y
yum groupinstall '服务器平台开发' -y
yum install pcre-devel -y # 这个是Nginx需要,用于基于perl的正则表达式扩展

# 解包

tar -xf nginx-1.14.0.tar.gz
cd nginx-1.14.0

# 添加用户和组

groupadd -r nginx
useradd -g nginx -r nginx

# 配置 注意:其中 --conf-path=/etc/nginx/nginx.conf 可以不指定,不指定的话就在/usr/local/nginx目录下,这样的话方便卸载和迁移,做的标准点就放到/etc目录下

./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx/nginx.lock --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi

# 编译安装

make && make install

# 准备目录

mkdir -pv /var/tmp/nginx/{client,proxy,fastcgi,uwsgi}

# 启动Nginx

/usr/local/nginx/sbin/nginx

# 查看监听

ss -tnlp |grep --color nginx

# 查看进程

ps aux|grep --color nginx
root       4819  0.0  0.1  46888  1196 ?        Ss   19:02   0:00 nginx: master process /usr/local/nginx/sbin/nginx  # 一个主进程
nginx      4820  0.0  0.1  47320  1780 ?        S    19:02   0:00 nginx: worker process  # 一个work进程

 

# 访问查看效果

 

 

到这里Nginx编译安装就完成了。

 

推荐阅读