CentOS 7 RPM包方式安裝LAMP

細節要求:

(1) 三者分離于兩臺主機;

(2) 一個虛擬主機用于提供phpMyAdmin;另一個虛擬主機用于提供wordpress;

(3) 提供xcache加速;

(4) 為phpMyAdmin提供https虛擬主機;

一、準備CentOS 7主機環境以及Repo倉庫提供基于rpm安裝包方式的程序包安裝源

安裝主機程序包規劃:

主機1:web-server(192.168.1.132)–安裝httpd、php、php-mysql、Xcache、phpMyAdmin、wordpress

主機2:db-server(192.168.1.200)–安裝mariadb-server

二、web-server程序軟件安裝

image.png

三、db-server程序軟件安裝

CentOS 7 RPM包方式安裝LAMPimage.png

四、具體部署配置

安裝完成以后執行各個服務配置。

a、httpd服務配置,創建虛擬主機,指定根文件路徑等

  phpMyAdmin虛擬主機名:pma.test.com,資源路徑/usr/share/phpMyAdmin/

  wordpress虛擬主機主機名:wordpress.test.com,資源路徑/usr/share/wordpress/

查看當前httpd使用的MPM模型

#cat /etc/httpd/conf.modules.d/00-mpm.conf

CentOS 7 RPM包方式安裝LAMPimage.png

#httpd -M

CentOS 7 RPM包方式安裝LAMPimage.png

默認使用prefork模式;

查看裝載PHP裝載的模塊

#cat /etc/httpd/conf.modules.d/10-php.conf

CentOS 7 RPM包方式安裝LAMPimage.png

#httpd -M

CentOS 7 RPM包方式安裝LAMPimage.png

已裝載libphp5.so;

啟動httpd服務進程并添加到開機自動啟動服務進程中

CentOS 7 RPM包方式安裝LAMPimage.png

查看httpd服務狀態

CentOS 7 RPM包方式安裝LAMPimage.png

創建虛擬主機配置文件

#vim /etc/httpd/conf.d/virtualhost.conf

<VirtualHost *:80>

    ServerName www.test.com      –用于測試主站點靜態資源訪問,以及php動態資源訪問

    DocumentRoot   /var/www/html     –默認的html資源路徑

</VirtualHost>

<VirtualHost *:80>

    Servername wordpress.test.com     –用于測試wordpress程序

    DocumentRoot   /usr/share/wordpress    –默認的wordpress程序資源路徑

</VirtualHost>

<VirtualHost *:443>

    Servername phpmyadmin.test.com     –用于測試phpMyAdmin程序

    DocumentRoot   /usr/share/phpMyAdmin    –默認的phpMyAdmin程序資源路徑

</VirtualHost>

b、mariadb數據庫配置

啟動mariadb服務進程,并加入開機自動啟動服務列表

CentOS 7 RPM包方式安裝LAMPimage.png

確認mariadb服務進程狀態

CentOS 7 RPM包方式安裝LAMPimage.png

禁用數據庫主機名解析

CentOS 7 RPM包方式安裝LAMP#echo 'skip_name_resolve = ON'>/etc/my.cnf

為wordpress程序設置遠程訪問數據庫參數

啟用數據庫遠程客戶端訪問,設置遠程訪問用戶名‘bdtest’,允許遠程訪問的主機‘192.168.1.0/24’網段,訪問密碼‘redhat’,允許訪問的數據庫‘test’

CentOS 7 RPM包方式安裝LAMPMariadb[(none)]>grant all privileges on test.* to bdtest@'192.168.1.%' identified by 'redhat';

開放db-server(數據庫服務器)運行遠程訪問mysql服務

CentOS 7 RPM包方式安裝LAMP#firewall-cmd –permanent –add-service=mysql

#firewall-cmd –reload

為phpMyAdmin程序設置遠程訪問數據庫參數

#mysql

Mariadb [(none)]>create database 'pma_db';

Mariadb [(none)]>grant all on pma_db.* to pmatest@'192.168.1.%' identified by 'redhat';

c、安裝PHP加速引擎xcache

#yum install php-xcache.x86_64 -y

#systemctl reload httpd.service     –重新裝載httpd配置

#通過調用phpinfo()參數顯示xcache已啟用

CentOS 7 RPM包方式安裝LAMPimage.png

d、web-server中配置wordpress程序參數

設置配置文件/etc/wordpress/wp-conf.php,修改與db-server通訊的參數

CentOS 7 RPM包方式安裝LAMPimage.png

修改wordpress資源訪問權限:/etc/httpd/conf.d/wordpress.conf

CentOS 7 RPM包方式安裝LAMPimage.png

針對httpd2.2和2.4不同版本修改原有默認的local本地訪問權限,允許all訪問,另外如果允許用戶上傳內容,也可以設置相應參數,目前保留默認設置

CentOS 7 RPM包方式安裝LAMPimage.png

通過瀏覽器訪問http://wordpress.test.com,進行首次安裝配置界面

CentOS 7 RPM包方式安裝LAMPimage.png

初始化安裝成功以后,彈出登錄界面

CentOS 7 RPM包方式安裝LAMPimage.png

輸入登錄賬戶信息以后,顯示wordpress使用界面如下

CentOS 7 RPM包方式安裝LAMPimage.png

查看后臺mariadb數據庫,顯示test數據庫新建立了如下表單信息

CentOS 7 RPM包方式安裝LAMPimage.png

以上完成wordpress軟件安裝與配置

e、配置mod_ssl協議模塊

#yum install -y mod_ssl    –安裝ssl模塊

#(umask 077;openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048)   –已web-server作為CA授權服務器,先創建本機私鑰

#openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/cacert.pem -days 365    –通過交互式界面生成請求并自簽名CA服務器證書

#touch /etc/pki/CA/{index.txt,serial}   –創建CA目錄下的文件index.txt(證書數據庫索引)以及serial(證書序列號文件)

#echo '01' > /etc/pki/CA/serial      –將剛才自簽名發布的首張服務器證書作為01標號記錄在serial文件中

#openssl req -new -key /etc/pki/CA/cakey.pem -out ./myserver.csr -days 180   –以本機作為web-server服務器向CA服務器申請簽發證書請求

#openssl ca -in ./myserver.csr -out /etc/pki/CA/certs/web-server.cert -days 180    –CA簽發web-sever服務器的證書申請,生成web-server服務器證書

#vim /etc/httpd/conf.d/ssl.conf     –修改web-server服務器證書,web-server服務器私鑰證書,CA服務器證書所在路徑的參數配置

#systemctl reload httpd.service      –重新加載httpd配置文件

f、安裝部署phpMyAdmin程序

#yum install -y phpMyAdmin

#vim /etc/httpd/conf.d/phpMyAdmin.conf    –修改PMA程序配置文件

<Directory /usr/share/phpMyAdmin/>

   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>

     # Apache 2.4

     <RequireAny>

       Require all granted

     </RequireAny>

   </IfModule>

   <IfModule !mod_authz_core.c>

     # Apache 2.2

     Order Deny,Allow

     Allow from All

   </IfModule>

</Directory>

<Directory /usr/share/phpMyAdmin/setup/>

   <IfModule mod_authz_core.c>

     # Apache 2.4

     <RequireAny>

      Require all granted

     </RequireAny>

   </IfModule>

   <IfModule !mod_authz_core.c>

     # Apache 2.2

     Order Deny,Allow

        Allow from all

   </IfModule>

</Directory>

#vim /etc/phpMyAdmin/config.inc.php       –編輯PMA配置文件,定義與mariadb數據庫相關的參數

$cfg['Servers'][$i]['host']          = '192.168.1.200'; // MySQL hostname or IP address

$cfg['Servers'][$i]['user']          = 'pmatest';          // MySQL user

$cfg['Servers'][$i]['password']      = 'redhat';          // MySQL password (only needed

                                                    // with 'config' auth_type)

測試訪問PMA站點

CentOS 7 RPM包方式安裝LAMPimage.png

輸入訪問mariadb數據的用戶名,密碼(config.inc.php配置腳本中填寫的賬戶信息貌似沒有效果),提交后顯示相應的數據庫信息

CentOS 7 RPM包方式安裝LAMPimage.png

以上是基于RPM包安裝方式執行的LAMP部署步驟。

原創文章,作者:N24_shishen,如若轉載,請注明出處:http://www.www58058.com/68802

(0)
N24_shishenN24_shishen
上一篇 2017-02-16 00:47
下一篇 2017-02-16 10:37

相關推薦

  • 實驗:LAMP的php模塊方式應用phpmyadm和wordpress

    實驗:LAMP的php模塊方式應用phpmyadm和wordpress 兩臺主機一臺A:httpd,php一臺B:mariadb server 1 A:yum httpd php php-mysql vim /etc/php.inidate.timezone = Asia/Shanghai vim /etc/httpd/conf/httpd.conf Dir…

    Linux干貨 2017-10-21
  • Http協議中的各種長度限制總結

    HTTP1.0的格式 request(HTTP請求消息)結構:一個請求行.部分消息頭,以及實體內容,其中的一些消息內容都是可選擇的.消息頭和實體內容之間要用空行分開. GET /index.html HTTP/1.1 //請求頭,下面都是消息頭.Accept: */*Accept-Languang:en-usConnection:keep-aliveHost…

    Linux干貨 2015-04-04
  • DNS詳解

    概述     互聯網訪問絕大多數都是基于域名的訪問,互聯網訪問的基礎是基于IP來實現的,因此,需要有一種將域名解析成IP的機制,讓用戶在利用域名訪問時,自動將域名轉換成為對應的IP,這就是DNS的功能,本章將介紹一些DNS相關的內容,具體分為:     1、DNS的基礎概念 &n…

    Linux干貨 2016-10-08
  • Linux之計劃任務

    Linux 之計劃任務    任務計劃Linux任務計劃、周期性任務執行未來的某時間點執行一次任務:atbatch:系統自行選擇空閑時間去執行此處指定的任務周期性運行某任務:cron   at任務at命令:at [option] TIME常用選項:-V 顯示版本信息:-l: 列出指定隊列中等待運行的作業;相當于atq-d: 刪除…

    Linux干貨 2016-09-11
  • The first work’s homework

    一、描述計算機的組成及其功能     計算機是由硬件系統(hardware system)和軟件系統(software system)兩部分組成的。     1.硬件系統:       根據馮諾依曼計算機體系結構模型,中…

    Linux干貨 2016-12-05

評論列表(1條)

  • luoweiro
    luoweiro 2017-02-23 07:28

    過程詳細,不過如果在大家apache的時候能稍微介紹一下不同工作模式差異會更好。

欧美性久久久久