一.利用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 attachment/
[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 [email protected]
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 [email protected]
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 [email protected]
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 [email protected]
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論壇