安装环境:
[root@secfpm]# cat /etc/redhat-release
CentOSrelease 6.9 (Final)
[root@secfpm]# uname -a
Linuxsec.hxmis.com 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64x86_64 x86_64 GNU/Linux
0x01
到官网http://archive.apache.org/dist/httpd/下载apache http2.4.48
tar zxfhttpd-2.4.18.tar.gz
[root@localhosthttpd-2.4.18]# rpm -qa | grep apr 查看当前主机上是否安装apr/apr-util,这个库为apache提供跨平台的支持
[root@localhosthttpd-2.4.18]# yum install apr apr-util apr-devel pcre-devel openssl-devel 这两个包在光盘镜像都有,配置和yum源即可
使用yum安装的apr位置信息
[root@localhosthttpd-2.4.18]# rpm -ql apr
/usr/lib64/libapr-1.so.0
/usr/lib64/libapr-1.so.0.4.8
/usr/share/doc/apr-1.4.8
/usr/share/doc/apr-1.4.8/CHANGES
/usr/share/doc/apr-1.4.8/LICENSE
/usr/share/doc/apr-1.4.8/NOTICE
[root@localhost httpd-2.4.18]# rpm -ql apr-util
/usr/lib64/apr-util-1
/usr/lib64/libaprutil-1.so.0
/usr/lib64/libaprutil-1.so.0.5.2
/usr/share/doc/apr-util-1.5.2
/usr/share/doc/apr-util-1.5.2/CHANGES
/usr/share/doc/apr-util-1.5.2/LICENSE
/usr/share/doc/apr-util-1.5.2/NOTICE
0x02 Apache编译选项
--prefix=/usr/local/apache
--sysconfdir=/etc/httpd
--with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-util
--enable-so //打开 so 模块,so 模块是用来提 DSO 支持的,提供动态共享模块与php协作
--enable-ssl //https使用
--enable-cgi //为非线程方式工作的mpm使用
--enable-rewrite //支持 URL 重写
--enable-zlib //通用压缩机制
--with-pcre //支持pcre
--enable-module=most //启用大多数常用的模块
--enable-mpms-shared=most //启用MPM支持的模式,启用哪种mpm(prefork,worker,event),使用worker或event时要另外一种方式编译php(编译时使用了–enable-maintainer-zts选项)
--with-mpm=MPM //指定默认的mpm
--enable-deflate //传输压缩机制,节约带宽
--enable-cgid //以线程工作(worker/event)的mpm使用
更多的选项可以通过./configure --help 了解
官方的编译选项文档http://httpd.apache.org/docs/current/programs/configure.html
0x03 安装
1、到官网下载apr和apr-util源码安装。
[root@localhosthttpd-2.4.18]# tar zxf /mymnt/mnt/apr-1.5.2.tar.gz -C /usr/local/src/ #硬盘里面有
[root@localhost httpd-2.4.18]# tar zxf /mymnt/mnt/apr-util-1.5.4.tar.gz -C/usr/local/src/
[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr && make && make install
[root@localhost apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr &&make && make install
[root@localhost httpd-2.4.18]# ./configure --prefix=/usr/local/apache2418--sysconfdir=/usr/local/apache2418/conf --enable-so --enable-ssl --enable-cgi--enable-rewrite --enable-zlib --enable-module=most --enable-mpms-shared=all--with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make &&make install
0x04 如何启动
修改配置文件:
vim/usr/local/apache2418/conf/httpd.conf
ServerRoot"/usr/local/apache2418"
Listen80
LoadModuleauthn_file_module modules/mod_authn_file.so
LoadModuleauthn_core_module modules/mod_authn_core.so
LoadModuleauthz_host_module modules/mod_authz_host.so
LoadModuleauthz_groupfile_module modules/mod_authz_groupfile.so
LoadModuleauthz_user_module modules/mod_authz_user.so
LoadModuleauthz_core_module modules/mod_authz_core.so
LoadModuleaccess_compat_module modules/mod_access_compat.so
LoadModuleauth_basic_module modules/mod_auth_basic.so
LoadModuleallowmethods_module modules/mod_allowmethods.so
LoadModulereqtimeout_module modules/mod_reqtimeout.so
LoadModuleinclude_module modules/mod_include.so
LoadModulefilter_module modules/mod_filter.so
LoadModuledeflate_module modules/mod_deflate.so
LoadModulemime_module modules/mod_mime.so
LoadModulelog_config_module modules/mod_log_config.so
LoadModuleenv_module modules/mod_env.so
LoadModuleheaders_module modules/mod_headers.so
LoadModulesetenvif_module modules/mod_setenvif.so
LoadModuleversion_module modules/mod_version.so
LoadModulempm_event_module modules/mod_mpm_event.so
LoadModuleunixd_module modules/mod_unixd.so
LoadModulestatus_module modules/mod_status.so
LoadModuleautoindex_module modules/mod_autoindex.so
Userwww
Groupwww
ServerName192.168.66.13
<FilesMatch"\.ph(p[2-6]?|tml)$">
SetHandlerapplication/x-httpd-php
</FilesMatch>
LoadModulenegotiation_module modules/mod_negotiation.so
LoadModuledir_module modules/mod_dir.so
LoadModuleactions_module modules/mod_actions.so
LoadModulealias_module modules/mod_alias.so
LoadModulerewrite_module modules/mod_rewrite.so
LoadModulephp7_module modules/libphp7.so
php_admin_valueopen_basedir "/usr/local/apache2418/htdocs/pm_hexincorp_cn"
chownwww.www /usr/local/apache2418/htdocs
0x05 启动服务
[root@localhostapache2]# /usr/local/apache2418/bin/apachectl start|stop
Apache 没有带服务脚本,所以需要自己编写一个用来实现开机启动。当然这里临时使用的就略过了
0x06 编译安装后一般设置
1、导出头文件;以目录链接的形式来实现
[root@localhost]#ln -sv /usr/local/apache2418/include/ /usr/include/httpd
2、输出二进制程序
[root@localhost]#vim /etc/profile.d/httpd24.sh
exportPATH=/usr/local/apache2418/bin:$PATH
[root@localhost]#./etc/profile.d/httpd24.sh
3、导出man文件
[root@localhost]#vim /etc/man.config
MANPATH/usr/local/apache2/man
[root@localhost]#man -M /usr/local/apache2/man httpd
4、导出库文件
把lib目录路径输出到/etc/ld.so.conf.d
[root@localhost]#echo“/usr/local/apache2/lib” > /etc/ld.so.conf.d/httpd
5、服务脚本
写个启动脚本放置在/etc/init.d/目录即可用service启动。
0x07 PHP7.0.1源代码安装:
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetypefreetype-devel libxml2 libxml2-devel mysql pcre-devel curl-devel libxslt-devel
[root@seclamp]# tar xf php-7.0.1.tar.gz
./configure --prefix=/usr/local/php701--with-apxs2=/usr/local/apache2418/bin/apxs --with-curl --with-freetype-dir--with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64--with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex--with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc--with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml--enable-inline-optimization --enable-gd-native-ttf --enable-mbregex--enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap--enable-sockets --enable-sysvsem --enable-xml --enable-zip
make&& make install (PS:如果是重装,记得要先make clean,再make)
编译错误请查看本目录下FAQ
0x08 配置
# cp/usr/local/src/lamp/php-7.0.1/php.ini-development /usr/local/php/lib/php.ini #php.ini-development php.ini-production
# cp/usr/local/php-7.0.1/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp/usr/local/php-7.0.1/etc/php-fpm.d/www.conf.default/usr/local/php/etc/php-fpm.d/www.conf
#CentOS6.x启动脚本
cp -R /usr/local/src/lamp/php-7.0.1/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm-701 && chmod 755 /etc/init.d/php-fpm-701
#CentOS7.x启动脚本:
cp -R/usr/local/src/lamp/php-7.0.1/sapi/fpm/php-fpm.service /etc/init.d/php-fpm-701 && chmod 755 /etc/init.d/php-fpm-701
需要注意的是php7中www.conf这个配置文件配置phpfpm的端口号等信息,如果你修改默认的9000端口号需在这里改,再改nginx的配置
0x09 启动
# /etc/init.d/php-fpm
phpinfo();