1. 程式人生 > >Linux系統下LNMP架構搭建

Linux系統下LNMP架構搭建

一、防火牆狀態:

1、檢視防火牆狀態:

systemctl status firewalld

service iptables status

firewall-cmd --state

2、永久有效開啟或關閉防火牆:

開啟防火牆 -- chkconfig iptables on

關閉防火牆 -- chkconfig iptables off

        systemctl disabled firewalld

3、暫時開啟或關閉防火牆:

開啟防火牆 -- service iptables start

關閉防火牆 -- service iptables stop

       systemctl stop firewalld

4、重啟防火牆

systemctl enabled firewalld

service iptables restart

二、SElinux

  selinux是linux下的一個安全機制,在部署的時候會提示,運維人員都喜歡將其關掉。將配置檔案/etc/selinux/config的SELINUX=enforcing改成SELINUX=disabled。但是修改後的disabled要在重啟後才能生效,工作時候的機器是不能隨便重啟的。使用getenforce檢視變數。變數並沒有變化,用setenforce 0操作變成Permissive,Permissive只是一個在部署時候出現的警告,也算是避免了selinux的安全機制。在重啟後selinux會改變成disabled。

 

 

 

LNMP架構:

1、使用 rz 工具將軟體包上傳。

 

 

 

 2、安裝 Nginx 服務

yum install -y gcc gcc-c++ make

 

----------------------------------------------------------------------------------------

 rpm是RPM軟體包的管理工具:

-a   查詢所有套件

-l    顯示套件的檔案列表

-i    顯示套件的相關資訊

-c   只列出組態配置檔案,配合 -l 引數使用

-s   顯示檔案狀態,配合 -l 引數使用

-R   顯示套件的關聯性資訊

-q    使用詢問模式,當遇到任何問題時,rpm指令會先詢問使用者。

-----------------------------------------------------------------------------------------

 

 yum install -y pcre-devel zlib-devel openssl-devel

 

 3、對Nginx進行編譯安裝:

  檢測系統是否有安裝 Apache 服務,如果有安裝則先解除安裝Apache:

rpm -aq httpd

建立 Nginx 程式使用者後對 Nginx 進行編譯安裝:

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio  --with-http_mp4_module --with-http_ssl_module && make && make install

修改 Nginx 配置檔案:

改成自己的主機名:

 

建立軟連線:

ln -s /usr/local/nginx/sbin/* /usr/local/sbin

修改系統最大開啟檔案數:

 

 配置檔案語法檢測:

 

4、啟動Nginx服務,並設定為開機自啟動:

 

 5、測試 Nginx 訪問情況:

&n