阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

编译安装 php 5.4.11

116次阅读
没有评论

共计 5716 个字符,预计需要花费 15 分钟才能阅读完成。

第一步 先下载 tzr.gz 的 php 源码包
然后 tar zxvf  php-5.4.11.tar.gz
然后 cd php-5.4.11

然后复制如下编译代码 
./configure \
–prefix=/usr/local/php \
–enable-zip \
–with-xsl \
–enable-zend-multibyte \
–enable-sockets \
–enable-soap \
–with-pdo-mysql=mysqlnd \
–with-mysql=mysqlnd \
–enable-pcntl \
–with-mcrypt \
–enable-fpm \
–enable-shmop \
–with-readline \
–enable-mbstring \
–with-mhash \
–enable-gd-native-ttf \
–with-freetype-dir \
--with-t1lib=/usr/local/share/t1lib \
–with-png-dir \
–with-jpeg-dir \
–with-gd \
–with-openssl-dir \
–enable-ftp \
–enable-exif \
–enable-dba \
–with-bz2 \
–enable-bcmath \
–with-curl

!!!

编译 PHP5 缺 t1lib 包解决方案

遇到这个报错:
configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.
以下是解决步骤:
1. 下载 t1lib-5.1.2.tar.gz
2. 解决依赖关系:apt-get build-dep t1lib
3. 安装:./configure & make without_doc & make install
4. 编译 php5 时在 ./configure 后加上 --with-t1lib=/usr/local/share/t1lib。再次编译就能通过了。

如果提示 configure: error: Please reinstall readline – I cannot find readline.h 错误!

安装 sudo apt-get install  libreadline-dev

然后再编译一下 就没错误了!

‘./configure’‘–prefix=/usr/local/php’‘–with-config-file-path=/etc’‘–with-mysql=/usr/local/mysql’‘–with-mysqli=/usr/local/mysql/bin/mysql_config’‘–with-iconv-dir=/usr/local’‘–with-freetype-dir’‘–with-jpeg-dir’‘–with-png-dir’‘–with-zlib’‘–with-libxml-dir=/usr’‘–enable-xml’‘–disable-rpath’‘–enable-safe-mode’‘–enable-bcmath’‘–enable-shmop’‘–enable-sysvsem’‘–enable-inline-optimization’‘–with-curl’‘–with-curlwrappers’‘–enable-mbregex’‘–enable-fpm’‘–enable-mbstring’‘–with-mcrypt’‘–with-gd’‘–enable-gd-native-ttf’‘–with-openssl’‘–with-mhash’‘–enable-pcntl’‘–enable-sockets’‘–with-xmlrpc’‘–enable-zip’‘–enable-soap’
出现得错误如下:

报错:configure: error: png.h not found.
解决办法:
apt-get -y install libpng12-dev

错误一:
configure: error: xml2-config not found. Please check your libxml2 installation.
而我已经安装过了 libxml2, 但是还是有这个提示:
解决办法:
# sudo apt-get install libxml2-dev

错误二:
configure: error: Please reinstall the BZip2 distribution
而我也已经安装了 bzip2,网上找到得解决方案都是需要安装 bzip2-dev,可是 11.10 里面没有这个库。
解决办法:在网上找到 bzip2-1.0.5.tar.gz,解压,直接 make ,sudo make install.

错误三:
configure: error: Please reinstall the libcurl distribution -easy.h should be in /include/curl/
解决办法:
# sudo apt-get install libcurl4-gnutls-dev

错误四:
configure: error: jpeglib.h not found.
解决办法:
# sudo apt-get install libjpeg-dev

错误五:
configure: error: png.h not found.
解决办法:
# sudo apt-get install libpng-dev

错误六:
configure: error: libXpm.(a|so) not found.
解决办法:
# sudo apt-get install libxpm-dev

错误七:
configure: error: freetype.h not found.
解决办法:
# sudo apt-get install libfreetype6-dev

错误八:
configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.
解决办法:
# sudo apt-get install libt1-dev

错误九:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决办法:
# sudo apt-get install libmcrypt-dev

错误十:
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!
解决办法:
# sudo apt-get install libmysql++-dev

错误十一:
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
解决办法:
# sudo apt-get install libxslt1-dev
如上错误都解决之后,再次./config…. 没有错误之后,
# make
# sudo make install

将编译安装的 PHP 输入到环境变量中
编译后 将其 PHP 路径 输入到环境变量中,要不然系统执行 PHP 的文件时 不知道 PHP 安装了没有 所以要指定一个目录 让系统知道去那里能找到编译安装的 PHP

Linux CentOS 系统上安装完 php 和 MySQL 后,为了使用方便,需要将 php 和 mysql 命令加到系统命令中,如果在没有添加到环境变量之前,执行“php -v”命令查看当前 php 版本信息时时,则会提示命令不存在的错误,下面我们详细介绍一下在 linux 下将 php 和 mysql 加入到环境变量中的方法(假 设 php 和 mysql 分别安装在 /usr/local/webserver/php/ 和 /usr/local/webserver/mysql/ 中)。

方法一:直接运行命令 export PATH=$PATH:/usr/local/webserver/php/bin 和 export PATH=$PATH:/usr/local/webserver/mysql/bin

使用这种方法,只会对当前会话有效,也就是说每当登出或注销系统以后,PATH 设置就会失效,只是临时生效。

方法二:执行 vi ~/.bash_profile 修改文件中 PATH 一行,将 /usr/local/webserver/php/bin 和 /usr/local/webserver/mysql/bin 加入到 PATH=$PATH:$HOME/bin 一行之后

这种方法只对当前登录用户生效

方法三:修改 /etc/profile 文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码
PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin
export PATH

或者   export PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin

最后:执行 命令 source /etc/profile 或 执行点命令 ./profile 使其修改生效,执行完可通过 echo $PATH 命令查看是否添加成功。

启动 php 服务的时候 

sudo /usr/local/php/sbin/php-fpm 

会出现

错误:

[10-Apr-2013 18:12:02] NOTICE: PHP message: PHP Deprecated:  Comments starting with ‘#’ are deprecated in /usr/local/php/lib/php.ini on line 1874 in Unknown on line 0
[10-Apr-2013 18:12:02] ERROR: failed to open configuration file ‘/usr/local/php/etc/php-fpm.conf’: No such file or directory (2)
[10-Apr-2013 18:12:02] ERROR: failed to load configuration file ‘/usr/local/php/etc/php-fpm.conf’
[10-Apr-2013 18:12:02] ERROR: FPM initialization failed

这时候 是 php 找不到 配置文件 php-fpm.conf

解决办法:
cd /usr/local/php/etc/ 

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

再启动
sudo /usr/local/php/sbin/php-fpm

出现错误:

[10-Apr-2013 18:14:09] NOTICE: PHP message: PHP Deprecated:  Comments starting with ‘#’ are deprecated in /usr/local/php/lib/php.ini on line 1874 in Unknown on line 0
[10-Apr-2013 18:14:09] ERROR: [pool www] cannot get gid for group ‘nobody’
[10-Apr-2013 18:14:09] ERROR: FPM initialization failed

原因是  [pool www] cannot get gid for group ‘nobody’  没有这个用户  我之前编译的时候 指定用户 是 www  所以进入 vi  /usr/local/php/etc/php-fpm.conf   
修改 

user = www
group = www
 
然后 测试 PHP 是否安装成功

在网站跟目录下 写入 一个测试 PHP 是否安装成功的 
我的 nginx 根目录是 /usr/local/nginx/html/

sudo vi   index.php

  <?php phpinfo(); ?>

保存

然后测试下即可

深入理解 PHP 中的 ini 配置 http://www.linuxidc.com/Linux/2016-02/128442.htm

剖析 PHP 脚本的超时机制 http://www.linuxidc.com/Linux/2016-02/128441.htm

Ubuntu 14.04 下搭建 PHP 开发环境 PDF  http://www.linuxidc.com/Linux/2016-02/128330.htm

PHP 7 革新与性能优化 http://www.linuxidc.com/Linux/2015-09/123136.htm

PHP 7,你值得拥有  http://www.linuxidc.com/Linux/2015-06/118847.htm 

在 CentOS 7.x / Fedora 21 上面体验 PHP 7.0  http://www.linuxidc.com/Linux/2015-05/117960.htm 

CentOS 6.3 安装 LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm 

在部署 LNMP 的时候遇到 Nginx 启动失败的 2 个问题 http://www.linuxidc.com/Linux/2013-03/81120.htm 

Ubuntu 安装 Nginx php5-fpm MySQL(LNMP 环境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm 

《细说 PHP》高清扫描 PDF+ 光盘源码 + 全套教学视频 http://www.linuxidc.com/Linux/2014-03/97536.htm 

CentOS 6 中配置 PHP 的 LNMP 的开发环境  http://www.linuxidc.com/Linux/2013-12/93869.htm 

PHP 的详细介绍:请点这里
PHP 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-04/129773.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计5716字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中