CentOS 5.5使用yum來(lái)安裝LAMP(php運(yùn)行環(huán)境)
更新時(shí)間:2010年09月10日 21:05:37 作者:
今天用yum方法搭建起了個(gè)LAMP環(huán)境,中間遇到了很多問(wèn)題,經(jīng)過(guò)google和各位前輩的幫助,終于將環(huán)境搭建起來(lái),現(xiàn)在把完整的步驟記錄下來(lái),
1. 換源,sohu的相當(dāng)好用。
1.1備份CentOS-Base.repo
cd /etc/yum.repos.d/
cp CentOS-Base.repo CentOS-Base.repo.bak
1.2替換源
用vi打開(kāi)CentOS-Base.repo,并將內(nèi)容清空,然后將下面的內(nèi)容復(fù)制進(jìn)去,并保存。
# 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 啟動(dòng)apache
設(shè)為開(kāi)機(jī)啟動(dòng):chkconfig httpd on
2.2 安裝mysql
2.2.1 yum install mysql mysql-server mysql-devel
同樣,完成后,用/etc/init.d/mysqld start 啟動(dòng)mysql
2.2.2 設(shè)置mysql密碼
mysql>; USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql>; FLUSH PRIVILEGES;
2.2.3 允許遠(yuǎn)程登錄
mysql -u root -p
Enter Password: <your new password>
mysql>GRANT ALL PRIVILEGES ON *.* TO '用戶名'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;
完成后就能用mysql-front遠(yuǎn)程管理mysql了。
2.2.4 設(shè)為開(kāi)機(jī)啟動(dòng)
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. 測(cè)試一下
4.1在/var/www/html/新建個(gè)test.php文件,將以下內(nèi)容寫(xiě)入,然后保存。
<?
phpinfo();
?>
4.2 防火墻配置
a.添加.允許訪問(wèn)端口{21: ftp, 80: http}.
iptables -I RH-Firewall-1-INPUT -m state –state NEW -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.關(guān)閉防火墻{不推薦}.
service iptables stop
c.重置加載防火墻
service iptables restart
4.3然后在客戶端瀏覽器里打開(kāi)http://serverip/test.php,若能成功顯示,則表示安裝成功。
至此,安裝完畢。感慨,yum真是太好用了。
1.1備份CentOS-Base.repo
cd /etc/yum.repos.d/
cp CentOS-Base.repo CentOS-Base.repo.bak
1.2替換源
用vi打開(kāi)CentOS-Base.repo,并將內(nèi)容清空,然后將下面的內(nèi)容復(fù)制進(jìn)去,并保存。
# 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 啟動(dòng)apache
設(shè)為開(kāi)機(jī)啟動(dòng):chkconfig httpd on
2.2 安裝mysql
2.2.1 yum install mysql mysql-server mysql-devel
同樣,完成后,用/etc/init.d/mysqld start 啟動(dòng)mysql
2.2.2 設(shè)置mysql密碼
mysql>; USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql>; FLUSH PRIVILEGES;
2.2.3 允許遠(yuǎn)程登錄
mysql -u root -p
Enter Password: <your new password>
mysql>GRANT ALL PRIVILEGES ON *.* TO '用戶名'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;
完成后就能用mysql-front遠(yuǎn)程管理mysql了。
2.2.4 設(shè)為開(kāi)機(jī)啟動(dòng)
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. 測(cè)試一下
4.1在/var/www/html/新建個(gè)test.php文件,將以下內(nèi)容寫(xiě)入,然后保存。
<?
phpinfo();
?>
4.2 防火墻配置
a.添加.允許訪問(wèn)端口{21: ftp, 80: http}.
iptables -I RH-Firewall-1-INPUT -m state –state NEW -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.關(guān)閉防火墻{不推薦}.
service iptables stop
c.重置加載防火墻
service iptables restart
4.3然后在客戶端瀏覽器里打開(kāi)http://serverip/test.php,若能成功顯示,則表示安裝成功。
至此,安裝完畢。感慨,yum真是太好用了。
您可能感興趣的文章:
- 使用PHPStorm+XDebug搭建單步調(diào)試環(huán)境
- Mac OSX下使用MAMP安裝配置PHP開(kāi)發(fā)環(huán)境
- 使用WAMP搭建PHP本地開(kāi)發(fā)環(huán)境
- PHP使用pear實(shí)現(xiàn)mail發(fā)送功能 windows環(huán)境下配置pear
- Mac系統(tǒng)下使用brew搭建PHP(LNMP/LAMP)開(kāi)發(fā)環(huán)境
- mac環(huán)境中使用brew安裝php5.5.15
- nginx php-fpm環(huán)境中chroot功能的配置使用方法
- 如何在PHP環(huán)境中使用ProtoBuf數(shù)據(jù)格式
相關(guān)文章
Apache Flink 任意 Jar 包上傳導(dǎo)致遠(yuǎn)程代碼執(zhí)行漏洞復(fù)現(xiàn)問(wèn)題(漏洞預(yù)警)
這篇文章主要介紹了Apache Flink 任意 Jar 包上傳導(dǎo)致遠(yuǎn)程代碼執(zhí)行漏洞復(fù)現(xiàn)問(wèn)題,本文給出了修復(fù)建議和解決方案,需要的朋友可以參考下2019-11-11
Apache遇到的問(wèn)題 APR not found問(wèn)題的解決方法
checking for APR... no configure: error: APR not found . Please read the documentation2013-07-07
詳解CentOS7下PostgreSQL 11的安裝和配置教程
這篇文章主要介紹了CentOS7下PostgreSQL 11的安裝和配置教程,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-10-10
詳解fedora 開(kāi)啟 apache 并 開(kāi)啟目錄瀏覽模式
這篇文章主要介紹了fedora 開(kāi)啟 apache 并 開(kāi)啟目錄瀏覽模式的相關(guān)資料,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-07-07
JVM上高性能數(shù)據(jù)格式庫(kù)包Apache Arrow入門(mén)和架構(gòu)詳解(Gkatziouras)
Apache Arrow是是各種大數(shù)據(jù)工具(包括BigQuery)使用的一種流行格式,它是平面和分層數(shù)據(jù)的存儲(chǔ)格式,今天給大家介紹JVM上高性能數(shù)據(jù)格式庫(kù)包Apache Arrow入門(mén)和架構(gòu)介紹,感興趣的朋友一起看看吧2021-05-05
解決nginx/apache靜態(tài)資源跨域訪問(wèn)問(wèn)題詳解
有時(shí)為了優(yōu)化網(wǎng)站訪問(wèn)速度,會(huì)給一些靜態(tài)資源配置cdn加速,但是有時(shí)候會(huì)出現(xiàn)跨域訪問(wèn)的問(wèn)題,在nginx和apache服務(wù)中可進(jìn)行如下配置2018-10-10
利用rsync自動(dòng)備份 完全配置方法 增加了ip限制
利用rsync自動(dòng)備份 完全配置,一些細(xì)節(jié)也做到了,對(duì)于比較熟悉rsync的朋友應(yīng)用,限制了ip相對(duì)來(lái)說(shuō)安全增加了。2009-09-09

