LAMP是Linux, Apache, MySQL, PHP的縮寫.這篇教程將教你如何在一臺(tái)Fedora 11服務(wù)器上安裝Apache2web服務(wù)器+PHP(mod_php) +MySQL .
我已經(jīng)測(cè)試無(wú)誤,你可以放心使用。
1. 前言
在這篇教程中,我使用的主機(jī)名為server1.example.com,ip地址是www.6688.cc。這些設(shè)置可能與你想要的有所不同,所以你必須在適當(dāng)?shù)牡胤叫薷囊幌隆?br />
2 安裝MySQL5
用下列命令安裝MySQL:
yum install mysql mysql-server
然后我們?yōu)镸ySQL創(chuàng)建系統(tǒng)啟動(dòng)鏈接(這樣的話,MySQL就會(huì)隨著系統(tǒng)啟動(dòng)而啟動(dòng)),并啟動(dòng)MySQL服務(wù)器:
chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start
運(yùn)行
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword
來(lái)為root用戶設(shè)置一個(gè)密碼(否則任何人都可以訪問(wèn)你的MySQL數(shù)據(jù)庫(kù)。3 安裝Apache2
Fedora默認(rèn)有Apache2這個(gè)包,我們可以用下列命令安裝它:
yum install httpd
現(xiàn)在配置下系統(tǒng)使得Apache能夠隨著系統(tǒng)啟動(dòng)而啟動(dòng)…
chkconfig –levels 235 httpd on
… 啟動(dòng)Apache:
/etc/init.d/httpd start
現(xiàn)在打開(kāi)瀏覽器,訪問(wèn)http://www.6688.cc,你就應(yīng)該能看到Apache2的預(yù)留頁(yè)了:
在Fedora中Apache的默認(rèn)文檔路徑在/var/www/html,配置文件是/etc/httpd/conf/httpd.conf。其余的配置文件存儲(chǔ)在/etc/httpd/conf.d/。4 安裝PHP5
我們用下列命令安裝PHP5和Apache PHP5模塊:
yum install php
然后我們啟動(dòng)下Apache:
/etc/init.d/httpd restart
5 測(cè)試PHP5/獲取PHP5安裝后的詳細(xì)信息
網(wǎng)站的默認(rèn)文檔路徑是/var/www/html。我們現(xiàn)在在這個(gè)文件夾中創(chuàng)建一個(gè)小型PHP(info.php)文件,并在;瀏覽器中訪問(wèn)它。這個(gè)文件會(huì)顯示關(guān)于PHP安裝的大量的細(xì)節(jié),例如PHP的版本。
vi /var/www/html/info.php
<?php
phpinfo();
?>
現(xiàn)在我們?cè)跒g覽器中訪問(wèn)這個(gè)文件(例如http://www.6688.cc/info.php):
正如你所看到的一樣,PHP5已經(jīng)正常工作了,并且在Server API這一行中顯示的Apache是以Apache2.0 Handler模式工作的。如果你向下翻頁(yè),你將會(huì)看到已經(jīng)安裝了PHP5的所有的模塊。MySQL沒(méi)有在這里列出來(lái),也就意味著目前PHP5并不支持MySQL。6 讓PHP5支持MySQL
我們安裝php-mysql這個(gè)包既可以使MySQL支持php了。在這里最好也安裝其他的PHP5模塊,這些模塊也許你會(huì)在其他的應(yīng)用中用到。你可以使用下列明星先搜索一下PHP5的模塊:
yum search php
選取你需要的模塊,并使用下列命令安裝它們:
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mapserver php-mbstring php-mcrypt php-mhash php-mssql php-shout php-snmp php-soap php-tidy
現(xiàn)在重啟Apache2:
/etc/init.d/httpd restart
現(xiàn)在在瀏覽器中刷新http://www.6688.cc/info.php,并再次翻到模塊部分。你就應(yīng)該能在這里找到很多新模塊,其中就包括了MySQL模塊:7 phpMyAdmin
phpMyAdmin是一款可以web化管理MySQL數(shù)據(jù)庫(kù)的工具:
可以使用下列命令安裝phpmyadmin:
yum install phpmyadmin
現(xiàn)在我們配置phpMyAdmin。我們改變Apache的配置文件讓其只能通過(guò)本地訪問(wèn)(通過(guò)注銷<Directory /usr/share/phpMyAdmin/參數(shù)):
vi /etc/httpd/conf.d/phpMyAdmin.conf
# phpMyAdmin – Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
#<Directory /usr/share/phpMyAdmin />
# order deny,allow
# deny from all
# allow from 127.0.0.1
# allow from ::1
#</Directory>
# This directory does not require access over HTTP – taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc. This may break your mod_security implementation.
#
#<IfModule mod_security.c>
# <Directory /usr/share/phpMyAdmin>
# SecRuleInheritance Off
# </Directory>
#</IfModule>
重啟Apache:
/etc/init.d/httpd restart
然后,你就可以通過(guò)http://www.6688.cc/phpmyadmin/:訪問(wèn)phpMyAdmin了 :
億恩科技地址(ADD):鄭州市黃河路129號(hào)天一大廈608室 郵編(ZIP):450008 傳真(FAX):0371-60123888
聯(lián)系:億恩小凡
QQ:89317007
電話:0371-63322206 本文出自:億恩科技【www.riomediacenter.com】
服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|