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/ 文件夹下~
相关文章
相关标签/搜索