今天用yum方法搭建起了個LAMP環境,中間遇到了很多問題,經過google和各位前輩的幫助,終於將環境搭建起來,現在把完整的步驟記錄下來,
1. 換源,sohu的相當好用。
1.1備份CentOS-Base.repo
cd /etc/yum.repos.d/
cp CentOS-Base.repo CentOS-Base.repo.bak
1.2取代來源
用vi開啟CentOS清空,然後將下面的內容複製進去,並儲存。
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system mirs the connecting IP address of the client and the that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# mom not fat then uncan at unywor s fow at not unwor nots 4002 月, not not n not n not 40000 y fem not le0 em notn 20002 月。 try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.hurel.com/cents/$hurelease] /
gpgcheck=1
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]httpdmmmmoname=cmwmmlmmoname=dprelease ://mirrors.sohu.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-51
#
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://mirrors.sohu.com/centos/$release/addons/$basearch/addons/$ gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Exbasesurl:com /mirrors.sohu.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
.com/centos/RPM-GPG-KEY-CentOS-5 extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.sohu.com/centos/$releasever/centosplus/$basearch/ 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 :chkconfig httpd on
2.2 安裝mysql
2.2.1 yum install mysql mysql-server mysql-devel
同樣,完成後,用/etc/init.d/mysqld start 啟動mysql USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql>; FLUSH PRIVILEGES;
2.2.3 允許遠端登入完碼
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-mysql php-common php-gd php-mbstring php-mcrypt php-mysql php-xmlin. httpd restart
4. 測試
4.1在/var/www/html/新建個test.php文件,將以下內容寫入,然後儲存。
phpinfo();
?>
4.2 防火牆配置
a.新增.允許存取連接埠{21: ftp, 80: http}.
iptables -I RH-Firewall-1-INNUT -m -m tcp -p tcp –dport 21 -j ACCEPT
iptables -I 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,若能成功顯示,則表示安裝成功。
至此,安裝完畢。感慨,yum真是太好用了。
以上就介紹了 CentOS 55使用yum來安裝LAMPphp運行環境,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。