http服务配置/LAMP网站平台/PHP应用部署(Discuz!论坛系统
admin
2023-06-23 20:42:17
0次

实验拓扑:

        RHEL6.5_1

-----CentOS6.5(vmnet1)----------(vmnet1)

       RHEL6.5_2


实验一:查看默认HTTP配置

安装httpd、httpd-manual软件包

启动httpd服务

从浏览器访问默认首页、手册页

找到默认红帽欢迎页面


1.安装软件包

[root@svr5 ~]# rpm -q httpd 

[root@svr5 ~]# yum -y install httpd 

2.启动服务

[root@svr5 ~]# service httpd restart

[root@svr5 ~]# chkconfig httpd on

[root@svr5 ~]# netstat -tulnp | grep httpd

3.测试

在真实机直接访问

http://192.168.4.5

4.新建测试主页

[root@svr5 ~]# cat /var/www/html/index.html

Test Page!!!

5.测试

在真实机直接访问

http://192.168.4.5

6.上传模版网站

//把FTP服务器上的test_web.zip上传到192.168.4.5:/root上,方法随便

[root@svr5 ~]# yum -y install unzip

[root@svr5 ~]# unzip -d /var/www/html/ /root/test_web.zip 

[root@svr5 ~]# ls /var/www/html/

在真实机直接访问

http://192.168.4.5/muban1

http://192.168.4.5/muban2

...


试验二:基本HTTP服务器的配置

Web服务器域名:svr5.tarena.com

默认首页包括:index.php、index.html

迁移网站根目录到/var/ftp

1.修改主配置文件

[root@svr5 ~]# cd /etc/httpd/conf

[root@svr5 conf]# cp httpd.conf httpd.conf.bak

[root@svr5 conf]# vim httpd.conf

...

276 ServerName svr5.tarena.com:80     //设置网站名称

...

292 #DocumentRoot "/var/www/html"      //注销网站目录

293 DocumentRoot "/var/ftp"                              //启用新网站目录

...

318 #                   //同上

319                   //同上

...

402 DirectoryIndex index.html index.php     //将index.html作为第一个查找

...

[root@svr5 ~]# mv /var/www/html/* /var/ftp/

2.启动服务

[root@svr5 ~]# service httpd restart

3.测试

在真实机直接访问

http://192.168.4.5/

http://192.168.4.5/muban1

http://192.168.4.5/muban2


实验三:基于域名的虚拟主机

www.google.com192.168.4.5google网站

www.baidu.com192.168.4.5baidu网站

1.创建虚拟站点准备网页

[root@svr5 ~]# cd /var/www/html/

[root@svr5 html]# mkdir google baidu

[root@svr5 html]# cat google/index.html

GOOGLE!!!

   //站点1的首页

[root@svr5 html]# cat baidu/index.html

BAIDU!!!

    //站点2的首页

2.修改主配置文件

[root@svr5 html]# cat /etc/httpd/conf.d/vhosts.conf    //建独立配置文件

NameVirtualHost 192.168.4.5         //虚拟主机服务的监听地址

       //配置虚拟站点1

    DocumentRoot /var/www/html/google

    ServerName  www.google.com

 

                    //配置虚拟站点2

    DocumentRoot /var/www/html/baidu

    ServerName  www.baidu.com

 

[root@svr5 html]# grep ^Include /etc/httpd/conf/httpd.conf

Include conf.d/*.conf                      //确认此包含设置已开启(包含建独立配置文件)

3.启动服务

[root@svr5 ~]# service httpd restart

4.配置hosts文件,支持域名访问

[root@pc205 ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.4.5www.google.com                     //添加两个虚拟Web站点的域名与IP地址映射记录

192.168.4.5www.baidu.com

5.测试

在真实机直接访问

http://www.baidu.com/

http://www.google.com/

http://192.168.4.5/


实验四:构建LAMP网站平台

1.安装软件包

[root@svr5 ~]# rpm -q httpd mysql-server mysql php php-mysql

[root@svr5 ~]# yum -y install mysql-server mysql php php-mysql

2.配置MySQL

[root@svr5 ~]# service mysqld restart

[root@svr5 ~]# chkconfig mysqld on

[root@svr5 ~]# mysqladmin -u root password 'Taren1'

3.配置PHP

[root@svr5 ~]# vim  /etc/php.ini

.. ..

default_charset = "utf-8" //设置默认字符集

file_uploads = On //允许从PHP网页上传文件

upload_max_filesize = 2M //允许上传的文件大小

post_max_size = 8M //每次POST提交的数据限制

4.配置Httpd

[root@svr5 ~]# vim /etc/httpd/conf/httpd.conf

...

      DocumentRoot "/var/www/html"

     #DocumentRoot "/var/ftp"

...

     

    #

     DirectoryIndex  index.php index.html 

...

[root@svr5 ~]# cat /var/www/html/test1.php

phpinfo();

?>

[root@svr5 ~]# cat /var/www/html/test2.php

    $link=mysql_connect('localhost','root','Taren1');

    if($link) echo "Success !!";         //成功则显示Success !!

    else echo "Failure !!";             //失败则显示Failure !!

    mysql_close();                       //关闭数据库连接

?>

5.启动服务

[root@svr5 ~]# service httpd restart

6.测试

[root@pc205 ~]# firefox http://192.168.4.5/test1.php

[root@pc205 ~]# firefox http://192.168.4.5/test2.php


实验五:PHP应用部署(Discuz!论坛系统)


1.建论坛库

[root@svr5 ~]# mysql -uroot -p

Enter password:  //验证管理密码

mysql> create database bbsdb;//创建bbsdb数据库

mysql> show databases;//查看数据库

mysql> grant all on bbsdb.* to runbbs@localhost identified by 'pwd123';//授权数据库

mysql> quit

2.部署论坛网页代码

[root@svr5 ~]# unzip Discuz_X3.2_SC_UTF8.zip -d tdir

[root@svr5 ~]# ls -F tdir/

[root@svr5 ~]# cp -rf tdir/upload/ /var/www/html/bbs

[root@svr5 ~]# cd /var/www/html/bbs/

[root@svr5 bbs]# chown -R apache template/ config/ data/ uc_client/ uc_server/

3.安装论坛系统

[root@pc205 ~]# firefox http://192.168.4.5/bbs/install

4.访问论坛前台首页  http://192.168.4.5/bbs/

测试用户注册、发帖、回帖等论坛操作




相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...