1.环境说明与准备
[root@localhost ~]# yum list | egrep -i "(httpd|mysql|php)" | grep ‘installed‘ This system is not registered with RHN. RHN support will be disabled. httpd.i386 2.2.3-11.el5 installed mysql.i386 5.0.22-2.1.0.1 installed mysql-server.i386 5.0.22-2.1.0.1 installed perl-DBD-MySQL.i386 3.0007-1.fc6 installed php.i386 5.1.6-15.el5 installed php-cli.i386 5.1.6-15.el5 installed php-common.i386 5.1.6-15.el5 installed php-mysql.i386 5.1.6-15.el5 installed php-pdo.i386 5.1.6-15.el5 installed [root@localhost ~]# 说明: 第一,Apache+MySQL+PHP全部采用YUM源安装完成,可以挂载安装ISO光盘,做成YUM源。 我的YUM配置文件如下供大家参考。 [root@localhost ~]# cat /etc/yum.repos.d/mytest1.repo [mytest1] name=myyumtest1 baseurl=file:///home/yum/cdrom/Server enabled=1 gpgcheck=0 [root@localhost ~]# 第二,关于APACHE的配置。 关于Apache httpd的详细分析,可以参考我的博客: http://zhangfengzhe.blog.51cto.com/8855103/1545425 这里需要说明的是,我将采用的是基于servername的虚拟主机方式进行试验。配置如下: [root@localhost ~]# cat /etc/httpd/conf.d/myhttpd.conf NameVirtualHost 192.168.204.88:80 <VirtualHost 192.168.204.88:80> DocumentRoot /web/v1/ ServerName www.zfz1.com ErrorLog logs/www.zfz1.com-error_log CustomLog logs/www.zfz1.com-access_log common </VirtualHost> <VirtualHost 192.168.204.88:80> DocumentRoot /web/v2/ ServerName www.zfz2.com ErrorLog logs/www.zfz2.com-error_log CustomLog logs/www.zfz2.com-access_log common </VirtualHost> [root@localhost ~]# 当然,大家需要在客户端配置好hosts,把SERVERNAME和IP的关系配好。 第三,关于MYSQL的配置。 关于MYSQL的安装及入门使用,可以参考我的博客: http://zhangfengzhe.blog.51cto.com/8855103/1547611 需要注意的是用户的访问授权: mysql> show grants for ‘root‘@‘%‘; +--------------------------------------------------------------------------------------------------------------------------------+ | Grants for root@% | +--------------------------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY PASSWORD ‘*A488BC0454FA2FD261762BD37034100FFF0B0510‘ WITH GRANT OPTION | +--------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> 第四,由于PHP需要访问MYSQL,因此需要安装php-mysql包。就如同JDBC中访问ORACLE,MYSQL等 数据库时需要提供驱动JAR一样。 |
2.Test LAMP
完成了第一步的LAMP平台搭建后,我们应该对LAMP进行测试,以确保他们可以协同工作。 第一步,启动httpd,mysql. [root@localhost ~]# service httpd start Starting httpd: [ OK ] [root@localhost ~]# service mysqld start Starting MySQL: [ OK ] [root@localhost ~]# [root@localhost ~]# netstat -tnlp | egrep ‘(80|3306)‘ tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3686/mysqld tcp 0 0 :::80 :::* LISTEN 3566/httpd [root@localhost ~]# 可以发现,HTTPD,MYSQL已经正常启动并且在指定端口处进行了监听。 第二步,测试HTTPD与PHP. [root@localhost v2]# cd /web/v2 [root@localhost v2]# cat test.php <?php phpinfo(); ?> [root@localhost v2]# 进行测试访问如下: 说明APACHE已经可以和PHP进行交互。 第三步,测试APACHE,MYSQL,PHP. [root@localhost v2]# pwd /web/v2 [root@localhost v2]# cat index.php <?php #Phpinfo(); $con=mysql_connect(‘192.168.204.88‘,‘root‘,‘zhangfengzhe‘); if (!$con) { echo "can not connect to mysql"; } mysql_select_db("mydb1", $con); $result = mysql_query("SELECT * FROM users"); ?> <table border=‘1‘> <?php while($row = mysql_fetch_array($result)) { echo "<tr><td>",$row[‘id‘],"</td><td>",$row[‘name‘],"</td></tr>"; } mysql_close($con); ?> </table> [root@localhost v2]# 测试访问结果如下: 查看MYSQL数据库: mysql> use mydb1; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +-----------------+ | Tables_in_mydb1 | +-----------------+ | users | +-----------------+ 1 row in set (0.00 sec) mysql> select * from users; +------+----------+------+----------+ | id | name | Sex | birthday | +------+----------+------+----------+ | 001 | zhangsan | NULL | NULL | | 002 | lisi | NULL | NULL | +------+----------+------+----------+ 2 rows in set (0.00 sec) mysql> 到现在,LAMP的测试工作就完成了,他们已经可以协同工作了。 |
3.安装部署discuz
进入www.discuz.net 下载ZIP,可以选择UTF-8版本的。
将下载的ZIP包上传至LINUX服务器,解压后,将upload目录下的所有文件COPY至/web/v1下,然后访问www.zfz1.com/install 进行安装。
在安装过程中,需要改变有关目录的权限,根据提示逐项修改即可。
指定好数据库连接的相关信息。实际上,这一步将会完成数据库相关表的创建。
安装完成后,就可以访问前台:
后台:
查看MYSQL相关信息:
mysql> use luntan; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +-----------------------------------+ | Tables_in_luntan | +-----------------------------------+ | pre_common_admincp_cmenu | | pre_common_admincp_group | | pre_common_admincp_member | | pre_common_admincp_perm | | pre_common_admincp_session | | pre_common_admingroup | | pre_common_adminnote | | pre_common_advertisement | | pre_common_advertisement_custom | | pre_common_banned |
至此,我们的LAMP不仅搭建完毕,而且还部署了一个论坛应用,就这么简单~
本文出自 “我想超越自我” 博客,请务必保留此出处http://zhangfengzhe.blog.51cto.com/8855103/1549533