一、准备yum源(本文使用了163镜像)
# mv /etc/yum.repos.d/centos-base.repo /etc/yum.repos.d/centos-base.repo.backup# wget http://mirrors.163.com/.help/centos6-base-163.repo -p /etc/yum.repos.d/# yum clean all# yum makecache
二、安装apache httpd
详细可以参考:linux下安装apache httpd
###检查是否已安装httpd# rpm -qa|grep httpd httpd-tools-2.2.15-45.el6.centos.x86_64 httpd-2.2.15-45.el6.centos.x86_64# yum -y install httpd ###此时我们看到httpd的小版本从45变成了53# rpm -qa|grep httpd httpd-tools-2.2.15-53.el6.centos.x86_64 httpd-2.2.15-53.el6.centos.x86_64###查询生成的相关配置文件# rpm -qc httpd|grep conf /etc/httpd/conf.d/welcome.conf /etc/httpd/conf/httpd.conf /etc/httpd/conf/magic /etc/sysconfig/htcacheclean /etc/sysconfig/httpd###启动httpd# /etc/init.d/httpd start starting httpd: [ ok ]# netstat -nltp|grep 80 tcp 0 0 :::80 :::* listen 7621/httpd###验证web服务# curl -i http://localhost http/1.1 403 forbidden date: tue, 12 jul 2016 09:25:15 gmt server: apache/2.2.15 (centos) accept-ranges: bytes content-length: 4961 connection: close content-type: text/html; charset=utf-8###编写一个php页面测试# echo > > this is a php test page.> phpinfo();> ?>> >>/var/www/html/index.php ###测试结果为phpinfo函数没有被解释# curl http://localhost/index.php this is a php test page.
三、安装php
###安装php,同时会安装依赖包# yum install php installing: php x86_64 5.3.3-47.el6 base 1.1 m installing for dependencies: php-cli x86_64 5.3.3-47.el6 base 2.2 m php-common x86_64 5.3.3-47.el6 base 530 k###查看php安装清单 # rpm -ql php /etc/httpd/conf.d/php.conf /usr/lib64/httpd/modules/libphp5.so /var/lib/php/session /var/www/icons/php.gif ###查看php的配置文件 # grep -ve ^#|^$ /etc/httpd/conf.d/php.conf loadmodule php5_module modules/libphp5.so loadmodule php5_module modules/libphp5-zts.so addhandler php5-script .php addtype text/html .php directoryindex index.php###在上面的配置文件中,由于php以模块化方式与httpd结合工作,根据httpd的mpm模式不同,###其所需要的php模块格式有所不同; prefork模式使用libphp5模块 worker和event模式则使用libphp5-zts模块###重启httpd已使得php模块生效# /etc/init.d/httpd configtest syntax ok# /etc/init.d/httpd restart stopping httpd: [ ok ] starting httpd: [ ok ]###验证php模块已经被加载# httpd -m |grep php php5_module (shared)###验证php页面 # curl http://localhost/index.php|more this is a php test page. span> public -//w3c//dtd xhtml 1.0 transitional//endtd/xhtml1-transitional.dtd>
四、安装mysql
# rpm -qa|grep mysql mysql-libs-5.1.73-5.el6_6.x86_64# yum install mysql-server # rpm -qa|grep mysql mysql-5.1.73-7.el6.x86_64 mysql-libs-5.1.73-7.el6.x86_64 mysql-server-5.1.73-7.el6.x86_64###查看mysql安装产生的文件# rpm -ql mysql-server# rpm -ql mysql# more /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid# /etc/init.d/mysqld start# /usr/bin/mysqladmin -u root password '***'# mysql -uroot -pmysql> show variables like 'port';+---------------+-------+| variable_name | value |+---------------+-------+| port | 3306 |+---------------+-------+###安装php连接mysql驱动# yum install php-mysql###查看安装完毕后生产的文件# rpm -ql php-mysql /etc/php.d/mysql.ini ### author : leshami /etc/php.d/mysqli.ini ### blog : http://blog.csdn.net/leshami /etc/php.d/pdo_mysql.ini /usr/lib64/php/modules/mysql.so /usr/lib64/php/modules/mysqli.so /usr/lib64/php/modules/pdo_mysql.so###测试到mysql的连接#vim /var/www/html/connmysql.php# curl http://localhost/connmysql.php succ
五、小结
1、apache httpd与php之间的衔接是通过模块化的方式来实现。
2、对于perfork模式使用libphp5模块,worker和event模式则使用libphp5-zts模块。
3、php与mysql则通过安装php-mysql包来实现php到mysql的访问。
').addclass('pre-numbering').hide(); $(this).addclass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadein(1700); }); }); 以上就介绍了 linux 6 下yum方式安装配置lamp平台,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。