一.利用rpm包搭建Lamp环境

安装过程

1. 安装apche服务
yum install httpd –y
2.安装mysql数据库
yum install mysql mysql-server –y
3.安装php服务
yum install php php-mysql php-mbstring –y
启动apache服务和mysql数据库
service httpd start
service mysqld start
开机引导
chkconfig httpd on
chkconfig mysqld on
测试
1.测试通过apche调用php
 cd /var/www/html
 vim index.php //注意这里的扩展名为php
文件内容:
 <?php phpinfo(); ?>
网页显示:
2.测试通过php调用mysql
 vim index.php 
文件内容:
 <?php $link=mysql_connect(‘127.0.0.1’,‘root’,‘’); //因为没创建密码,所以为空
if ($link) echo “ok”; else echo “no”; ?>
网页显示:
二.利用phpwind实现论坛
1.[root@localhost ~]# unzip phpwind_GBK_8.3.zip
2.[root@localhost ~]# cd phpwind_GBK_8.3
[root@localhost phpwind_GBK_8.3]# mv upload/ /var/www/html/phpwind
这时候访问网页会出现乱码,需要改变文件
vim /etc/httpd/conf/httpd.conf
文件内容:
在命令模式下搜索 :/UTF ,然后注释746行内容
746 #AddDefaultCharset UTF-8
3.[root@localhost ~]# service httpd restart
 
安装phpwind论坛
 
1.修改文件权限
[root@localhost ~]# cd /var/www/html/phpwind/
[root@localhost phpwind]# chmod -R 777 p_w_upload/
[root@localhost phpwind]# chmod -R 777 data/
[root@localhost phpwind]# chmod -R 777 html/
2.创建数据库并设置密码
mysql> create database phpwind;
[root@localhost phpwind]# mysqladmin -u root -p password '123'
Enter password:      //旧密码为空
3.安装phpwind论坛
4.删除文件
[root@localhost phpwind]# rm install.php
5.安装完成,打开网页
6.虚拟主机
vim /etc/httpd/conf/httpd.conf
文件内容:
<VirtualHost 192.168.2.100:80>
    ServerAdmin master@sina.com
    DocumentRoot /var/www/html/phpwind
    ServerName bbs.abc.com
    ErrorLog logs/phpwind-error_log
    CustomLog logs/phpwind-access_log common
</VirtualHost>
利用新域名访问论坛
 
四.利用wordpress实现论坛
1.[root@localhost ~]# unzip wordpress_v3.0.5-zh_CN.zip
[root@localhost ~]# cd wordpress-3.0.5-zh_CN/
[root@localhost wordpress-3.0.5-zh_CN]# mv wordpress/ /var/www/html/
[root@localhost ~]# cd /var/www/html/ wordpress/
[root@localhost wordpress]# cp wp-config-sample.php wp-config.php
[root@localhost wordpress]# chown apache.apache wp-config.php
2.创建数据库
root@localhost ~]# mysql -u root –p
mysql> create database wordpress;
[root@localhost html]# cd wordpress/
[root@localhost wordpress]# vim wp-config.php
文件内容:
19 define('DB_NAME', 'wordpress');
22 define('DB_USER', 'root');
25 define('DB_PASSWORD', '123');
3.访问页面:
 
4.修改主题
[root@localhost wordpress]# ll wp-content/
-rw-r--r-- 1 root root   30 2011-02-08 index.php
drwxr-xr-x 2 root root 4096 2011-02-08 languages
drwxr-xr-x 3 root root 4096 2011-02-08 plugins
drwxr-xr-x 3 root root 4096 2011-02-08 themes
[root@localhost wordpress]# chmod o+w wp-content/
[root@localhost wordpress]# cd wp-content/themes
[root@localhost themes]# cp ../uploads/Stratex.zip ./
[root@localhost themes]# unzip Stratex.zip
网页安装主题:
安装成功,选择主题
5.Phpwind论坛和wordpress论坛通过虚拟主机实现访问
vim /etc/httpd/conf/httpd.conf
文件内容需要修改的内容:
Alias /wordpress/ "/var/www/html/wordpress/"
 
<Directory "/var/www/html/wordpress">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
Alias /wordpress/ "/var/www/html/phpwind/"
 
<Directory "/var/www/html/phpwind">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
 
NameVirtualHost 192.168.2.100:80
 
<VirtualHost 192.168.2.100:80>
    ServerAdmin master@sina.com
    DocumentRoot /var/www/html
    ServerName www.abc.com
    ErrorLog logs/error_log
    CustomLog logs/access_log common
</VirtualHost>
<VirtualHost 192.168.2.100:80>
    ServerAdmin master@sina.com
    DocumentRoot /var/www/html/phpwind
    ServerName bbs.abc.com
    ErrorLog logs/phpwind-error_log
    CustomLog logs/phpwind-access_log common
</VirtualHost>
<VirtualHost 192.168.2.100:80>
    ServerAdmin master@sina.com
    DocumentRoot /var/www/html/wordpress
    ServerName bbs.qq.com
    ErrorLog logs/wp-error_log
    CustomLog logs/wp-access_log common
</VirtualHost>
6.客户端改变host文件,加入:
192.168.2.100   www.abc.com
192.168.2.100   bbs.abc.com
192.168.2.100   bbs.qq.com
7.通过网页分别访问两个论坛
访问phpwind论坛
访问wordpress论坛