linux系统下源码安装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的源码安装就到此结束了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











There are four main error types in PHP: 1.Notice: the slightest, will not interrupt the program, such as accessing undefined variables; 2. Warning: serious than Notice, will not terminate the program, such as containing no files; 3. FatalError: the most serious, will terminate the program, such as calling no function; 4. ParseError: syntax error, will prevent the program from being executed, such as forgetting to add the end tag.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

HTTP request methods include GET, POST, PUT and DELETE, which are used to obtain, submit, update and delete resources respectively. 1. The GET method is used to obtain resources and is suitable for read operations. 2. The POST method is used to submit data and is often used to create new resources. 3. The PUT method is used to update resources and is suitable for complete updates. 4. The DELETE method is used to delete resources and is suitable for deletion operations.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

In PHPOOP, self:: refers to the current class, parent:: refers to the parent class, static:: is used for late static binding. 1.self:: is used for static method and constant calls, but does not support late static binding. 2.parent:: is used for subclasses to call parent class methods, and private methods cannot be accessed. 3.static:: supports late static binding, suitable for inheritance and polymorphism, but may affect the readability of the code.

PHP handles file uploads through the $\_FILES variable. The methods to ensure security include: 1. Check upload errors, 2. Verify file type and size, 3. Prevent file overwriting, 4. Move files to a permanent storage location.
