tythg 发表于 2015-8-3 08:25:58

CentOS 5.5下安装Apache+php+Mysql+phpMyAdmin

在CentOS 5.5下安装Apache+php+Mysql+phpMyAdmin的php环境
今天主要讲一下centos5.5用yum安装配置php环境,主要安装的有apache、php、mysql、phpMyAdmin。下面是安装php环境的准备工作和安装步骤:
一、安装centos5.5操作系统


二、系统安装
安装CentOS 5.5是做服务器,所以没有用的,一概不装;具体哪些不装,自己看着办吧:
三、安装Apache+php+Mysql

1.换源,sohu的相当好用。
1.1备份CentOS-Base.repocd /etc/yum.repos.d/
cp CentOS-Base.repo CentOS-Base.repo.bak

  以超级用户登录
  先关闭fastestmirror “vi /etc/yum/pluginconf.d/fastestmirror.conf”
  and set “enable=0″

sohu的yum源
wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
更新玩yum源后,建议更新一下,使操作立即生效
yum makecache  yum 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密码
         mysql> USE mysql;
         mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';   
         mysql> FLUSH PRIVILEGES;   
2.2.3 允许远程登录
         mysql -u root -p   
         Enter 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.测试一下
在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。

四、 配置防火墙
添加允许访问HTTP、FTP端口

代码:
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
重启iptables: service iptables restart
五、安装phpMyAdmin
进入phpMyAdmin官方下载phpMyAdmin,3.1以上需php 5.2以上,上传到你的网站目录下,然后进行配置。只需几步即可搞定。
config.sample.inc.php更名为config.inc.php,然后打开config.inc.php文件,进行以下修改;
代码:
// $cfg['Servers'][$i]['controluser'] = ‘pma’;
// $cfg['Servers'][$i]['controlpass'] = ‘pmapass’;
// $cfg['Servers'][$i]['pmadb'] = ‘phpmyadmin’;
// $cfg['Servers'][$i]['bookmarktable'] = ‘pma_bookmark’;
// $cfg['Servers'][$i]['relation'] = ‘pma_relation’;
// $cfg['Servers'][$i]['table_info'] = ‘pma_table_info’;
// $cfg['Servers'][$i]['table_coords'] = ‘pma_table_coords’;
// $cfg['Servers'][$i]['pdf_pages'] = ‘pma_pdf_pages’;
// $cfg['Servers'][$i]['column_info'] = ‘pma_column_info’;
// $cfg['Servers'][$i]['history'] = ‘pma_history’;
// $cfg['Servers'][$i]['designer_coords'] = ‘pma_designer_coords’;
去掉每行前面的//注释
$cfg['blowfish_secret'] = ”; |修改为| $cfg['blowfish_secret'] = ‘http’;
$cfg['Servers'][$i]['controluser'] = ‘pma’; |把’pma’修改为你的帐号|$cfg['Servers'][$i]['controlpass'] = ‘pmapass’; |把’pmapass设置为你的mysql登录密码
$cfg['blowfish_secret'] = ”; | 添加短语密码例如:$cfg['blowfish_secret'] = ‘onohot’;
六、安装php的扩展
代码:
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
七、安装apache扩展
代码:
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql  到此为止centos5.3下的php环境基本就配置完成了,用命令启动服务即可使用。
八、如果想升级PHP的话
提及php需要升级到5.2以上,而centos 5.x目前提供php版本为5.1.6,
通过以下方法升级PHP到5.2比较方便,现推荐给大家。


先将以下地址导入。
# rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
# vi /etc/yum.repos.d/CentOS-Base.repo 增加下面信息

name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
执行命令,自动升级。
#################
升级与维护
yum update php -y
yum install libmcrypt -y

1、查看3306端口:# netstat -hat和telnet localhost 3306
2、改密:# /usr/bin/mysqladmin -u root password 'new-password'
3、添加组:
# vi /etc/passwd 按G到最后一页,查看是否有mysql用户。则:q退出,
# vi /etc/group 查看是否有mysql组
如果没有组,则# groupadd mysql,如果没有mysql用户则# useradd -g mysql mysql
mysql组和mysql成员都存在,则gpasswd -a mysql mysql把用户加入到MYSQL中
4、启动、重启mysql服务:
service mysqld restart
service mysqld start
页: [1]
查看完整版本: CentOS 5.5下安装Apache+php+Mysql+phpMyAdmin