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服务基础