install_httpd_php
一、安装httpd
创新互联2013年至今,先为文登等服务建站,文登等地企业,进行企业商务咨询服务。为文登企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
1、安装apr
yum -y install gcc gcc-c++ openssl-devel pcre-devel tar xf apr-1.4.6.tar.bz2 cd apr-1.4.6 ./configure --prefix=/usr/local/apr --disable-ipv6 make && make install
2、安装apr-util
tar xf apr-util-1.4.1.tar.bz2 cd apr-util-1.4.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install
3、安装apache
tar zxf httpd-2.4.17.tar.gz cd httpd-2.4.17 ./configure \ --prefix=/usr/local/apache \ --sysconfdir=/etc/httpd \ --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-mods-shared=most \ --enable-mpms-shared=all \ --with-mpm=event make && make install
4、设置服务控制脚本
cp build/rpm/httpd.init /etc/init.d/httpd vim /etc/init.d/httpd httpd=${HTTPD-/usr/local/apache/bin/httpd} pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid} lockfile=${LOCKFILE-/var/lock/subsys/${prog}} RETVAL=0 # check for 1.3 configuration check13 () { CONFFILE=/etc/httpd/httpd.conf echo "PATH=/usr/local/apache/bin:$PATH" >> /etc/profile.d/http.sh . /etc/profile.d/http.sh ln -s /usr/local/apache/include/ /usr/include/httpd vim /etc/httpd/httpd.conf ServerName localhost:80 chkconfig --add httpd chkconfig httpd on service httpd start
二、安装php
tar zxf php-5.6.0.tar.gz cd php-5.6.0 yum install -y libxml2 libxml2-devel bzip2 bzip2-devel curl* curl-devel libjpeg\* openjpeg\* \*png\* freetype\* ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --with-bz2 \ --with-curl \ --enable-ftp \ --enable-sockets \ --disable-ipv6 \ --with-gd \ --with-jpeg-dir=/usr/local \ --with-png-dir=/usr/local \ --with-freetype-dir=/usr/local \ --enable-gd-native-ttf \ --with-iconv-dir=/usr/local \ --enable-mbstring \ --enable-calendar \ --with-gettext \ --with-libxml-dir=/usr/local \ --with-zlib \ --with-pdo-MySQL=mysqlnd \ --with-mysqli=mysqlnd \ --with-mysql=mysqlnd \ --enable-dom \ --enable-xml \ --enable-fpm \ --with-libdir=lib64 \ --enable-bcmath make make install cp php.ini-production /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on service php-fpm start
三、整合httpd和php
方式1:修改httpd主配置文件httpd.conf
去掉以下两行的 ‘#’ LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so 修改ServerName ServerName 127.0.0.1:80 或 ServerName localhost:80 添加SetHandler "proxy:fcgi://127.0.0.1:9000"
方式2:配置虚拟主机
去掉以下三行的 ‘#’ LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so Include /etc/httpd/extra/httpd-vhosts.conf 修改ServerName ServerName 127.0.0.1:80 或 ServerName localhost:80 注释下面正一行 DocumentRoot "/usr/local/apache/htdocs" 在httpd-vhosts.conf配置文件添加虚拟机DocumentRoot "/usr/local/apache/htdocs" ServerName www.example.com ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1 Options none AllowOverride none Require all granted
四、测试
新建测试文件
vim /usr/local/nginx/html/phpinfo.php
在浏览器中输入:http://ip/phpinfo.php
网页名称:install_httpd_php
标题网址:http://cdiso.cn/article/pcscjh.html