搭建nginx網站(-)
本實驗安裝環境redhat6.5
1.安裝前準備:
1)確保安裝pcre-devel,zlib-devel
pcre-devel,zlib-devel包 在redhat6.5中可安裝
2)創建運行的用戶
2.編譯安裝:
./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre --with-zlib=/usr/local/zlib --with-http_stub_status_module --with-http_gzip_static_module --with-file-aio --with-http_ssl_module --user=nginx
make
make install
--prefix 指定安裝路徑
--user 指定運行的用戶
--with-http_stub_status_module 啓用狀態統計
--with-http_gzip_static_module 啓用gzip靜態壓縮
--with-http_ssl_module 啓用SSL模塊
--with-http_flv_module 啓用flv模塊
--with-file-aio 啓用文件修改支持
注:幫助:./configure --help
確定nginx編譯安裝成功
ls /usr/local/nginx
3.創建軟連接並確認成功
4.nginx的運行控制
1)檢查配置文件是否正確(當我們修改了配置文件的時候去檢查,首次安裝去檢查一定會是正確的,因爲我們並沒有對它進行修改。)
2)啓動nginx服務並查看監聽狀態
nginx程序支持標準的進程信號,
3)重啓nginx服務
killall -s HUP nginx
4)停止nginx服務
killall -s QUIT nginx
(-s:指定信號的種類,HUP信號:重載配置,QUIT信號:退出進程)
平穩關閉nginx,保存相關文件
nginx -s quit
5.設置防火牆入站規則
至此,我們已經搭建完了nginx。
訪問網頁驗證:
我們直接輸入網站的地址就可以了,頁面呢是nginx默認的測試頁。