search
HomeBackend DevelopmentPHP Tutoriallinux系统下源码安装PHP5.6

linux系统下源码安装PHP5.6




从php5.4开始,需要自己下载安装libXpm-dev了,但是由于包的依赖性原因,我就选择了yum方式来进行安装,通过网络yum源直接下载并进行安装了


下载php以及相关的库文件(百度网盘:http::/pan.baidu.com/s/1bnL31c7)

gd库以及php功能特性扩展库文件

libgd-2.1.1.tar.gz        gd库文件(使php支持以下功能)    

jpegsrc.v7.tar.gz         jpeg库文件(使php支持jpeg格式图片)

zlib-1.2.7.tar.gz         数据压缩函数库(使php支持数据压缩功能)      

freetype-2.6.tar.gz       freetype库文件(使php支持多种字体格式文件

libpng-1.2.56.tar.gz      libpng库文件(使php支持png格式图片)



安装libXpm

yum -y install libXpm安装完后libXpm配置文件下这个目录/usr/lib64/下


安装autoconf-2.69.tar.gzauto

[root@end LAMP-php]# tar -zxvf autoconf-2.69.tar.gz [root@end LAMP-php]# cd autoconf-2.69[root@end autoconf-2.69]# ./configure [root@end autoconf-2.69]# make ; make install


安装 libxml2-2.7.8.tar.gz

[root@end LAMP-php]# tar -zxvf libxml2-2.7.8.tar.gz [root@end LAMP-php]# cd libxml2-2.7.8     将$RM "cfgfile"这行用#注释[root@end libxml2-2.7.8]# ./configure --prefix=/usr/local/libxml2[root@end libxml2-2.7.8]# make ; make install


安装libmcrypt-2.5.8.tar.gz

[root@end LAMP-php]# tar -zxvf libmcrypt-2.5.8.tar.gz [root@end LAMP-php]# cd libmcrypt-2.5.8[root@end libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt[root@end libmcrypt-2.5.8]# make ; make install


安装zlib-1.2.7.tar.gz

[root@end LAMP-php]# tar -zxvf zlib-1.2.7.tar.gz [root@end LAMP-php]# cd zlib-1.2.7[root@end zlib-1.2.7]# ./configure --prefix=/usr/local/zlib[root@end zlib-1.2.7]# make ; make install


安装 libpng-1.2.56.tar.gz

[root@end LAMP-php]# tar -zxvf libpng-1.2.56.tar.gz[root@end LAMP-php]# cd libpng-1.2.56[root@end libpng-1.2.56]# ./configure --prefix=/usr/local/libpng[root@end libpng-1.2.56]# make ; make install


安装jpegsrc.v7.tar.gz

[root@end LAMP-php]# tar -zxvf jpegsrc.v7.tar.gz  [root@end LAMP-php]# cd jpeg-7/[root@end jpeg-7]# mkdir /usr/local/jpeg6                    建立jpeg6软件安装目录[root@end jpeg-7]# mkdir /usr/local/jpeg6/bin                建立存放命令的目录[root@end jpeg-7]# mkdir /usr/local/jpeg6/lib                创建jpeg6库文件所在目录[root@end jpeg-7]# mkdir /usr/local/jpeg6/include            建立存放头文件目录[root@end jpeg-7]# mkdir -p /usr/local/jpeg6/man/man1        建立存放手册目录[root@end jpeg-7]# ./configure \> --prefix=/usr/local/jpeg6/ \  > --enable-shared \    建立共享库使用的GNUd libtool> --enable-static      建立静态库使用的GNUlibtool./configure --prefix=/usr/local/jpeg6/ --enable-shared  --enable-static[root@end jpeg-7]# make ; make install



安装freetype-2.6.tar.gz

[root@end LAMP-php]# tar -zxvf freetype-2.6.tar.gz [root@end LAMP-php]# cd freetype-2.6[root@end freetype-2.6]# ./configure --prefix=/usr/local/freetype[root@end freetype-2.6]# make ; make install


安装gd-2.0.32.tar.gz

[root@end LAMP-php]# tar -zxvf gd-2.0.32.tar.gz[root@end LAMP-php]# cd gd-2.0.32[root@end gd-2.0.32]# ./configure \  进入vim gd_png.c 将16行改为#include "/usr/local/libpng/include/png.h"> --prefix=/usr/local/gd2/ \                       gd库文件安装目录> --with-zlib=/usr/local/zlib/ \                   指定zlib安装路径> --with-jpeg=/usr/local/jpeg6/ \                  指定jpeg6安装路径> --with-png=/usr/local/libpng/ \                  指定libpng安装路径> --with-freetype=/usr/local/freetype/             指定freetype安装路径./configure --prefix=/usr/local/gd2/ --with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype[root@end gd-2.0.32]# make ; make install




安装PHP

[root@end AMP]# tar -zxvf php-5.6.9.tar.gz[root@end AMP]# cd php-5.6.9[root@end php-5.6.9]# ./configure \                        执行当前目录下软件自带的配置命令> --prefix=/usr/local/php \                                设置PHP5的安装路径> --with-config-file-path=/usr/local/php/etc \             指定PHP5配置文件存入的路径> --with-apxs2=/usr/local/apache2/bin/apxs \               指定PHP查找Apache2的位置> --with-mysql=/usr/local/mysql/ \                         指定mysql的安装目录> --with-libxml-dir=/usr/local/libxml2/ \                  指定php放置libxml2库的位置> --with-png-dir=/usr/local/libpng/ \                      指定php放置libpng库的位置> --with-jpeg-dir=/usr/local/jpeg6/ \                      指定php放置jpeg库的位置> --with-freetype-dir=/usr/local/freetype/ \               指定php放置freetype库的位置> --with-gd=/usr/local/gd2/ \                              指定php放置gd库的位置> --with-zlib-dir=/usr/local/zlib/ \                       指定php放置zlib库的位置> --with-mcrypt=/usr/local/libmcrypt/ \                    指定php放置libcrypt库的位置> --with-mysql=/usr/local/mysql/bin/mysql_config  \        变量激活新增加mysqli功能> --enable-soap \                                          变量激活soap和web services支持> --enable-mbstring=all \                                  使多字节字符串支持> --enable-sockets                                         变量激活socket通信特性[root@end php-5.6.9]# ./configure  --prefix=/usr/local/php  --with-config-file-path=/usr/local/php/etc  --with-apxs2=/usr/local/apache2/bin/apxs  --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg6 --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd2 --with-zlib-dir=/usr/local/zlib --with-mcrypt=/usr/local/libmcrypt  --with-xpm-dir=/usr/lib64/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets [root@end php-5.6.9]# make ; make install



配置php

cp php.ini-development /usr/local/php/etc/php.ini  创建php配置文件


配置Apache

进入Apache主配置文件/etc/httpd/http.conf中加入Addtype application/x-httpd-php .php .phtmlAddType application/x-httpd-php .php .php4 .php5




创建php测试文件


cp php.ini-development /usr/local/php/etc/php.ini  创建php配置文件创建kdir /usr/local/apache2/htdocs/test.php进入test.php编辑<?php        phpinfo();?>


重启Apache,使设置生效

[root@localhost php-5.6.9]# service httpd restart


打开网页,输入网址http://ip:test.php

看到php的版本信息网页,表示测试成功!!!



至此php的源码安装就到此结束了








Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

Simple Guide: Sending Email with PHP ScriptSimple Guide: Sending Email with PHP ScriptMay 12, 2025 am 12:02 AM

PHPisusedforsendingemailsduetoitsbuilt-inmail()functionandsupportivelibrarieslikePHPMailerandSwiftMailer.1)Usethemail()functionforbasicemails,butithaslimitations.2)EmployPHPMailerforadvancedfeatureslikeHTMLemailsandattachments.3)Improvedeliverability

PHP Performance: Identifying and Fixing BottlenecksPHP Performance: Identifying and Fixing BottlenecksMay 11, 2025 am 12:13 AM

PHP performance bottlenecks can be solved through the following steps: 1) Use Xdebug or Blackfire for performance analysis to find out the problem; 2) Optimize database queries and use caches, such as APCu; 3) Use efficient functions such as array_filter to optimize array operations; 4) Configure OPcache for bytecode cache; 5) Optimize the front-end, such as reducing HTTP requests and optimizing pictures; 6) Continuously monitor and optimize performance. Through these methods, the performance of PHP applications can be significantly improved.

Dependency Injection for PHP: a quick summaryDependency Injection for PHP: a quick summaryMay 11, 2025 am 12:09 AM

DependencyInjection(DI)inPHPisadesignpatternthatmanagesandreducesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itallowspassingdependencieslikedatabaseconnectionstoclassesasparameters,facilitatingeasiertestingandscalability.

Increase PHP Performance: Caching Strategies & TechniquesIncrease PHP Performance: Caching Strategies & TechniquesMay 11, 2025 am 12:08 AM

CachingimprovesPHPperformancebystoringresultsofcomputationsorqueriesforquickretrieval,reducingserverloadandenhancingresponsetimes.Effectivestrategiesinclude:1)Opcodecaching,whichstorescompiledPHPscriptsinmemorytoskipcompilation;2)DatacachingusingMemc

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.