CentOS 下编译安装PHP(2)

(备注:一定要加这个 apxs - APache eXtenSion tool 用来制作apache的扩展模块DSO,要使用这个工具,安装apache的时候就必须添加enable-so以支持DSO. 如果没有这个的话apache是只会解析静态页面的,第一次编译时没加,怎么配置都不行,第二次加了该选项重新编译以后就都OK了。)

(2)sudo make

(3)sudo make install

12.为了在命令行可以直接使用php命令,编辑 sudo vim /etc/environment,将php的bin目录路径添加进去,我的是/usr/local/php/bin,然后reboot机器

13.为了使Apache支持PHP,解决办法:

(1)进入apache配置目录,执行命令:cd /usr/local/apache2/conf。 编辑文件:sudo vim httpd.conf

(2)查找字符串AddType,并增加

AddType application/x-httpd-php .php .php3 .htm .phtml .php4

AddType application/x-httpd-php-source .phps
添加LoadModule php5_module modules/libphp5.so #如果存在就不必要了

然后重启apache使配置生效

(3)查找字符串DirectoryIndex,并修改为 DirectoryIndex index.html index.php3 index.php default.php

14. 修改php配置.

(1)进入php源码目录,选择php.ini-development复制一份到/usr/local/lib,并改名为php.ini使用vim打开,查找extension_dir,修改为extension_dir = "D:/php/php5/ext",读      者根据自己的目录结构配置,目的是找到和php.ini同目录下的ext文件夹中的扩展库。

(2)查找extension=php_,去掉extension=php_curl.dll,extension=php_gd2.dll,extension=php_mbstring.dll,extension=php_mysql.dll,extension=php_mysqli.dll,extension=php_pdo_mysql.dll,extension=php_xmlrpc.dll前面 的分号。查找short_open_tag = Off把它修改成short_open_tag = On,让其支持短标签(我看注释这个默认是打开的)。

Php.ini配置完成

配置apache的config

15.查找字符串DocumentRoot,可以设置Apache虚拟根目录

16.查找字符串ServerAdmin,并修改成自己的邮箱

17.在apache根文件中增加一个test.php文件,<?php phpinfo(); ?>,然后访问127.0.0.1/test.php,查看结果。

自己用的编译版本

./configure

--profix=/user/local/php

--with-apxs2=/usr/local/apache/bin/apxs

--with-config-file-path=/usr/local/PHP/etc

--with-mysql=/usr/local/mysql

--with-mysqli=/usr/local/mysql/bin/mysql_config

--with-libxml-dir= #libxml目录

--with-zlib-dir= #zlib目录

--enable-sysvsem

--enable-sockets

--enable-pcntl

--enable-mbstring

--enable-mysqlnd

--enable-opcache

--enable-shmop

--enable-zip

--enable-ftp

--enable-gd-native-ttf

--enable-wddx

--enable-soap

--enable-fpm

附录:网上找的php各个版本的编译参数如下。

Fast-CGI:

./configure --prefix=/usr/local/php --enable-fastcgi --enable-force-cgi-redirect --with-config-file-path=/etc --with-zlib --with-mysql --with-xml --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --enable-mbstring

PHP4-Server:

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-config-file-path=/etc --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-xml --enable-mbstring

PHP4-Max:

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --mandir=/usr/share/man --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php/etc --with-openssl=/usr/local/openssl-0.9.7e --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-bz2 --with-inifile --with-hyperwave --enable-xml --enable-track-vars --enable-dba --enable-dbase --enable-filepro --enable-ftp --enable-versioning --enable-memory-limit --enable-calendar --enable-session --enable-sockets --enable-sysmsg --enable-sysvsem --enable-sysvshm --enable-tokenizer --enable-overload --enable-ctype --enable-sigchild --enable-magic-quotes --enable-roxen-zts --enable-fastcgi --enable-dbx --enable-dio --enable-shmop --enable-mbstring

PHP5-Server:

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib-dir --with-bz2 --with-tiff-dir --with-libxml-dir --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf --enable-mbstring --with-mysql=/usr/lib/mysql --with-config-file-path=/etc --disable-ipv6 --enable-gd-native-ttf

PHP5-Standard:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/9d85a1738801da2c65ff0177c4b59e9b.html