【编译安装Nginx】
为了顺利安装Nginx,先安装下面这些:
【CentOS 编译 nginx 前要做的事情】
yum install gcc gcc-c++ kernel-devel yum -y install pcre-devel openssl openssl-devel【Ubuntu 编译 nginx 前要做的事情】
apt-get install gcc
apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g zlib1g-dev
apt-get install openssl openssl-dev
sudo apt-get install libcurl3-openssl-dev
解压 nginx-1.7.4.tar.gz ,然后进入目录,开始编译。
命令:
sudo ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
编译完的界面:
这个过程可能出现的错误:
./configure: error: the HTTP cache module requires md5 functions from OpenSSL library. You can either disable the module by using --without-http-cache option, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-http_ssl_module --with-openssl=<path> options.
解决:
sudo apt-get install openssl
sudo apt-get install libssl-dev
然后 make && make install
使用命令:/usr/local/server/nginx/sbin/nginx 启动Nginx.
使用命令:/usr/local/server/nginx/sbin/nginx -s reload 重启Nginx.
使用命令:/usr/local/server/nginx/sbin/nginx -s stop 终止Nginx.
查看是否已经成功启动nginx:
ps -ef | grep nginx
或者使用:ps -A | grep -i nginx