You may edit your .ini file to set PHP options. If you prefer
having php.ini in another location, use
--with-config-file-path=/some/path in step 5. 自定义配置文件路径
If you instead choose php.ini-production, be certain to read the
list of changes within, as they affect how PHP behaves.
7. Edit your httpd.conf to load the PHP module. The path on the right
hand side of the LoadModule statement must point to the path of the
PHP module on your system. The make install from above may have
already added this for you, but be sure to check.
LoadModule php5_module modules/libphp5.so 在httpd配置文件中添加语句加载php模块
8. Tell Apache to parse certain extensions as PHP. For example, let's
have Apache parse .php files as PHP. Instead of only using the
Apache AddType directive, we want to avoid potentially dangerous 只使用AddType指令具有潜在危险
uploads and created files such as exploit.php.jpg from being
executed as PHP. Using this example, you could have any
extension(s) parse as PHP by simply adding them. We'll add .php to
demonstrate.
<FilesMatch \.php$> 正则表达式,匹配所有“.php”结尾的文件名
SetHandler application/x-httpd-php
</FilesMatch>
Or, if we wanted to allow .php, .php2, .php3, .php4, .php5, .php6,
and .phtml files to be executed as PHP, but nothing else, we'd use
this:
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
And to allow .phps files to be handled by the php source filter,
and displayed as syntax-highlighted source code, use this:
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
mod_rewrite may be used To allow any arbitrary .php file to be
displayed as syntax-highlighted source code, without having to
rename or copy it to a .phps file:
RewriteEngine On
RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source]
The php source filter should not be enabled on production systems,
where it may expose confidential or otherwise sensitive information
embedded in source code.
9. Use your normal procedure for starting the Apache server, e.g.:
/usr/local/apache2/bin/apachectl start
OR
service httpd restart
Following the steps above you will have a running Apache2 web server
with support for PHP as a SAPI module. Of course there are many more
configuration options available Apache and PHP. For more information
type ./configure --help in the corresponding source tree.
Apache may be built multithreaded by selecting the worker MPM, rather
than the standard prefork MPM, when Apache is built. This is done by
adding the following option to the argument passed to ./configure, in
step 3 above:
--with-mpm=worker
This should not be undertaken without being aware of the consequences
of this decision, and having at least a fair understanding of the
implications. The Apache documentation regarding » MPM-Modules
discusses MPMs in a great deal more detail.
Note:
The Apache MultiViews FAQ discusses using multiviews with PHP.
Note:
To build a multithreaded version of Apache, the target system must
support threads. In this case, PHP should also be built with
experimental Zend Thread Safety (ZTS). Under this configuration, not
all extensions will be available. The recommended setup is to build
Apache with the default prefork MPM-Module.
__________________________________________________________________
具体参数含义可以用./configure --help来查看。源自 ,还有一个官方的文档参考
列表如下(部分参数未得到解释):
# 指定 php 安装目录
--prefix=/usr/local/php
# 指定php.ini位置
--with-config-file-path=/usr/local/php/etc
# mysql安装目录,对mysql的支持
--with-mysql=/usr/local/mysql
mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定。
--with-mysqli=/usr/local/mysql/bin/mysql_config
整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到 apache,要求 apache 要打开SO模块
--with-apxs2=/usr/local/apache/bin/apxs
# 选项指令 --with-iconv-dir 用于 PHP 编译时指定 iconv 在系统里的路径,否则会扫描默认路径。
--with-iconv-dir=/usr/local
--with-freetype-dir 打开对freetype字体库的支持
--with-jpeg-dir 打开对jpeg图片的支持
--with-png-dir 打开对png图片的支持
--with-zlib-dir 打开zlib库的支持,用于http压缩传输
--with-libxml-dir 打开libxml2库的支持
--disable-rpath 关闭额外的运行库文件
--enable-bcmath 打开图片大小调整,用到zabbix监控的时候用到了这个模块
--enable-shmop --enable-sysvsem 这样就使得你的PHP系统可以处理相关的IPC函数了。
--enable-inline-optimization 优化线程
--with-curl 打开curl浏览工具的支持
--with-curlwrappers 运用curl工具打开url流
--enable-mbregex
--enable-fpm 打上PHP-fpm 补丁后才有这个参数,CGI方式安装的启动程序
--enable-mbstring 多字节,字符串的支持
--with-mcrypt mcrypt算法扩展
--with-mhash mhash算法扩展
--with-gd 打开gd库的支持
--enable-gd-native-ttf 支持TrueType字符串函数库
--with-openssl openssl的支持,加密传输https时用到的
--enable-pcntl freeTDS需要用到的,可能是链接mssql 才用到
--enable-sockets 打开 sockets 支持
--with-xmlrpc 打开xml-rpc的c语言
--enable-zip 打开对zip的支持
--enable-ftp 打开ftp的支持
--with-bz2 打开对bz2文件的支持
--without-iconv 关闭iconv函数,字符集间的转换
--with-ttf 打开freetype1.*的支持,可以不加了
--with-xsl 打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件
--with-gettext 打开gnu 的gettext 支持,编码库用到
--with-pear 打开pear命令的支持,PHP扩展用的
--enable-calendar 打开日历扩展功能
--enable-exif 图片的元数据支持
--enable-magic-quotes 魔术引用的支持
--disable-debug 关闭调试模式
--with-mime-magic=/usr/share/file/magic.mime 魔术头文件位置
CGI方式安装才用的参数
--enable-fastCGI 支持fastcgi方式启动PHP
--enable-force-CGI-redirect 重定向方式启动PHP
--with-ncurses 支持ncurses 屏幕绘制以及基于文本终端的图形互动功能的动态库
--with-gmp 应该是支持一种规范
--enable-dbase 建立DBA 作为共享模块
--with-pcre-dir=/usr/local/bin/pcre-config perl的正则库案安装位置
--disable-dmalloc
--with-gdbm dba的gdbm支持
--enable-sigchild
--enable-sysvshm
--enable-zend-multibyte 支持zend的多字节
--enable-wddx
--enable-soap
0x03 安装过程