Heim  >  Artikel  >  Backend-Entwicklung  >  php for Linux之源码编译安装与配置

php for Linux之源码编译安装与配置

WBOY
WBOYOriginal
2016-06-20 12:56:56958Durchsuche

    PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域。PHP 独特的语法混合了C、Java、Perl以及PHP自创的语法。它可以比CGI或者Perl更快速地执行动态网页。用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;PHP还可以执行编译后代码,编译可以达到加密和优化代码运行,使代码运行更快。
 

一、下载

下载地址:http://cn2.php.net/distributions/php-5.6.8.tar.gz

 

二、安装

tar xzvf php-5.6.8.tar.gz

cd php-5.6.8

PHP编译参数:

#!/bin/sh
./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--with-zlib \
--with-gd \
--with-freetype-dir \
--with-png-dir \
--with-jpeg-dir \
--with-mcrypt \
--enable-mbstring \

--enable-fpm \
--disable-debug

 

make  && make install

 

三、配置

cp php.ini-development /usr/local/php/lib/php.ini

 

cd /usr/local/php/etc/

cp php-fpm.conf.default php-fpm.conf

sed -i "s/nobody/apache/g" php-fpm.conf

ln -s /usr/local/php/sbin/php-fpm /usr/sbin/

注:配合nginx使用的,如果是apache可不用配置;

 

四、校验

在apache web程序目录下增加一个info.php文件,内容如下:

phpinfo();

?>

打开浏览器,在地址栏输入:http://ip/info.php ,如果能正常显示出PHP相应信息即可;

 

 

编译PHP出错解决办法:

configure: error: xml2-config not found. Please check your libxml2 installation.

yum -y install libxml2 libxml2-devel
------------------------------------

configure: error: jpeglib.h not found.

yum -y install libjpeg libjpeg-devel
------------------------------------

configure: error: png.h not found.

yum -y install libpng libpng-devel
------------------------------------

configure: error: freetype-config not found.

yum -y install freetype freetype-devel
------------------------------------

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

yum -y install libmcrypt-devel

 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:原生 PHP 模板系统:PlatesNächster Artikel:PHP分页设计