Nginx的安装
如果在运行下面命令出现 wget commond not found 需要先安装wget,命令 # yum -y install wget
安装必要的库 gzip 模块需要 zlib 库 rewrite 模块需要 pcre,ssl, openssl 库
安装 gcc gcc-c++(如新环境,未安装请先安装)
yum install -y gcc gcc-c++
安装 PCRE 库
cd /usr/local/
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
tar -zxvf pcre-8.33.tar.gz
cd pcre-8.33
./configure
make && make install
如报错:configure: error: You need a C++ compiler for C++ support
解决:yum install -y gcc gcc-c++
安装SSL 库
cd /usr/local/
wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
tar -zxvf openssl-1.0.1j.tar.gz
cd openssl-1.0.1j
./config
make && make install
安装zlib 库
cd /usr/local/
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
安 装nginx
cd /usr/local/
wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure
make && make install
./configure --user=nobody
./configure --group=nobody
./configure --prefix=/usr/local/nginx
./configure --with-http_stub_status_module
./configure --with-http_gzip_static_module
./configure --with-http_realip_module
./configure --with-http_sub_module
./configure --with-http_ssl_module
如果启动提示 make: *** No rule to make target build', needed by
default’. Stop. 或者 make: *** 没有规则可以创建“default”需要的目标“build”表示需要安装依赖包
安装依赖包命令
yum install pcre-devel zlib zlib-devel openssl openssl-develke。。。。
启动,重启,停止,测试配置文件是否正常,强制关闭
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx –s reload
/usr/local/nginx/sbin/nginx –s stop
/usr/local/nginx/sbin/nginx –t
pkill nginx
启动成功业务无提示,后默认端口为 80 通过浏览器直接访问就可以看到页面了。
linux下启动和关闭nginx命令
whereis nginx
cd /usr/local/nginx/sbin
./nginx
出现下面启动成功
ps -ef | grep nginx
出现master 则启动成功
./nginx -s stop
./nginx -s reload