CentOs7.2编译安装Nginx服务器
1. 安裝nginx依賴(lài)
首先安裝nginx的依賴(lài)
yum install gcc gcc-c++ openssl openssl-devel cyrus-sasl-md52,創(chuàng)建nginx用戶(hù)
如果沒(méi)有nginx,啟動(dòng)nginx時(shí)會(huì)報(bào)錯(cuò)
[root@localhost nginx-1.11.2]# /usr/local/nginx/sbin/nginx nginx: [emerg] getpwnam("nginx") failed 因此執(zhí)行 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,進(jìn)入nginx目錄
cd nginx-1.12.06,編譯設(shè)置
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module因此要順利的通過(guò)nginx編譯安裝必須安裝的依賴(lài)關(guān)系有:
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel如果有錯(cuò)誤提示:./configure: error: C compiler cc is not found
解決方法:
yum install gcc gcc-c++如果有錯(cuò)誤提示:./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如果有錯(cuò)誤提示:./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直接啟動(dòng)方法 /usr/local/nginx/sbin/nginx
9,現(xiàn)在我們將nginx加入到環(huán)境變量中
vi /etc/profile隨后我們更新環(huán)境變量 并使用命令再次重啟nginx
寫(xiě)在結(jié)尾:可能會(huì)出現(xiàn)沒(méi)有pid文件的情況
ps?-ef|grep?nginx 過(guò)濾出nginx的進(jìn)程號(hào),然后在配置文件中 pid配置目錄創(chuàng)建一個(gè)pid文件,里面填寫(xiě)nginx的進(jìn)程號(hào)就可以了。[emerg]: getpwnam(“nginx”) failed
| 1 2 | [root@localhost nginx-1.11.2]# /usr/local/nginx/sbin/nginx nginx: [emerg] getpwnam("nginx") failed |
轉(zhuǎn)載于:https://www.cnblogs.com/pcyy/p/8834851.html
總結(jié)
以上是生活随笔為你收集整理的CentOs7.2编译安装Nginx服务器的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Esri大赛:添加Arcgis Andr
- 下一篇: Nginx服务基础