yum install -y gcc gcc-c++ yum groupinstall "Development tools" yum install zlib-devel pcre-devel yum install openssh-clients wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.6.tar.gz wget http://mirror.esocc.com/apache//apr/apr-1.4.8.tar.gz wget http://mirror.esocc.com/apache//apr/apr-util-1.5.2.tar.gz tar -xvf httpd-2.4.6.tar.gz tar -xvf apr-1.4.8.tar.gz tar -xvf apr-util-1.5.2.tar.gz mv apr-1.4.8 httpd-2.4.6/srclib/apr mv apr-util-1.5.2 httpd-2.4.6/srclib/apr-util cd httpd-2.4.4 ./configure --with-included-apr --enable-nonportable-atomics=yes --with-z --enable-so make make install
修改配置文件,将以下行的注释去掉
/usr/local/apache2/conf/httpd.conf LoadModule authz_host_module modules/mod_authz_host.so LoadModule authz_core_module modules/mod_authz_core.so LoadModule userdir_module modules/mod_userdir.so LoadModule dir_module modules/mod_dir.so LoadModule mime_module modules/mod_mime.so LoadModule php5_module modules/libphp5.so
添加mime,添加一行
/usr/local/apache2/conf/mime.types application/x-httpd-php php
老版本需要改
/usr/local/apache2/conf/httpd.conf <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch>
服务的启动和停止
/usr/local/apache2/bin/apachectl [-k start|restart|graceful|graceful-stop|stop] /usr/local/apache2/bin/apachectl -k start /usr/local/apache2/bin/apachectl -k stop
访问测试
http://192.168.200.146
it works!
说明安装成功
以下步骤,配置完PHP后再测试
zabbix[3]为zabbix server编译安装php5.6
测试php
vi /usr/local/apache2/htdocs/info.php
<?php phpinfo() ?>
http://192.168.200.146/info.php
出现php安装修,则php运行无误
引用
System Linux centos.vm.zzdev.com 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64
Build Date Aug 12 2016 00:33:15
Configure Command './configure' '--prefix=/opt/php5' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-config-file-path=/opt/php5/lib' '--disable-cli' '--enable-shared' '--with-libxml-dir' '--with-gd' '--with-openssl' '--enable-mbstring' '--with-mcrypt' '--with-mysqli' '--with-mysql' '--enable-opcache' '--enable-mysqlnd' '--enable-zip' '--with-zlib-dir' '--with-pdo-mysql' '--with-jpeg-dir' '--with-freetype-dir' '--with-curl' '--without-pdo-sqlite' '--without-sqlite3' '--enable-bcmath' '--enable-sockets' '--with-gettext'
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path /opt/php5/lib
Loaded Configuration File /opt/php5/lib/php.ini
Scan this dir for additional .ini files (none)
Additional .ini files parsed (none)
PHP API 20131106
PHP Extension 20131226
Zend Extension 220131226
Zend Extension Build API220131226,TS
PHP Extension Build API20131226,TS
Debug Build no
Thread Safety enabled
Zend Signal Handling disabled
Zend Memory Manager enabled
Zend Multibyte Support provided by mbstring
IPv6 Support enabled
DTrace Support disabled
Registered PHP Streams https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters zlib.*, convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk
Zend logo This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies