centos7安裝lamp並部署應用phpMyadmin和wordpress和Discuz個人論壇

centos7上安裝lamp

centos7系統光盤默認帶的httpd-2.4版本

 

第一步

yum安裝httpd

yum install httpd

    

安裝mod_ssl模塊,使httpd支持ssl協議

[root@localhost conf.d]# yum install mod_ssl

 

安裝完成後啓動並查看:

[root@localhost conf.d]# systemctl start httpd.service 

[root@localhost conf.d]# netstat -tunlp | grep httpd

tcp6       0      0 :::80                   :::*                    LISTEN      29185/httpd         

tcp6       0      0 :::443                  :::*                    LISTEN      29185/httpd    

 

[root@localhost conf.d]# httpd -M | grep ssl

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

 ssl_module (shared)

 

httpd服務已經加載mod_ssl模塊。

 

新建三個虛擬主機:

需要首先禁用中心主機

#DocumentRoot "/var/www/html"

 

一:

<VirtualHost "*:80">

   DocumentRoot "/var/www/pma/"

   ServerName pma.stu.com

  <Directory "/">

       AllowOverride None

       # Allow open access:

       Require all granted

       DirectoryIndex index.html

  </Directory>

</VirtualHost>

 

二:

<VirtualHost "*:80">

  DocumentRoot "/var/www/wp/"

  ServerName "wp.stu.com"

  <Directory "/">

       AllowOverride None

       # Allow open access:

       Require all granted

    DirectoryIndex index.html

  </Directory>

</VirtualHost>

 

 

三:

 

<VirtualHost "*:80">

  DocumentRoot "/var/www/dz/"

  ServerName "dz.stu.com"

  <Directory "/">

       AllowOverride None

       # Allow open access:

       Require all granted

    DirectoryIndex index.html

  </Directory>

</VirtualHost>

 

 

分別創建每個虛擬主機的根目錄,並在各目錄下創建用於測試的index.html文件

[root@localhost www]# mkdir pma

[root@localhost www]# mkdir wp

[root@localhost www]# mkdir dz

[root@localhost wp]# echo "php ceshi " > index.html

[root@localhost wp]# cd ../wp

[root@localhost wp]# echo "wordpress ceshi " > index.html

[root@localhost wp]# cd ../dz

[root@localhost dz]# echo "discuz ceshi " > index.html

[root@localhost dz]# 

 

 

修改/etc/hosts文件

172.16.249.209   pma.stu.com

172.16.249.209   wp.stu.com

172.16.249.209   dz.stu.com

 

測試三個虛擬主機可以訪問

[root@localhost pma]# curl http://pma.stu.com

phpmyadmin ceshi 

[root@localhost wp]# curl http://wp.stu.com

wordpress ceshi 

[root@localhost wp]# curl http://dz.stu.com

discuz ceshi 

 

 

yum安裝phpmariadb-server

[root@localhost pma]# yum install php mariadb-server

 wKiom1YIvpijwGRxAAKLzPHTFG0866.jpg

 

啓動mariadb-server測試

[root@localhost mariadb]# systemctl start mariadb.service

[root@localhost mariadb]# netstat -tunlp | grep 3306

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      31860/mysqld        

[root@localhost mariadb]# 

測試mysql客戶端可以正常連接mariadb數據庫

[root@localhost mysql]# mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 2

Server version: 5.5.41-MariaDB MariaDB Server

 

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MariaDB [(none)]> 

 

 

測試php

[root@localhost logs]# curl http://pma.stu.com/index.php

php ceshi page

[root@localhost logs]# curl http://wp.stu.com/index.php

wordpress ceshi page[ro

[root@localhost logs]# curl http://dz.stu.com/index.php

discuz ceshi page

 

 

爲第一主機添加phpmyadmin功能

直接解壓phpMyAdmin-4.4.5-all-languages.zip到第一虛擬主機的根目錄下並設軟連接

ln -sv ./phpMyAdmin-4.4.5-all-languages.zip phpadmin

 

修改此虛擬主機的配置文件:添加以下內容:

 <Directory "/phpadmin/">

       AllowOverride None

       # Allow open access:

       Require all granted

       DirectoryIndex   index.php

  </Directory>

 

重新啓動httpd服務

第一次訪問提示提示mbstring缺少,安裝即可。(mbstring是一個支持多語言字符編碼格式的軟件包,是爲了彌補php自身支持字符編碼格式有限的一個程序包

[root@localhost logs]# yum install php-mbstring

再次重啓出現phpmyadmin的頁面

 wKioL1YIvtGyu6WgAAEVbHu9r5M117.jpg

phpmyadmin必須使用用戶和密碼登錄,因此使用mysql客戶端登錄服務器修改root的密碼即可

MariaDB [mysql]> set password for "root"@"localhost"=password("111111");

Query OK, 0 rows affected (0.03 sec)

重新登錄

 wKioL1YIvu2RF9GmAAPib_jAcJg273.jpg

 

此時phpmyadmin部署完成。

接下來爲此虛擬主機添加認證登錄機制。查看httpd服務是否安裝mod_ssl模塊。

[root@localhost setup]# httpd -M | grep ssl

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message

 ssl_module (shared)

 

因此可以直接在配置文件對/phpadmin/目錄設置中添加以下幾行,並保存配置文件。

       AuthType Basic   //基於basic模式認證

       AuthName "admim can access"  //提示認證的原因

       AuthUserFile "/var/www/pma/htpasswd"   //提供認證的證書文件

       Require user lpw   // 允許認證通過的名單

然後用htpasswd命令爲需要登錄的用戶設置密碼:

[root@localhost pma]# htpasswd -c htpasswd lpw

New password: 

Re-type new password: 

Adding password for user lpw

[root@localhost pma]# 

注意:第一次使用htpasswd時需要使用-c選項指定創建htpasswd文件,以後往這個文件中添加用戶密碼就不用指定-c選項了。

[root@localhost pma]# cat htpasswd 

lpw:$apr1$qasopCLe$jmVh9M2Vx4iBp.JDVUzN4.

並設置配置文件

 <Location "/phpadmin/">

       AllowOverride None

       # Allow open access:

       Require all denied

       DirectoryIndex   index.php

       AuthType Basic

       AuthName "admin can access"

       AuthUserFile "/etc/httpd/htpasswd"

       Require user lpw

  </Location>

注意:此處必須使用<Location></Location>來限定訪問路徑才能使用用戶認證登錄,而使用 </Directory>不能實現用戶訪問

然後重啓httpd服務器

[root@localhost pma]# systemctl restart httpd.service

 

爲第二個虛擬主機添加wordpress論壇服務

將解壓後的wordpress放在此虛擬主機的根路徑下

root@localhost wp]# ls

index.html  index.php  wordpress

[root@localhost wp]# 

 

[root@localhost wordpress]# mv wp-config-sample.php wp-config.php 

注意:修改此配置文件中內容(需要提前在數據庫服務器上創建一個數據庫並設置好密碼)

/** WordPress數據庫的名稱 */

define('DB_NAME', 'wordpress');

 

/** MySQL數據庫用戶名 */

define('DB_USER', 'root');

 

/** MySQL數據庫密碼 */

define('DB_PASSWORD', '111111');

 

/** MySQL主機 */

define('DB_HOST', 'localhost');

 

 

然後在瀏覽器中打開此站點,開始配置wordpress

wKioL1YIvyaTgzGDAAE5jWnNsx8604.jpg

wKiom1YIvx7yVJdpAACiWq8TCK8439.jpg

 

 

 

 

至此個人的wordpress站點搭建完成。

 

 

爲第三個虛擬主機添加discus論壇功能

解壓Discuz_X3.2_SC_GBK.zip後生成三個包  readmeupload、 utility

upload包移動到第三個虛擬主機的根目錄下

首次打開站點出現亂碼情況,修改httpd的主配置文件中的

     AddDefaultCharset GBK (把原來的UTF-8改爲GBK

即可開始配置Discuz個人論壇

 wKioL1YIv0bhVa6sAAOqSQ9kOgc641.jpg

discuz指定數據庫,需要先創建數據庫以及用戶和權限等信息

MariaDB [(none)]> create database discuz;

Query OK, 1 row affected (0.01 sec)

 wKioL1YIv2eDHLhpAAFwaES8lf0448.jpg

 

 

安裝步驟填寫即可完成論壇站點安裝

 wKiom1YIv3uR5Vb-AAK-43BpWd4605.jpg

 

 

 


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