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

 

 

 


你可能感兴趣的:(wordpress,discuz应用)