012-LAMP_compiling_installation_LAMP_components
安装版本
编译安装httpd-2.4
[http://blog.csdn.net/u010796631/article/details/50531726](http://blog.csdn.net/u010796631/article/details/50531726)
编译安装php-5.4
二进制安装mariadb-5.5
[http://blog.csdn.net/u010796631/article/details/50534230](http://blog.csdn.net/u010796631/article/details/50534230)
注意:任何一个程序包被编译操作依赖到时,需要安装此程序包的开发版本
注意:任何一个程序包被编译操作依赖到时,需要安装此程序包的开发版本
注意:任何一个程序包被编译操作依赖到时,需要安装此程序包的开发版本
重要的事情说三遍^_^,提示哪种包没有就安装它的devel版本
注意:php作为httpd的一个模块安装的时候,httpd的MPM机制不可以随意更改因为php不能兼容
编译安装php(作为httpd的模块)
1 下载php-5.4.0并解压之
[root@husa ~]# cd /tmp
[root@husa tmp]# ls
php-5.4.40.tar.bz2 systemd-private-Wypjfj systemd-private-XX9BAH yum_save_tx.2016-01-13.09-09.HtoCbo.yumtx
[root@husa tmp]# tar xjf php-5.4.40.tar.bz2
[root@husa tmp]# ls
php-5.4.40 systemd-private-Wypjfj yum_save_tx.2016-01-13.09-09.HtoCbo.yumtx
php-5.4.40.tar.bz2 systemd-private-XX9BAH
2 ./configure
[root@husa php-5.4.40]# ./configure --prefix=/usr/local/php --with-openssl --enable-mbstring --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2
...
configure: error: xml2-config not found. Please check your libxml2 installation.
缺少xml2-config就安装libxml2-devel等
按照提示安装各种*-devel包之后出现如下结果
Thank you for using PHP.
...
注意:如果提供httpd和mysql的安装路径,则使用如下配置;对于rpm包安装的mysql和httpd则直接使用/usr作为他们的路径
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache24/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2
其中
–with-apxs2=FILE Build shared Apache 2.0 Handler module. FILE is the optional
pathname to the Apache apxs tool apxs #表示编译为apache的模块!如果rpm安装了apache,那么php默认就已经作为了apache的模块了,不需要指定了。
–with-mssql=DIR Include MSSQL-DB support. DIR is the FreeTDS home
directory /usr/local/freetds
–with-mysql=DIR Include MySQL support. DIR is the MySQL base
directory, if no DIR is passed or the value is
mysqlnd the MySQL native driver will be used
–with-mysqli=FILE Include MySQLi support. FILE is the path
to mysql_config. If no value or mysqlnd is passed
as FILE, the MySQL native driver will be used
可能依赖的包pcre-devel,apr-devel,apr-util-devel,openssl-devel
3 编译安装
[root@husa php-5.4.40]# make -j 2 && make install
Build complete.
Don't forget to run 'make test'.
Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/php/man/man1/
Installing PHP CGI binary: /usr/local/php/bin/
Installing PHP CGI man page: /usr/local/php/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
...
httpd.conf配置并重启httpd
如果php被编译为httpd的模块,则在httpd.conf文件中配置httpd能够自动识别.php文件
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-http-php http .php
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
注意,此处的编译安装php,适用于把php作为apache的模块;在这里,httpd也使用编译安装,mysql使用二进制方式安装。上面由于没有编译安装httpd,所以就没有指定把php作为httpd的模块编译安装…