httpd把.php资源的请求“反向代理”至php服务器;httpd依赖于反向代理模块以及专用于fastcgi反向代理模块
httpd-2.2默认没有附带专用fastcgi反向代理模块,所以需要独立安装;
http-2.4已经自带此模块:mod_proxy_fcgi
安装次序:httpd或mysql 再装php,php编译安装mysql的开发环境
1、安装apr
#tar xf apr-1.5.0.tar.bz2
#cd apr-1.5.0
#./configure --prefix=/usr/local/apr
#make
#make install
2、安装apr-util
#tar xf apr-util-1.5.3.tar.bz2
#cd apr-util
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#make
#mkae install
3、安装httpd
#tar xf httpd-2.4
#cd httpd-2.4
#yum install pcre-devel
#yum install openssl-devel
# ./configure --prefix=/usr/local/httpd24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event
#make
#make install
4、安装mariadb
编译安装mysql
mariadb-5.5.36的包
#groupadd -r mysql
#useradd -g mysql -r mysql
#id mysql
#tar xf mariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local
注意:一定要解压至/usr/local目录,因为它自己也提供了服务脚本,脚本中的路径是/usr/local
#ln -s mariadb-5.5.36-linux-x86_64 mysql
bin 二进制程序
data 数据存放目录
scripts/mysql_install_db mysql初始化脚本
support-file 样例文件
其中国有样例配置文件,但是提供了不同的版本
huge 海量内存
large 服务器硬件叫充分
small 较少的内存
mysql.server 服务脚本
#mkdir -p /mydatad/data
#chown -R mysql:mysql /mydata/data
#scripts/mysql_install_db --help
#scripts/mysql_install_db --datadir=/mydata/data --user=mysql
#mkdir /etc/mysql
#cp support-file/my-large.cnf /etc/mysql/my.cnf
#vim /etc/mysql/my.cnf
datadir=/mydata/data
#cp scripts/mysql.server /etc/rc.d/init.d/mysqld
#chkconfig --add mysqld
#chkconfig mysqld on
#service mysqld start
#vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
#. /etc/profile.d/mariadb.sh
5、安装php-5.4.26
#yum install libxml2-devel libmcrypt-devel bzip2-devel
#tar xf php-5.4.26
#./configure --help
#./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-mcrypt --with-bz2 --with-config-file-path=/etc/php/php.ini --with-config-file-scan-dir=/etc/php/php.d/
#make
#make install
6、配置文件:
php的配置文件:php.ini
php的守护进程配置文件:fpm.conf
#mkdir -pv /etc/php/php.d
#cp php.ini-production /etc/php/php.ini
#cp php-5.4.26/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
#chkconfig --add php-fpm
#
#vim /usr/local/php/etc/php-fpm.conf
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
#vim /etc/httpd24/httpd.conf
LoadModule proxy_module modeles/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off 关闭正向代理
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1