- 在hadoop202上运行yum,安装相关依赖包
sudo yum -y install openssl openssl-devel pcre pcre-devel zlib zlib-devel gcc gcc-c++
- 将/2.资料/工具下的nginx-1.12.2.tar.gz上传到/opt /software下
- 在/opt/module/software下解压缩nginx-1.12.2.tar.gz包
- 进入解压缩目录,执行
./configure --prefix=/opt/module/nginx make && make install
--prefix=要安装到的目录 - 安装成功后,/opt/module/nginx目录下结构
- 启动Nginx
在/opt/module/nginx/sbin目录下执行
./nginx
- 如果在zkx用户下面启动会报错
原因:nginx占用80端口,默认情况下非root用户不允许使用1024以下端口
解决:让当前用户的某个应用也可以使用1024以下的端口
sudo setcap cap_net_bind_service=+eip /opt/module/nginx/sbin/nginx
注意:要根据自己的实际路径进行配置 - 查看启动情况
ps -ef |grep nginx
因为nginx不是用java写的,所以不能通过jps查看 - 在浏览器中输入http://hadoop202/访问
==========================================================
- 重启Nginx
./nginx -s reload
- 关闭Nginx
./nginx -s stop
- 通过配置文件启动
./nginx -c /opt/module/nginx/conf/nginx.conf /opt/module/nginx/sbin/nginx -c /opt/module/nginx/conf/nginx.conf
其中-c是指定配置文件,而且配置文件路径必须指定绝对路径 - 配置检查
当修改Nginx配置文件后,可以使用Nginx命令进行配置文件语法检查,用于检查Nginx配置文件是否正确
/opt/module /nginx/sbin/nginx -c /opt/module/nginx/conf/nginx.conf –t
- 如果80端口号被占用 httpd
sudo systemctl stop httpd
sudo systemctl disable httpd - 部分机器启动时报错:
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决:ln -s /usr/local/lib/libpcre.so.1 /lib64
./configure --prefix=/usr/local/nginx --add-module=/opt/softwarebei/echo-nginx-module-master && make -j2 && make install
网友评论