设为首页 收藏本站
查看: 1887|回复: 0

centos7安装lamp并部署应用phpMyadmin和wordpress和Discuz个人论坛

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-9-29 08:57:07 | 显示全部楼层 |阅读模式
在centos7上安装lamp。
centos7系统光盘默认带的httpd-2.4版本

第一步:
yum安装httpd
yum install httpd

安装mod_ssl模块,使httpd支持ssl协议,
[iyunv@localhost conf.d]# yum install mod_ssl

安装完成后启动并查看:
[iyunv@localhost conf.d]# systemctl start httpd.service
[iyunv@localhost conf.d]# netstat -tunlp | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      29185/httpd         
tcp6       0      0 :::443                  :::*                    LISTEN      29185/httpd   

[iyunv@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文件:
[iyunv@localhost www]# mkdir pma
[iyunv@localhost www]# mkdir wp
[iyunv@localhost www]# mkdir dz
[iyunv@localhost wp]# echo "php ceshi " > index.html
[iyunv@localhost wp]# cd ../wp
[iyunv@localhost wp]# echo "wordpress ceshi " > index.html
[iyunv@localhost wp]# cd ../dz
[iyunv@localhost dz]# echo "discuz ceshi " > index.html
[iyunv@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

测试三个虚拟主机可以访问:
[iyunv@localhost pma]# curl http://pma.stu.com
phpmyadmin ceshi
[iyunv@localhost wp]# curl http://wp.stu.com
wordpress ceshi
[iyunv@localhost wp]# curl http://dz.stu.com
discuz ceshi


yum安装php、mariadb-server
[iyunv@localhost pma]# yum install php mariadb-server
wKiom1YIvpijwGRxAAKLzPHTFG0866.jpg

启动mariadb-server测试
[iyunv@localhost mariadb]# systemctl start mariadb.service
[iyunv@localhost mariadb]# netstat -tunlp | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      31860/mysqld        
[iyunv@localhost mariadb]#
测试mysql客户端可以正常连接mariadb数据库
[iyunv@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
[iyunv@localhost logs]# curl http://pma.stu.com/index.php
php ceshi page
[iyunv@localhost logs]# curl http://wp.stu.com/index.php
wordpress ceshi page[ro
[iyunv@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自身支持字符编码格式有限的一个程序包)
[iyunv@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模块。
[iyunv@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命令为需要登录的用户设置密码:
[iyunv@localhost pma]# htpasswd -c htpasswd lpw
New password:
Re-type new password:
Adding password for user lpw
[iyunv@localhost pma]#
注意:第一次使用htpasswd时需要使用-c选项指定创建htpasswd文件,以后往这个文件中添加用户密码就不用指定-c选项了。
[iyunv@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服务器
[iyunv@localhost pma]# systemctl restart httpd.service

为第二个虚拟主机添加wordpress论坛服务:
将解压后的wordpress放在此虚拟主机的根路径下
root@localhost wp]# ls
index.html  index.php  wordpress
[iyunv@localhost wp]#

[iyunv@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后生成三个包  readme、upload、 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





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-120250-1-1.html 上篇帖子: LNMP安装Nginx1.9.5+PHP5.5+MySQL5.6 下篇帖子: LAMP+NFS(编译php-fpm模块与apache2.4结合) wordpress
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表