1.查看是否有OpenSSL
ssh -V
下载nginx地址 http://nginx.org/en/download.html
2.解压到usr/local(到这个路径下使用)
cd /usr/local/nginx
3.执行命令
./configure
#提示权限不够,执行
chmod +x configure
#报错
#./configure: error: C compiler cc is not found 执行安装gcc 编译器
yum -y install gcc gcc-c++ autoconf automake make
#报错
#nginx error: the HTTP rewrite module requires the PCRE library.
#安装下
yum -y install pcre-devel
#报错 需要安装“zlib-devel”即可 ./configure: error: the HTTP gzip module requires the zlib library.
yum install -y zlib-devel
4.//执行make命令
make
报错 缺少依赖
yum install pcre-devel zlib zlib-devel openssl openssl-devel
如果还是报错,执行下
./configure
//执行make install命令
make install
报错
执行
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf
解决
5.替换 /usr/local/nginx/conf 里的配置文件
- 开机自启
vim /etc/rc.local
在文件末尾添加
/usr/local/nginx/sbin/nginx
nginx配置完成
启动nginx
端口占用
ps -ef|grep java 查看情况
启动,关闭,重启,命令:
到sbin目录下执行
./nginx 启动
./nginx -s stop 关闭
./nginx -s reload 重启
如果出现报错:nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed
则运行: /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf