LAMP--4.php 编译安装
(安装顺序在最后)
把 php 放到最后安装是因为在编译 php 时,需要指定 mysql 和 apache 的路径,如果不先安装好 mysql 和 apache 就没有办法安装 php 。而 apache 和 mysql 的安装顺序就无所谓了。
PHP 官网下载地址:http://www.php.net/downloads.php 。搜狐镜像:http://mirrors.sohu.com/php/php-5.6.10.tar.gz 。
下载 php:
[root@localhost~]#cd/usr/local/src[root@localhostsrc]#wgethttp://mirrors.sohu.com/php/php-5.6.10.tar.gz
解压源码包:
[root@localhostsrc]#tarzxfphp-5.6.10.tar.gz
配置编译参数:
[root@localhostsrc]#cdphp-5.6.10[root@localhostphp-5.6.10]#./configure\--prefix=/usr/local/php\--with-apxs2=/usr/local/apache2/bin/apxs\--with-config-file-path=/usr/local/php/etc\--with-mysql=/usr/local/mysql\--with-libxml-dir\--with-gd\--with-jpeg-dir\--with-png-dir\--with-freetype-dir\--with-iconv-dir\--with-zlib-dir\--with-bz2\--with-openssl\--with-mcrypt\--enable-soap\--enable-gd-native-ttf\--enable-mbstring\--enable-sockets\--enable-exif\--disable-ipv6
遇到错误:
error:xml2-confignotfound.Pleasecheckyourlibxml2installation.#yuminstall-ylibxml2-devel
error:CannotfindOpenSSL's<evp.h>#yuminstall-yopensslopenssl-devel
error:PleasereinstalltheBZip2distribution#yuminstall-ybzip2bzip2-devel
error:png.hnotfound.#yuminstall-ylibpnglibpng-devel
error:freetype.hnotfound.#yuminstall-yfreetypefreetype-devel
error:freetype-confignotfound.#yuminstall-yfreetype-devel
error:mcrypt.hnotfound.Pleasereinstalllibmcrypt.#yuminstall-ylibmcrypt-devel
编译
#make
[root@localhostphp-5.6.10]#makecrypt-lxml2-lz-lm-lxml2-lz-lm-lxml2-lz-lm-lcrypt-osapi/cgi/php-cgiGeneratingphar.phpGeneratingphar.pharPEARpackagePHP_Archivenotinstalled:generatedpharwillrequirePHP'spharextensionbeenabled.pharcommand.incdirectorytreeiterator.incclicommand.incdirectorygraphiterator.incinvertedregexiterator.incphar.incBuildcomplete.Don'tforgettorun'maketest'.[root@localhostphp-5.6.10]#echo$?0
安装
# make install
[root@localhostphp-5.6.10]#makeinstallInstallingPEARenvironment:/usr/local/php/lib/php/[PEAR]Archive_Tar-installed:1.3.12[PEAR]Console_Getopt-installed:1.3.1[PEAR]Structures_Graph-installed:1.0.4[PEAR]XML_Util-installed:1.2.3[PEAR]PEAR-installed:1.9.5WrotePEARsystemconfigfileat:/usr/local/php/etc/pear.confYoumaywanttoadd:/usr/local/php/lib/phptoyourphp.iniinclude_path/usr/local/src/php-5.6.10/build/shtoolinstall-cext/phar/phar.phar/usr/local/php/binln-s-fphar.phar/usr/local/php/bin/pharInstallingPDOheaders:/usr/local/php/include/php/ext/pdo/[root@localhostphp-5.6.10]#echo$?0
拷贝 php 配置文件
[root@localhostphp-5.6.10]#cpphp.ini-production/usr/local/php/etc/php.ini
修改 apache 配置文件
[root@localhostphp-5.6.10]#vim/usr/local/apache2/conf/httpd.conf
找到:
<Directory/>OptionsFollowSymLinksAllowOverrideNoneOrderdeny,allowDenyfromall</Directory>改为:<Directory/>OptionsFollowSymLinksAllowOverrideNoneOrderdeny,allowAllowfromall</Directory>
说明:如果不修改这个地方,我们访问网站会禁止访问,显示403。
然后找到:
AddTypeapplication/x-gzip.gz.tgz
在该行下面添加:
AddTypeapplication/x-gzip.gz.tgzAddTypeapplication/x-httpd-php.php
说明:要想支持 php 脚本解析,必须要加上对应的类型。
再找到:
<IfModuledir_module>DirectoryIndexindex.html</IfModule>
改为:
<IfModuledir_module>DirectoryIndexindex.htmlindex.htmindex.php</IfModule>
说明:增加对 php 的索引,如果一个站点默认页为 index.php,那么就得加上这个 index.php 的支持。
再找到:
#ServerNamewww.example.com:80
修改为:
ServerNamelocalhost:80
如果不去掉#,则启动 apache 时,会有警告信息“httpd:Could not reliably determine the server's fully qualified domain name,using localhost.localdomain for ServerName”,看起来像是错误,其实没有影响。
查看配置文件是否有问题:
[root@localhostphp-5.6.10]#/usr/local/apache2/bin/apachectl-tSyntaxOK
启动服务:
[root@localhostphp-5.6.10]#/usr/local/apache2/bin/apachectlstart
检查是否正常启动:
[root@localhostphp-5.6.10]#psaux|grephttpdroot79980.00.71962607284?Ss23:450:00/usr/local/apache2/bin/httpd-kstartdaemon79990.00.41963964920?S23:450:00/usr/local/apache2/bin/httpd-kstartdaemon80000.00.41963964920?S23:450:00/usr/local/apache2/bin/httpd-kstartdaemon80010.00.41963964920?S23:450:00/usr/local/apache2/bin/httpd-kstartdaemon80020.00.41963964920?S23:450:00/usr/local/apache2/bin/httpd-kstartdaemon80030.00.41963964920?S23:450:00/usr/local/apache2/bin/httpd-kstartroot80050.00.0103316900pts/1S+23:450:00grephttpd
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。