Nginx 源碼編譯安裝


  Nginx 源碼編譯安裝環境

    Centos7

    Nginx1.8.1    下載地址:http://nginx.org/download/ 選擇自己想要的版本

     我這邊使用1.8.1,下載地址:http://nginx.org/download/nginx-1.8.1.tar.gz 

  

1、編譯前安裝環境

[root@CentOS7_30 ~]# yum groupinstall "Development Tools" -y                #安裝開發工具包
[root@CentOS7_30 ~]# yum install openssl-devel pcre-devel                   #ssl、pcre的devel包

2、下載Nginx

[root@CentOS7_30 ~]# cd /usr/local/src/                                    #進入src目錄
[root@CentOS7_30 src]# wget    #下載Nginx
[root@CentOS7_30 src]# tar xf nginx-1.8.1.tar.gz                           #解壓縮
[root@CentOS7_30 src]# cd nginx-1.8.1/                                     #進入nginx-1.8.1目錄
[root@CentOS7_30 nginx-1.8.1]#  ./configure \                              #編譯參數,按照自己的需要
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx --group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-threads   \
--with-file-aio  \
--with-ipv6 
[root@CentOS7_30 nginx-1.8.1]# make && make install
[root@CentOS7_30 nginx-1.8.1]# useradd -r nginx                     #創建Nginx,-r指定爲系統用戶
[root@CentOS7_30 nginx-1.8.1]# nginx -t                             #測試語法是否用問題
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@CentOS7_30 nginx-1.8.1]# /usr/sbin/nginx                      #啓動Nginx
[root@CentOS7_30 nginx-1.8.1]# ss -tnl| grep 80                     #查看是否成功
LISTEN     0      128                       *:80                       *:* 
[root@CentOS7_30 nginx-1.8.1]# ifconfig | grep "inet 192.168"       #查看地址
        inet 192.168.11.30  netmask 255.255.255.0  broadcast 192.168.11.255
[root@CentOS7_30 nginx-1.8.1]# iptables -F                          #清楚防火牆規則,要麼自己增加80端口
[root@CentOS7_30 nginx-1.8.1]# setenforce 0                         #設定selinux爲permissive

訪問試一試看看:

wKioL1f-EJLzzRHOAABj5IhXQw8127.png-wh_50

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章