| 導讀 |
Nginx是一款開放原始碼的高效能HTTP伺服器和反向 Proxy伺服器,同時支援IMAP/POP3代理服務,是一款自由的軟體,同時也是營運工程師必會的一種伺服器,下面我就簡單的說一下Nginx伺服器的安裝和檔案解析。 |
簡單安裝
本教程一Centos 6.3為例講解,軟體包可以在官方網站下載,編譯安裝之前,我們需要使用YUM提前將所需的軟體依賴包安裝完成。
安裝命令如下:
[root@centos6 ~]# wget http://nginx.org/download/nginx-1.4.0.tar.gz[root@centos6 ~]# tar -xzf nginx-1.4.0.tar.gz -C /usr/src[root@centos6 ~]# yum -y install gcc pcre pcre-devel openssl \>openssl-devel gd gd-devel perl perl-ExtUtils-Embed[root@centos6 ~]# cd /usr/src/nginx-1.4.0/[root@centos6 nginx-1.4.0]# ./configure --prefix=/usr/local/nginx \>--with-ipv6 \>--with-http_ssl_module \>--with-http_realip_module \>--with-http_addition_module \>--with-http_dav_module \>--with-http_flv_module \>--with-http_mp4_module \>--with-http_gzip_static_module \>--with-http_perl_module \>--with-mail \>--with_main_ssl_module[root@centos6 nginx-1.4.0]# make && make install
Nginx Web伺服器軟體安裝完成後,程式主目錄位於/usr/local/nginx/,該目錄下的內容分別為cong、html、logs、sbin。下面是Nginx常用的進程管理指令:
[root@centos6 ~]# /usr/local/nginx/sbin/nginx #啟動主程式[root@centos6 ~]# /usr/local/nginx/sbin/nginx -c \ #指定設定檔啟動主程式[root@centos6 ~]# /usr/local/nginx/sbin/nginx -s stop #關閉主程式[root@centos6 ~]# /usr/local/nginx/sbin/nginx -s reload #重新載入設定
設定檔解析
Nginx預設的設定檔為/usr/local/nginx/conf/nginx.conf,設定檔包括全域、event、http、server設定,event主要用來定義Nginx工作模式,http提供Web功能,server用來設定虛擬機器主機,server必須位於http內部,一個設定檔中可以有多個server。
本文原創地址:http://www.linuxprobe.com/nginx-installation-parsing
免費提供最新Linux技術教程書籍,為開源技術愛好者努力做得更多更好:http://www.linuxprobe.com/
以上就介紹了Nginx安裝與設定檔解析,包括了nginx,設定檔方面的內容,希望對PHP教程有興趣的朋友有所協助。