1.从nginx的官方网站下载nginx的安装源码包,要下载.gz格式的包才是linux安装包 网址http://nginx.org/download/ linux
wget http://nginx.org/download/nginx-1.5.9.tar.gz
2.解压 nginx
tar -zxvf nginx-1.5.9.tar.gz yum -y install pcre-devel gcc gcc-c++ autoconf automake make zlib-devel openssl openssl-devel
3.打开解压后的目录 配置安装环境-执行命令:c++
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重写功能,必须制定pcreide
为了支持rewrite功能,咱们须要安装pcre
yum install pcre*
须要ssl的支持
yum install openssl*网站
4.在解压目录执行编译命令:make && make install
ui
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从容中止nginx
kill -QUIT 主进程号
2快速中止nginx
kill -TERM 主进程号
3强制中止nginx
kill -9 nginxgoogle
1 ./congigure: error: the HTTP rewrite module requires the PCRE library 安装pcre-devel 解决问题 yum -y install pcre-devel 2 ./configure: error: C compiler cc is not found yum install gcc yum install gcc-c++ yum install autoconf yum install automake yum install make 3 ./configure: error: the HTTP gzip module requires the zlib library yum install zlib-devel 4 ./configure: error: the …from OpenSSL library. with-openssl=<path>options yum -y install openssl openssl-devel