RHEL5.3-WEB-linux+apache+mysql+php搭建論壇 (全rpm包安裝)

---陳功磊 2009-6-9
說明:
主從dns服務器之前配置好了:
主dns 192.168.7.8 主機名dns01
從 dns 192.168.7.7 主機名 dns02
主從dns爲可用狀態:
dns對benet.com區的配置
[root@dns01 named]# vi benet.com.zone # 編輯正向文件
$TTL 86400
@ IN SOA dns01.benet.com. root.benet.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS dns01.benet.com. # dns服務器
@ IN NS dns02.benet.com.
dns01 IN A 192.168.7.8
dns02 IN A 192.168.7.7
apache IN A 192.168.7.2
vsftpd IN A 192.168.7.3
samba IN A 192.168.7.4
mail IN A 192.168.7.5
dhcp IN A 192.168.7.6
www IN CNAME apache
sendmail IN CNAME mail
@ IN MX 5 sendmai.benet.com.
~
"benet.com.zone" 13L, 271C
[root@dns01 named]# vi 7.168.192.rev # 配置反向文件
$TTL 86400
@ IN SOA dns01.benet.com. root.benet.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
@ IN NS dns01.benet.com.
@ IN NS dns02.benet.com.
2 IN PTR apache.benet.com.
3 IN PTR vsftpd.benet.com.
4 IN PTR samba.benet.com.
5 IN PTR sendmail.benet.com.
6 IN PTR dncp.benet.com.
7 IN PTR dns02.benet.com.
8 IN PTR dns01.benet.com.
~
"7.168.192.rev" 12L, 475C
[root@dns02 ~]# nslookup # 在從服務器上檢查服務情況
> www.benet.com # 默認從主dns解析
Server: 192.168.7.8
Address: 192.168.7.8#53
www.benet.com canonical name = apache.benet.com.
Name: apache.benet.com
Address: 192.168.7.2
> server 192.168.7.7 # 設置從從dns解析
Default server: 192.168.7.7
Address: 192.168.7.7#53
> www.benet.com
Server: 192.168.7.7
Address: 192.168.7.7#53
www.benet.com canonical name = apache.benet.com.
Name: apache.benet.com
Address: 192.168.7.2
> exit
[root@dns02 ~]#
一、Apache服務器基本設置
系統使用鏡像:Redhat.Enterprise.Linux.AS.V5.3-i386-dvd.iso
[root@ apache ~]# setup
彈出一個對話框。我們要進行的是防火牆配置,步驟如下:
選擇“Firewall Configuration”---按 “Tab”鍵切換到“Run Tool”—回車—“Security Level”選項要在“Enabled”前面按一下“Tab”鍵---“SelLinux”選項要選“Disabled”—按一下“Tab”鍵---選中“Customize”-按圖配置—“OK”—返回上一個對話框—“OK”—對話框自動關閉。配置完成。
clip_image002
clip_image004
[root@apache ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 apache www.benet.com localhost
::1 localhost6.localdomain6 localhost6
"/etc/hosts" 4L, 186C
[root@apache ~]# cat /etc/resolv.conf
nameserver 192.168.7.8
nameserver 192.168.7.7
[root@apache ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.7.255
HWADDR=00:0C:29:8C:DA:02
IPADDR=192.168.7.2
IPV6INIT=yes
IPV6_AUTOCONF=yes
NETMASK=255.255.255.0
NETWORK=192.168.7.0
ONBOOT=yes
[root@apache ~]#
Apache基本:
後臺進程:httpd
腳本:/etc/rc.d/init.d/httpd
使用端口:80(http),443(https)
所需RPM 包:httpd
配置路徑:/etc/httpd/*
默認網站存放路徑:/var/www/*
開始配置
1、安裝apache相關軟件
[root@apache Server]# ls | grep httpd
httpd-2.2.3-22.el5.i386.rpm
httpd-devel-2.2.3-22.el5.i386.rpm
httpd-manual-2.2.3-22.el5.i386.rpm
system-config-httpd-1.3.3.3-1.el5.noarch.rpm
[root@apache Server]# rpm -ivh httpd-2.2.3-22.el5.i386.rpm # 開始安裝,請按以下順序安裝所有包
[root@apache Server]# rpm -ivh apr-devel-1.2.7-11.i386.rpm
[root@apache Server]# rpm -ivh db4-devel-4.3.29-9.fc6.i386.rpm
[root@apache Server]# rpm -ivh expat-devel-1.95.8-8.2.1.i386.rpm
[root@apache Server]# rpm -ivh cyrus-sasl-devel-2.1.22-4.i386.rpm
[root@apache Server]# rpm -ivh openldap-devel-2.3.43-3.el5.i386.rpm
[root@apache Server]# rpm -ivh apr-util-devel-1.2.7-7.el5.i386.rpm
[root@apache Server]# rpm -ivh httpd-devel-2.2.3-22.el5.i386.rpm
[root@apache Server]# rpm -ivh httpd-devel-2.2.3-22.el5.i386.rpm
[root@apache Server]# rpm -ivh httpd-manual-2.2.3-22.el5.i386.rpm
[root@apache Server]# rpm -ivh libxslt-python-1.1.17-2.el5_2.2.i386.rpm
[root@apache Server]# rpm -ivh system-config-httpd-1.3.3.3-1.el5.noarch.rpm
2、啓動hpptd服務並測試
[root@apache Server]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName # 此處的提示有錯誤,不過沒有關係,稍後
[ OK ]
[root@apache Server]#
修改/etc/httpd/conf/httpd.conf文件
#ServerName www.example.com:80 # 默認註釋掉的
ServerName www.benet.com:80 # 修改後的
[root@apache Server]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@apache Server]#
測試:
使用在xp系統測試(注意xp的dns爲192.168.7.8和192.168.7.7)
clip_image006
clip_image008
3、簡單修改主頁並測試
[root@apache ~]# cd /var/www/html/
[root@apache html]# ls -l
total 0
[root@apache html]# echo hello.This is my web! > index.html # 創建index.html並添加語句
[root@apache html]# ls -l
total 8
-rw-r--r-- 1 root root 22 Jun 9 23:54 index.html
[root@apache html]#service httpd restart # 重啓服務
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
測試:
clip_image010
4、構建虛擬主機(基於域名)
修改dns服務器的配置
[root@dns01 named]# vi benet.com.zone
$TTL 86400
@ IN SOA dns01.benet.com. root.benet.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS dns01.benet.com.
@ IN NS dns02.benet.com.
dns01 IN A 192.168.7.8
dns02 IN A 192.168.7.7
apache IN A 192.168.7.2
vsftpd IN A 192.168.7.3
samba IN A 192.168.7.4
mail IN A 192.168.7.5
dhcp IN A 192.168.7.6
www IN CNAME apache
bbs IN CNAME apache # 添加的內容,其他不變
sendmail IN CNAME mail
@ IN MX 5 sendmai.benet.com.
"benet.com.zone" 23L, 493C written
[root@dns01 named]# service named restart # 重啓服務
Stopping named: [ OK ]
Starting named: [ OK ]
[root@dns01 named]# nslookup # dns解析測試
> bbs.benet.com
Server: 192.168.7.8
Address: 192.168.7.8#53
web.benet.com canonical name = apache.benet.com.
Name: apache.benet.com
Address: 192.168.7.2
> exit
[root@dns01 named]#
建立/var/www/web 目錄,用於存放web.benet.com 的網站
(默認的www.benet.com放在/arv/www/html目錄中)
[root@apache www]# mkdir bbs # 建立目錄
[root@apache www]# ls -l
total 48
drwxr-xr-x 2 root root 4096 Nov 12 2008 cgi-bin
drwxr-xr-x 3 root root 4096 Jun 9 23:33 error
drwxr-xr-x 2 root root 4096 Jun 10 00:00 html
drwxr-xr-x 3 root root 4096 Jun 9 23:33 icons
drwxr-xr-x 14 root root 4096 Jun 9 23:36 manual
drwxr-xr-x 2 root root 4096 Jun 10 00:09 bbs
[root@apache www]# echo hello.This is bbs.benet.com! > bbs/index.html # 建立測試頁面
[root@apache www]# cat bbs/index.html
hello.This is web.benet.com!
[root@apache www]# echo hello.This is www.benet.com! > html/index.html # 建立測試頁面
[root@apache www]# cat html/index.html
hello.This is www.benet.com!
[root@apache www]#
編輯/etc/httpd/conf/httpd.conf配置文件
[root@apache www]# vi /etc/httpd/conf/httpd.conf
。。。。。。。。。。。。。。。
NameVirtualHost 192.168.7.2:80 # 去除此行註釋符,並寫該爲此
。。。。。。。。。。。。。。。
#<VirtualHost *:80> # 模板
# ServerAdmin [email protected]
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
<VirtualHost 192.168.7.2:80> # 安裝模板添加www.benet.com目錄
ServerAdmin [email protected]
DocumentRoot /var/www/html # 頁面根目錄位置
ServerName www.benet.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost 192.168.7.2:80> # 安裝模板添加web.benet.com目錄
ServerAdmin [email protected]
DocumentRoot /var/www/bbs # 頁面根目錄位置
ServerName web.benet.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
"/etc/httpd/conf/httpd.conf" 1005L, 34233C written
[root@apache www]# service httpd restart # 重啓服務
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@apache www]#
測試:(在xp中測試)
(可以由於處理需要一點時間,所有web.benet.com要一點時間後才能訪問的到,而www.benet.com可以立即訪問的到,這也只是個人實驗是情況)
clip_image012
clip_image014
5、配置httpd隨機啓動
[root@apache ~]# chkconfig --level 35 httpd on
[root@apache ~]# chkconfig --list httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
[root@apache ~]#
二、MySQL安裝 1、安裝軟件包
所需軟件包(要按一下順序安裝哦)
perl-DBI-1.52-1.fc6.i386.rpm
perl-DBD-MySQL-3.0007-1.fc6.i386.rpm
mysql-5.0.22-2.1.0.1.i386.rpm
mysql-server-5.0.22-2.1.0.1.i386.rpm
mysql-devel-5.0.22-2.1.0.1.i386.rpm
[root@apache ~]# mount -t iso9660 /dev/cdrom /media/cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@apache ~]# cd /media/cdrom/Server/
[root@apache Server]# rpm -ivh perl-DBI-1.52-2.el5.i386.rpm
warning: perl-DBI-1.52-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-DBI ########################################### [100%]
[root@apache Server]# rpm -ivh mysql-5.0.45-7.el5.i386.rpm
warning: mysql-5.0.45-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:mysql ########################################### [100%]
[root@apache Server]# rpm -ivh perl-DBD-MySQL-3.0007-2.el5.i386.rpm
warning: perl-DBD-MySQL-3.0007-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-DBD-MySQL ########################################### [100%]
[root@apache Server]# rpm -ivh mysql-server-5.0.45-7.el5.i386.rpm
warning: mysql-server-5.0.45-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:mysql-server ########################################### [100%]
[root@apache Server]#
2、啓動mysql服務
[root@apache Server]# service mysql start
mysql: unrecognized service
[root@apache Server]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h apache password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[ OK ]
Starting MySQL: [ OK ]
[root@apache Server]# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
[root@apache Server]#
3、設置管理員帳號密碼並測試
[root@apache Server]# cd
[root@apache ~]# mysqladmin -u root password 123.com
[root@apache ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql&gt; exit
Bye
[root@apache ~]#
4、設置隨機啓動msysqld服務
[root@apache ~]# chkconfig --level 35 mysqld on
[root@apache ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:on 4:off 5:on 6:off
[root@apache ~]#
三、PHP安裝 安裝軟件包
所需的軟件包:
php-common-5.1.6-15.el5.i386.rpm
php-cli-5.1.6-15.el5.i386.rpm
php-5.1.6-15.el5.i386.rpm
php-pdo-5.1.6-15.el5.i386.rpm
php-mysql-5.1.6-15.el5.i386.rpm
安裝(請安裝以上順序安裝哦
[root@apache ~]# cd /media/cdrom/Server/
[root@apache Server]# rpm -ivh php-common-5.1.6-23.el5.i386.rpm
warning: php-common-5.1.6-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php-common ########################################### [100%]
[root@apache Server]# rpm -ivh php-cli-5.1.6-23.el5.i386.rpm
warning: php-cli-5.1.6-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php-cli ########################################### [100%]
[root@apache Server]# rpm -ivh php-5.1.6-23.el5.i386.rpm
warning: php-5.1.6-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php ########################################### [100%]
[root@apache Server]# rpm -ivh php-pdo-5.1.6-23.el5.i386.rpm
warning: php-pdo-5.1.6-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php-pdo ########################################### [100%]
[root@apache Server]# rpm -ivh php-mysql-5.1.6-23.el5.i386.rpm
warning: php-mysql-5.1.6-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php-mysql ########################################### [100%]
[root@apache Server]#
四、相關配置 1、編輯Apache 配置文件/etc/hpptd/conf/httpd.conf相關項
[root@apache ~]# vi /etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd" # apache根目錄,此爲默認值,可不改
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256 # 設置客戶端連接數量,可按需修改
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
Listen 80 # 設置http監聽端口好,默認爲80
ServerAdmin [email protected] # 設置管理員郵箱
ServerName www.benet.com:80 # 這種服務器主機名和端口
DocumentRoot "/var/www/html" # 這種頁面根目錄
DirectoryIndex index.html index.html.var index.php # 設置首頁文件,其他都可以不必更改了哈
保存退出
2、編輯個php頁面
[root@apache ~]# vi /var/www/html/index.php
<?php
phpinfo();
?>
"/var/www/html/index.php" [New] 3L, 20C written
[root@apache ~]# cat /var/www/html/index.php
<?php
phpinfo();
?>
[root@apache ~]#
3、重啓httpd服務
[root@apache ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@apache ~]#
4、測試php頁面
clip_image016
五、安裝bbs論壇網頁文檔
(說明:本文將bbs論壇網頁文檔打包爲iso鏡像文件然後掛載鏡像)
1、拷貝bbs論壇文件壓縮包到linu並解壓
[root@apache ~]# mount -t iso9660 /dev/cdrom /media/cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@apache ~]# cd /media/cdrom
[root@apache cdrom]# cd /media/cdrom/linux/
[root@apache linux]# ls
Discuz!_6.0.0_SC_UTF8.zip php-5.2.9.tar.gz
root@apache linux]# cp Discuz\!_6.0.0_SC_UTF8.zip /root # 複製到root目錄
[root@apache linux]# cd /root
[root@apache ~]# ls
anaconda-ks.cfg Discuz!_6.0.0_SC_UTF8.zip install.log install.log.syslog
[root@apache ~]# unzip Discuz\!_6.0.0_SC_UTF8.zip # 解壓zip文件
[root@apache ~]# ls
anaconda-ks.cfg install.log upload users_guide.htm
Discuz!_6.0.0_SC_UTF8.zip install.log.syslog usersguide utilities
[root@apache ~]# ls upload/ # 查看一下下
admin faq.php member.php rss.php
admincp.php favicon.ico memcp.php search.php
ajax.php forumdata misc.php seccode.php
announcement.php forumdisplay.php modcp.php sitemap.php
api frame.php mspace space.php
archiver images my.php stats.php
attachment.php include plugin.php tag.php
attachments index.php plugins templates
blog.php install pm.php topicadmin.php
config.inc.php install.php post.php topic.php
crossdomain.xml invite.php redirect.php trade.php
customavatars ipdata register.php viewpro.php
digest.php leftmenu.php relatekw.php viewthread.php
discuz_version.php logging.php relatethread.php wap
eccredit.php magic.php robots.txt
[root@apache ~]#
2、複製uploads 目錄裏所有文件到/var/www/html/bbs 目錄
[root@apache ~]# ls
anaconda-ks.cfg install.log upload users_guide.htm
Discuz!_6.0.0_SC_UTF8.zip install.log.syslog usersguide utilities
[root@apache ~]# cp -r upload/* /var/www/bbs
[root@apache ~]# cd /var/www
[root@apache www]# ls bbs
admin faq.php magic.php robots.txt
admincp.php favicon.ico member.php rss.php
ajax.php forumdata memcp.php search.php
announcement.php forumdisplay.php misc.php seccode.php
api frame.php modcp.php sitemap.php
archiver images mspace space.php
attachment.php include my.php stats.php
attachments index.html plugin.php tag.php
blog.php index.php plugins templates
config.inc.php install pm.php topicadmin.php
crossdomain.xml install.php post.php topic.php
customavatars invite.php redirect.php trade.php
digest.php ipdata register.php viewpro.php
discuz_version.php leftmenu.php relatekw.php viewthread.php
eccredit.php logging.php relatethread.php wap
[root@apache www]#
3、更改目錄權限及配置
[root@apache www]# chmod -R 777 /var/www/bbs/
[root@apache www]# ls -l
total 44
drwxrwxrwx 16 root root 4096 Jun 10 04:16 bbs
drwxr-xr-x 2 root root 4096 Nov 12 2008 cgi-bin
drwxr-xr-x 3 root root 4096 Jun 10 02:25 error
drwxr-xr-x 2 root root 4096 Jun 10 04:12 html
drwxr-xr-x 3 root root 4096 Jun 10 03:27 icons
drwxr-xr-x 14 root root 4096 Jun 10 02:29 manual
[root@apache www]#
[root@apache www]# vi bbs/config.inc.php # 更改對應配置
$dbhost='linuxsrv'; # 修改一下內容
$dbuser='root';
$dbpw= '123';
$dbname ='benet';
$adminemail='[email protected]';
$dbreport=0;
[root@apache www]#
4、安裝動網論壇
進入論壇安裝頁面,點擊同意安裝
clip_image018
clip_image020
點擊上圖同意後
clip_image022
上圖的當前狀態要全爲“可寫”才行,否則寫該相應文權限爲777。
然後點擊“下一步”按鈕
clip_image024
可以保持圖片設置,然後點擊“下一步”按鈕
clip_image026
在上圖中設置管理員Email地址及管理員密碼(及論壇後臺管理帳號和密碼)
然後點擊“下一步”
clip_image028
看到上圖的安裝成功提示,現在可以到論壇觀光了。
clip_image030
成功了不是嘛! ^_^.
附加:
重啓apache服務器,然後在裝個靜態htm網頁玩玩看
[root@apache ~]# mount -t iso9660 /dev/cdrom /media/cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@apache ~]# cd /media/cdrom
[root@apache cdrom]# ls
bn
[root@apache cdrom]# rm -rf /var/www/html/
[root@apache cdrom]# ls /var/www/html
ls: /var/www/html: No such file or directory
[root@apache cdrom]# mkdir /var/www/html
[root@apache cdrom]# cp -r bn/* /var/www/html
[root@apache cdrom]# ls /var/www/html
chgl index.dwt index.htm q.doc Templates
[root@apache cdrom]#
clip_image032
clip_image034
完成。好累呀!!!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章