CentOS 下編譯安裝 Nginx

摘要:

主要講述了編譯安裝 Nginx

安裝 pcre

pcre: 支持正則表達式,地址重寫rewrite

tar -xvf tar_ball/pcre-8.38.tar.gz
cd pcre-8.38/
./configure --prefix=/usr/local/pcre-8.38
make && make install

編譯安裝 Nginx

yum install openssl openssl-devel
groupadd www
useradd -g www www -s /sbin/nologin
tar -xvf tar_ball/nginx-1.9.12.tar.gz
cd nginx-1.9.12/

# 注意轉義符號後面不要跟空格
[root@localhost nginx-1.9.12]# ./configure \
> --prefix=/usr/local/nginx-1.9.12 \
> --user=www \
> --group=www \
> --with-http_ssl_module \
> --with-http_flv_module \
> --with-http_stub_status_module \
> --with-http_gzip_static_module \
> --with-pcre=/root/source/pcre-8.38/  # 注意要指定pcre源碼包位置

make
make install

# 啓動並測試
/usr/local/nginx-1.9.12/sbin/nginx -t  # 測試配置文件
/usr/local/nginx-1.9.12/sbin/nginx  # 啓動Nginx
lsof -i:80  # 查看80端口占用情況
elinks -dump http://localhost  # 用elinks測試本機

# 在 /etc/profile 中添加如下語句
  pathmunge /usr/local/nginx-1.9.12/sbin/ after  # 添加Nginx可執行文件的PATH
發佈了69 篇原創文章 · 獲贊 17 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章