PHP连接mysql
[root@localhost mysql]# yum install php-mysql
CMS:(开源)
drupal
joomla
编译安装LAMP之httpd
安装顺序:httpd-->mysql-->php
版本:
httpd:2.4.12
mysql:5.6.10
php:5.4.42
apr:Apache Portable Runtime,是HTTPD的虚拟机
apr-util
apr-iconv
编译安装httpd软件:
# yum -y install pcre-devel #HTTPD的编译环境 # tar xf apr-1.4.6.tar.bz2 #httpd虚拟机apr软件安装 # cd apr-1.4.6 # ./configure --prefix=/usr/local/apr # make # make install # tar xf apr-util-1.4.1.tar.bz2 #apr-util工具包的安装 # cd apr-util-1.4.1 # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr # make # make install # tar xf httpd-2.4.4.tar.bz2 # cd httpd-2.4.4 ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --enable-deflate --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util # make # make install --prefix=/usr/local/apache #安装路径 --sysconfdir=/etc/httpd #配置文件路径 --enable-so #支持共享模块 --enable-rewirte #支持URL重写 --enable-ssl #支持ssl --enable-cgi #进程方式使用cgi --enable-cgid #纯种方式使用cgi --enable-modules=most --enable-mods-shared=most #启用共享模块 --enable-mods-static=MODULE-LIST #静态库,直接编译进主程序 --enable-mpms-shared=all #多道处理模块(MPM)的支持 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-authn-dbm #启用认证,默认是启用的 --enable-deflate #启用网页传输压缩
--enable-mpms-shared=all #多道处理模块(MPM)的支持,需注意的是,如果是使用worker,event模式,PHP必须编译安装成ZTS格式,prefork模式不需要单独编译php
配置安装好的httpd服务:
#修改httpd的pid进程文件路径
[root@localhost apache]# vim /etc/httpd/httpd.conf
PidFile "/var/run/httpd.pid" #需要停用服务,再去修改配置
[root@localhost apache]# ./bin/apachectl start #启动服务
[root@localhost apache]# ls /var/run/ | grep httpd
httpd.pid
#配置httpd服务管理脚本:
vim /etc/rc.d/init.d/httpd
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve # HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
[root@localhost tmp]# chmod +x /etc/rc.d/init.d/httpd #给服务脚本权限
[root@localhost tmp]# chkconfig --add httpd #加入服务列表
[root@localhost tmp]# chkconfig --level 2345 httpd on #加入运行启动级别
[root@localhost tmp]# chkconfig --list | grep httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#现在可以使用service httpd start的方式来管理httpd服务
#添加PATH环境变量,以正常的情况执行http相关命令
[root@localhost ~]# cat /etc/profile.d/httpd.sh
export PATH=$PATH:/usr/local/apache/bin原文:http://leozhenping.blog.51cto.com/10043183/1663298