編譯安裝 php 5.4.11

来源:http://www.cnblogs.com/xiongmaolinux/archive/2016/04/01/5345210.html
-Advertisement-
Play Games

第一步 先下載 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 ...


第一步 先下載 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。再次編譯就能通過了。 


解決地址:http://lepingbeta.com/archives/255


如果提示 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.(我使用的該源來自於http://ishare.iask.sina.com.cn/f/9769001.html)

錯誤三:
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
可見PHP源碼安裝之前需要先安裝這些依賴,詳細可見http://forum.ubuntu.org.cn/viewtopic.php?f=88&t=231159
如上錯誤都解決之後,再次./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(); ?>

保存

然後測試下即可


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • Too many open files解決辦法 1,修改/etc/security/limits.conf文件內容 使用sudo vim /etc/security/limits.conf命令進入/etc/security/limits.conf文件中。 在/etc/security/limits. ...
  • 今天突然想要在linux上播放音樂,但是打開之後發現缺少瞭解碼器 於是去網上找瞭解決的方法,說得天花亂墜,不過有個帖子給出了很簡單的方法。 以下內容轉載於網路 上面提示沒有安裝解碼器,這是因為版權問題軟體不自帶解碼器 解決的方法很簡單,就是安裝第三方源 32位的系統第三方源:rpm -ivh htt ...
  • 讓.NET應用程式在linux上運行,目前通用的做法就是在Linux上安裝mono,然後通過”mono your.exe“命令運行這個程式。 這種運行.net程式的辦法有兩個弱點,一個是需要客戶機安裝mono,二個是 ”mono xx.exe“ 這種命令行總讓人感到有點不太專業的味道。 那麼,有沒有 ...
  • 實驗4 外部中斷實驗 一、實驗目的 理解中斷的基本概念。 掌握STM32的中斷源及中斷優先順序。 掌握STM32外部中斷技術的基本使用方法。 掌握STM32中斷處理程式的編程方法。 二、實驗內容 硬體設計原理圖如下圖1所示:LED的連接在上一節已經介紹過了,在STM32開發板上的按鍵KEY0是接在PE ...
  • Office 2016 VOL版 http://blog.sina.com.cn/s/blog_470614a90102vtmc.html 專業版合集: magnet:?xt=urn:btih:772912C80F19B7DC145C88810DD8FCD8031D4478 標準版合集: magne ...
  • 一 命令解釋: dd:用指定大小的塊拷貝一個文件,併在拷貝的同時進行指定的轉換。 註意:指定數字的地方若以下列字元結尾,則乘以相應的數字:b=512;c=1;k=1024;w=2 參數註釋: ascii:轉換ebcdic為ascii ebcdic:轉換ascii為ebcdic ibm:轉換ascii ...
  • a.c #include #include "a.h" int main() { printf("hello world\n"); printf("A= %d\n",A); test_fun(); return 0; } a.h #define A 1 b.c #include int test_f... ...
  • 1. Question Description: the screen of the vmware looks small . 2. Solution: 2.1 look the size of screen resolution of my own computer. 2.2 change the ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...