您的位置:首页 > 运维架构 > Nginx

nginx源码包编译安装

2016-04-09 21:58 656 查看
1.到官方站点卸载nginx-1.6.3版本的源码包 http://nginx.org/en/download.html http://nginx.org
2.安装依赖包和编译工具
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
说明:nginx的重写功能依赖pcre-devel包

2.解压源码包
[root@bogon tmp]# tar xf nginx-1.6.3.tar.gz
[root@bogon tmp]# cd nginx-1.6.3
[root@bogon nginx-1.6.3]# ./configure --help
--help print this message
--prefix=PATH (程序安装路径) set installation prefix
--sbin-path=PATH (nginx主程序安装路径) set nginx binary pathname
--conf-path=PATH (主配置文件安装路径) set nginx.conf pathname
--error-log-path=PATH(错误日志安装路径) set error log pathname
--pid-path=PATH (pid文件路径) set nginx.pid pathname
--lock-path=PATH (锁文件路径 ) set nginx.lock pathname
--user=USER (work进程的运行身份,一般为普通用户) set non-privileged user for
worker processes
--group=GROUP set non-privileged group for worker processes
……………………………………查看配置说明

3.添加用户和组
[root@bogon nginx-1.6.3]# groupadd -r nginx
[root@bogon nginx-1.6.3]# useradd -g nginx -r nginx
[root@bogon nginx-1.6.3]# id nginx
uid=496(nginx) gid=493(nginx) 组=493(nginx)
4.编译nginx并配置安装路径,以及指明需要开启的模块
[root@bogon nginx-1.6.3]# ./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.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
说明:
--with-http_ssl_module:http的ssl模块
--with-http_stub_status_module:状态信息提供模块
--with-http_gzip_static_module:压缩静态资源的gzip模块
--with-http_flv_module:flv流媒体支持模块
--with-http_mp4_module:mp4流媒体支持模块
创建临时目录路径:
[root@bogon nginx-1.6.3]# mkdir -pv /var/tmp/nginx/{client,proxy,fastcgi,uwsgi}
[root@bogon nginx-1.6.3]# make && make install

5.启动nginx
[root@bogon nginx-1.6.3]# /usr/local/nginx/sbin/nginx //启动nginx
查看80端口的监听状态:
[root@bogon nginx-1.6.3]# ss -tnlp | grep nginx
LISTEN 0 128 *:80 *:* users:(("nginx",27544,6),("nginx",27545,6))
查看进程启动情况:
[root@bogon nginx-1.6.3]# ps aux | grep nginx
root 27544 0.0 0.1 44584 1136 ? Ss Mar23 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 27545 0.0 0.1 45012 1712 ? S Mar23 0:00 nginx: worker process
root 27588 0.0 0.0 103320 872 pts/3 S+ 00:02 0:00 grep nginx
可以看到,运行了一个master主进程和一个worker子进程
6.访问nginx http://192.168.1.102/ 会出现nginx欢迎界面

over!

本文出自 “小步前进” 博客,请务必保留此出处http://lxk008.blog.51cto.com/5061207/1762165
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: