CentOS 5.3上yum安装Apache+php+Mysql+phpMyAdmin

来源:互联网 发布:淘宝直销店是什么意思 编辑:程序博客网 时间:2024/04/29 15:23

 CentOS 5.3上yum安装Apache+php+Mysql+phpMyAdmin

一、系统下载

CentOS 开发社区已发布了新的 5.3 版本。CentOS 5.3 基于 Red Hat Enterpris Linux 5.3.0,其中包括 Kernel 2.6.18、Apache 2.2、PHP 5.1.6、MySQL 5.0、PostgreSQL 8、GNOME 2.16、KDE 3.5、OpenOffice.org 2.3、Firefox 3.0、Evolution 2.12 等等。此外,CentOS 5.3 更新了美工设计,并根据用户的请求恢复了 Contrib 仓库。

CentOS 5.3 支持 i386 及 x86_64 架构,其 ISO 映像可从以下地址获取。

isoredirect.centos.org/centos/5

/isos/

二、系统安装

安装CentOS 5.3是做服务器,所以没有用的,一概不装;具体哪些不装,自己看着办吧:)

三、安装、配置Apache+php+Mysql

Centos 里的 yum 在线安装很慢.以下是替换为中国CentOS镜像服务器!

中国官方镜像网站: http://centos.ustc.edu.cn/

引用:

 

/* 使用说明 */

 

cd /etc/yum.repos.d[进入yum.repos.d目录]

mv CentOS-Base.repo  CentOS-Base.repo.save[修改源文件名称备份]

wget http://centos.ustc.edu.cn/CentOS-Base.repo.5[下载]

mv CentOS-Base.repo.5 CentOS-Base.repo[下载后的文件更名]

 

1. 更新系统内核到最新.

引用:

 

yum -y update

 

系统更新后,如果yum安装时提示错误信息,请执行以下命令修复.

引用:

 

rpm –import  /etc/pki/rpm-gpg/RPM-GPG-KEY*

 

2. 安装Apahce, PHP, Mysql, 以及php连接mysql库组件

引用:

 

yum -y install httpd php mysql mysql-server php-mysql

 

//安装mysql扩展

yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

//安装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

 

一次性粘贴安装:

引用:

 

yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql

 

3. 启动服务配置

引用:

 

/sbin/chkconfig httpd on [设置apache为自启动]

 

/sbin/chkconfig –-add mysqld [mysql服务]

/sbin/chkconfig mysqld on [mysqld服务]

/sbin/service httpd start [自启动 httpd 服务]

/sbin/service mysqld start [自启动mysqld服务]

 

4.设置mysql数据库root帐号密码。

引用:

 

mysqladmin -u root password ‘新密码’ [引号内填密码]

 

5.让mysql数据库更安全

引用:

 

mysql -u root -p [此时会要求你输入刚刚设置的密码,输入后回车即可

 

mysql> DROP DATABASE test; [删除test数据库]

mysql> DELETE FROM mysql.user WHERE user = ”; [删除匿名帐户]

mysql> FLUSH PRIVILEGES; [重载权限]

 

按照以上的安装方式, 配置出来的默认站点目录为/var/www/html/新建一个php脚本:

引用:

 

<?php

 

phpinfo();

?>

 

6. 防火墙配置

引用:

 

a.添加.允许访问端口{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.保存

service iptables save

c.重置加载防火墙

service iptables restart

 

7. 安装phpMyAdmin进入phpMyAdmin官方下载最新版本后,上传到你的网站目录下,然后进行配置。只需几步即可搞定。

引用:

 

a. config.sample.inc.php更名为config.inc.php;

 

b. 打开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’;

去掉每行前面的//;

c.$cfg['blowfish_secret'] = ”; |修改为|  $cfg['blowfish_secret'] = ‘http’;

d.$cfg['Servers'][$i]['controluser'] = ‘pma’; |把’pma’修改为你的帐号|

e.$cfg['Servers'][$i]['controlpass'] = ‘pmapass’;  |把’pmapass设置为你的mysql登录密码|

f. $cfg['blowfish_secret'] = ”; | 添加短语密码例如:$cfg['blowfish_secret'] = ‘onohot’|