CentOs7.2编译安装Nginx服务器
1. 安装nginx依赖
首先安装nginx的依赖
yum install gcc gcc-c++ openssl openssl-devel cyrus-sasl-md52,创建nginx用户
如果没有nginx,启动nginx时会报错
[root@localhost nginx-1.11.2]# /usr/local/nginx/sbin/nginx nginx: [emerg] getpwnam("nginx") failed 因此执行 groupadd nginxuseradd -s /sbin/nologin -g nigix -M nginx
3,下载最新版nginx安装包
wget -C http://nginx.org/download/nginx-1.12.0.tar.gz4,解压
tar zxvf nginx-1.12.0.tar.gz5,进入nginx目录
cd nginx-1.12.06,编译设置
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module因此要顺利的通过nginx编译安装必须安装的依赖关系有:
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel如果有错误提示:./configure: error: C compiler cc is not found
解决方法:
yum install gcc gcc-c++如果有错误提示:./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using –without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre=<path> option.
解决方法:
yum install pcre-devel如果有错误提示:./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl=<path> option.
解决方法:
yum install openssl-devel7,编译&安装 make & make install
8,nginx直接启动方法 /usr/local/nginx/sbin/nginx
9,现在我们将nginx加入到环境变量中
vi /etc/profile随后我们更新环境变量 并使用命令再次重启nginx
写在结尾:可能会出现没有pid文件的情况
ps -ef|grep nginx 过滤出nginx的进程号,然后在配置文件中 pid配置目录创建一个pid文件,里面填写nginx的进程号就可以了。[emerg]: getpwnam(“nginx”) failed
| 1 2 | [root@localhost nginx-1.11.2]# /usr/local/nginx/sbin/nginx nginx: [emerg] getpwnam("nginx") failed |
转载于:https://www.cnblogs.com/pcyy/p/8834851.html
总结
以上是生活随笔为你收集整理的CentOs7.2编译安装Nginx服务器的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Esri大赛:添加Arcgis Andr
- 下一篇: Nginx服务基础