一:先添加下yum源:
- #sh centostweak.sh
- #部分centostweak内容 源自leo
- # 设置升级源
- cd /etc/yum.repos.d/
- cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.`date +"%Y-%m-%d_%H-%M-%S"`
- sed -i -e 's/mirrorlist/#mirrorlist/' CentOS-Base.repo
- sed -i -e 's/#baseurl/baseurl/' CentOS-Base.repo
- sed -i -e 's/mirror.centos.org/mirrors.sohu.com/' CentOS-Base.repo
- cp /etc/yum.conf /etc/yum.conf.`date +"%Y-%m-%d_%H-%M-%S"`
- sed -i 's/gpgcheck=1/gpgcheck=0/' /etc/yum.conf
- sed -i 's/plugins=1/plugins=0/' /etc/yum.conf
- sed -i 's/metadata_expire=1h/metadata_expire=24h/' /etc/yum.conf
- # 添加dag@sohu源
- # relver=`uname -r | awk -F. '{print $NF}'`
- echo -e "# Name: SOHU RPM Repository for Red Hat Enterprise – dag\n"\
- "# URL: http://mirrors.sohu.com/dag/redhat/\n"\
- "[dag-sohu]\n"\
- "name = Red Hat Enterprise \$releasever – sohu.com – dag\n"\
- "baseurl = http://mirrors.sohu.com/dag/redhat/`uname -r | awk -F. '{print substr($NF,1,3)}'`/en/\$basearch/dag\n"\
- "enabled = 1\n"\
- "gpgcheck = 0" > /etc/yum.repos.d/dag-sohu.repo
- # 添加epel@sohu源
- echo -e "# Name: SOHU RPM Repository for Red Hat Enterprise – EPEL\n"\
- "# URL: http://mirrors.sohu.com/fedora-epel/\n"\
- "[epel-sohu]\n"\
- "name = Fedora EPEL \$releasever - sohu.com\n"\
- "baseurl = http://mirrors.sohu.com/fedora-epel/\$releasever/\$basearch\n"\
- "enabled = 1\n"\
- "gpgcheck = 0" > /etc/yum.repos.d/epel-sohu.repo
- # 添加CentALT源
- # 使用方法:--enablerepo=centalt
- if [[ `uname -r | awk -F. '{print substr($NF,1,3)}'` == "el5" ]]; then
- echo -e "[CentALT]\n"\
- "name=CentALT Packages for Enterprise Linux 5 - \$basearch\n"\
- "baseurl=http://centos.alt.ru/repository/centos/5/\$basearch/\n"\
- "enabled=0\n"\
- "gpgcheck=0" > /etc/yum.repos.d/centalt.repo
- fi
- # 添加ius源
- # 使用方法:--enablerepo=ius,如yum install python26 --enablerepo=ius
- echo -e "# Name: IUS RPM Repository for Red Hat Enterprise 5\n"\
- "# URL: http://dl.iuscommunity.org/pub/ius/stable/Redhat/\n"\
- "[ius]\n"\
- "name = Red Hat Enterprise \$releasever – ius\n"\
- "baseurl = http://dl.iuscommunity.org/pub/ius/stable/Redhat/\$releasever/\$basearch/\n"\
- "enabled = 0\n"\
- "gpgcheck = 0" > /etc/yum.repos.d/ius.repo
二、安装
1:安装apache
- yum install httpd httpd-devel
2:安装mysql
- yum install mysql mysql-server mysql-devel
3:安装php
- yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
4:启动apache
测试php
建立以下文件/var/www/html/test.php
编辑其内容
- // test.php
- <?php
- phpinfo();
- ?>
5:测试
在浏览器中输入:http://IP/test.php
看是否显示PHP的信息
6:设置开机启动
- chkconfig httpd on