以前在Ubuntu上安装过LAMP,一直没在CentOS上装过,认为过这两个好像安装都一样,很方便。

第一步:安装apache mysql php

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

//安装apacher服务器、apacher所需的库和包含文件、MySQL服务器、MySQL所需的库和包含文件、PHP

系统提示:

Installing
httpd-devel、mysql-server、mysql、mysql-devel、php
installing for dependencies:
apr-devel、apr-util-devel、cyrus-sasl-devl、db4-devel、e2fsprogs-devel、 expat-devel、gcc、glibc-debel、glibc-headers、kernel-headers、keyutils-libs- devel、krb5-devel、libselinux-devel、libsepol-devel、openldap-devel、openssl- devel、perl-DBD-MySQL、perl-DBI、php-cli、php-common、zlib-devel、

 

 

第二步:配置MySQL

创建mysql启动链接

chkconfig --levels 235 mysqld on                 //这样mysql会随着系统启动而启动

 

启动mysql

#etc/init.d/mysqld start

给root设置密码:

# mysql_secure_installation

系统提示:

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):   (一般刚装上mysql,root没有密码,在此直接Enter)
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password: 12345678    //设定新密码
Re-enter new password:12345678   //再次确认密码

 

之后一路Enter就可以了

第三步:测试apache和php

创建httpd启动链接

chkconfig --levels 235 httpd on

启动apache

/etc/init.d/httpd start

apache测试:在浏览器里输入服务器IP,打开后看到apache那经典的页面,OK!apache正常运行了(如开了防火墙,不要忘记在防火墙放行www)。

PHP测试:创建个php.info

vim /var/www/html/info.php
<?
phpinfo();
?>

 

然后在浏览器里输入http://localhost/info.php应该能看到测试页面

第四步:让PHP支持mysql

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc  php-mbstring

系统提示:(安装以下软件包)

Installed:
php-gd.i386 0:5.1.6-27.el5_5.3               php-imap.i386 0:5.1.6-27.el5_5.3          php-ldap.i386 0:5.1.6-27.el5_5.3
php-mbstring.i386 0:5.1.6-27.el5_5.3         php-mysql.i386 0:5.1.6-27.el5_5.3         php-odbc.i386 0:5.1.6-27.el5_5.3
php-pear.noarch 1:1.4.9-6.el5                php-xml.i386 0:5.1.6-27.el5_5.3           php-xmlrpc.i386 0:5.1.6-27.el5_5.3

 

安装好后再重启httpd

#/etc/init.d/httpd restart

再在浏览器里输入http://localhost/info.php应能看到mysql的模块

第五步:安装phpmyadmin

在centos里phpmyadmin无法用yum install来安装,先要加入

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

 

rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm

然后再

yum install phpmyadmin

系统提示将装安装下列程序包

Installed:
  phpmyadmin.noarch 0:2.11.11.3-2.el5.rf                                                                                       
Dependency Installed:
  libmcrypt.i386 0:2.5.8-4.el5.centos                            php-mcrypt.i386 0:5.1.6-15.el5.centos.1

 

修改phpmyadmin.conf让用户可以远程登录

vim /etc/httpd/conf.d/phpmyadmin.conf

将下面的语句全部注释掉

<Directory "/usr/share/phpmyadmin">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>

如果出现:phpmyadmin配置文件现在需要绝密的短语密码(blowfish_secret)

请移步:http://www.pooy.net/blowfish-secret.html

解决Apache 2 Test Page powered by CentOS问题

 

 

 

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="">

请选择吧!