本文共 1768 字,大约阅读时间需要 5 分钟。
1.从nginx的官方网站下载nginx的安装源码包,要下载.gz格式的包才是linux安装包 网址http://nginx.org/download/
wget http://nginx.org/download/nginx-1.5.9.tar.gz
2.解压
tar -zxvf nginx-1.5.9.tar.gzyum -y install pcre-devel gcc gcc-c++ autoconf automake make zlib-devel openssl openssl-devel
3.打开解压后的目录 配置安装环境-执行命令:
cd nginx-1.6.0./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-pcre --with-http_v2_module
--with-http_stub_status_module:支持nginx状态查询
--with-http_ssl_module:支持https--with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持--with-pcre:为了支持rewrite重写功能,必须制定pcre为了支持rewrite功能,我们需要安装pcre
yum install pcre*需要ssl的支持yum install openssl*4.在解压目录执行编译命令:
make && make install
5.创建软链:执行命令:
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx
6.【启动nginx服务】:执行命令:/usr/local/servers/nginx/sbin/nginx
7.【查看nginx服务是否启动成功】:执行命令:ps -ef|grep nginx,如果成功应该会出来两条数据8.停止9.1先查询nginx主进程号 ps -ef|grep nginx在进程列表里面找master进程,他的编号就是主进程号了9.2发送信号1从容停止nginxkill -QUIT 主进程号2快速停止nginxkill -TERM 主进程号3强制停止nginxkill -9 nginx 1 ./congigure: error: the HTTP rewrite module requires the PCRE library 安装pcre-devel 解决问题 yum -y install pcre-devel2 ./configure: error: C compiler cc is not found yum install gcc yum install gcc-c++ yum install autoconf yum install automakeyum install make3 ./configure: error: the HTTP gzip module requires the zlib library yum install zlib-devel4 ./configure: error: the …from OpenSSL library. with-openssl=options yum -y install openssl openssl-devel
转载于:https://blog.51cto.com/12390045/2361627