CentOS 5.5使用yum來安裝LAMP並安裝phpMyAdmin

使用yum來安裝LAMP

1. 換源。 

1.1備份CentOS-Base.repo 
cd /etc/yum.repos.d/ 
cp CentOS-Base.repo CentOS-Base.repo.bak 
1.2替換源 
用vi打開CentOS-Base.repo,並將內容清空,而後將下面的內容複製進去,並保存。 
# CentOS-Base.repo 

# This file uses a new mirrorlist system developed by Lance Davis for CentOS. 
# The mirror system uses the connecting IP address of the client and the 
# update status of each mirror to pick mirrors that are updated to and 
# geographically close to the client. You should use this for CentOS updates 
# unless you are manually picking other mirrors. 

# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead. 


[base] 
name=CentOS-$releasever - Base 
baseurl=http://mirrors.sohu.com/centos/$releasever/os/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
#released updates 
[updates] 
name=CentOS-$releasever - Updates 
baseurl=http://mirrors.sohu.com/centos/$releasever/updates/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
#packages used/produced in the build but not released 
[addons] 
name=CentOS-$releasever - Addons 
baseurl=http://mirrors.sohu.com/centos/$releasever/addons/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
#additional packages that may be useful 
[extras] 
name=CentOS-$releasever - Extras 
baseurl=http://mirrors.sohu.com/centos/$releasever/extras/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
#additional packages that extend functionality of existing packages 
[centosplus] 
name=CentOS-$releasever - Plus 
baseurl=http://mirrors.sohu.com/centos/$releasever/centosplus/$basearch/ 
gpgcheck=1 
enabled=0 
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5 
1.3更新一下。 
yum -y update 

2. 用yum安裝Apache,Mysql,PHP. 

2.1安裝Apache 
yum install httpd httpd-devel 
安裝完成後,用/etc/init.d/httpd start 啓動apache 
設爲開機啓動:chkconfig httpd on 
2.2 安裝mysql 
2.2.1 yum install mysql mysql-server mysql-devel 
一樣,完成後,用/etc/init.d/mysqld start 啓動mysql 
2.2.2 設置mysql密碼  
mysqladmin -u root password "密碼"
2.2.3 容許遠程登陸 
mysql -u root -p 
Enter Password: <your new password> 
mysql>GRANT ALL PRIVILEGES ON *.* TO '用戶名'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION; 
完成後就能用mysql-front遠程管理mysql了。 
2.2.4 設爲開機啓動 
chkconfig mysqld on 

3. 安裝php 

yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml 
/etc/init.d/httpd start 

4. 測試一下 

4.1在/var/www/html/新建個test.php文件,將如下內容寫入,而後保存。 
<? 
phpinfo(); 
?> 
4.2 防火牆配置 
a.添加.容許訪問端口{21: ftp, 80: http}.
修改防火牆配置文件: 
vi /etc/sysconfig/iptables 
增長下面兩行: 

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT 
 
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
b.關閉防火牆. 
service iptables stop 
c.重置加載防火牆 
service iptables restart 
4.3而後在客戶端瀏覽器裏打開http://serverip/test.php,若能成功顯示,則表示安裝成功。

安裝phpMyAdmin

具體參看:http://faq.comsenz.com/viewnews-484
這裏幾個地方須要注意:
1.  phpMyAdmin包下載過來解壓以後, libraries 目錄下的config.default.php配置文件,修改過以後,須要複製到上一級目錄,並改名爲config.inc.php。一開始就是一直改 config.default.php,發現無效,後來才發現真正起效果的是config.inc.php這個文件,因此配置應該在這個文件裏面改。
2.修改完配置文件以後,講整個 phpMyAdmin文件夾上傳到 web能夠訪問的目錄下,好比/var/www/html/ 文件夾下~
相關文章
相關標籤/搜索