php7如何源碼編譯安裝,編譯安裝php72

本文目錄一覽:

如何在openSUSE42.1下編譯安裝PHP7

首先推薦一篇文章 PHP 7 Release Date Arrived: Will Developers Adopt PHP 7? – PHP Classes blog 。

裡面說到是否會去使用PHP7,就個人而言,我是毫不猶豫地使用的,但是生產環境就不是我說了算,所以只能自己在自己的開發環境里更新PHP的版本。那麼,你呢?

筆者使用的是Linux的openSUSE42.1發行版,Yast裡面還沒有PHP7的安裝包,於是乎只能自己手動編譯安裝了。作為一個PHP開發者,我是非常希望能夠學會編譯安裝PHP7的,之前試過幾次,但是每次安裝都要上網找各種資料,於是乎,這次安裝成功後就想把自己的安裝過程以及遇到的問題記錄下來,方便以後查閱和分享給需要的人。

下載源碼並解壓

進入正題,要編譯安裝PHP7,首先當然要下載PHP7的源碼。你可以到 github 上clone,也可以到 PHP官網 下載。下載後解壓到 /usr/local/src 目錄,並將目錄重命名為php7。進入目錄。

配置編譯參數

生成配置文件

./buildconf

配置

./configure \

–prefix=/usr/local/php7 \

–exec-prefix=/usr/local/php7 \

–bindir=/usr/local/php7/bin \

–sbindir=/usr/local/php7/sbin \

–includedir=/usr/local/php7/include \

–libdir=/usr/local/php7/lib/php \

–mandir=/usr/local/php7/php/man \

–with-config-file-path=/usr/local/php7/etc \

–with-mysql-sock=/var/run/mysql/mysql.sock \

–with-mcrypt=/usr/include \

–with-mhash \

–with-openssl \

–with-mysqli=shared,mysqlnd \

–with-pdo-mysql=shared,mysqlnd \

–with-gd \

–with-iconv \

–with-zlib \

–enable-zip \

–enable-inline-optimization \

–disable-debug \

–disable-rpath \

–enable-shared \

–enable-xml \

–enable-bcmath \

–enable-shmop \

–enable-sysvsem \

–enable-mbregex \

–enable-mbstring \

–enable-ftp \

–enable-gd-native-ttf \

–enable-pcntl \

–enable-sockets \

–with-xmlrpc \

–enable-soap \

–without-pear \

–with-gettext \

–enable-session \

–with-curl \

–with-jpeg-dir \

–with-freetype-dir \

–enable-opcache \

–enable-fpm \

–disable-cgi \

–with-fpm-user=nginx \

–with-fpm-group=nginx \

–without-gdbm \

–disable-fileinfo

參數說明

prefix PHP7安裝的根目錄

with-config-file-path PHP7的配置文件目錄

執行完上面的配置命令後的結果如下圖所示:

執行上面命令的過程中會遇到一些依賴缺少的提示,下面列出我遇到的依賴問題:

錯誤:

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

解決:

zypper install libxml2-devel

錯誤:

configure: WARNING: unrecognized options: –with-mysql

解決:

取消這個選項,這個選項是不存在的

錯誤:

configure: error: jpeglib.h not found.

解決:

zypper install libjpeg-devel

錯誤:

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

解決:

zypper install libmcrypt-devel

錯誤:

checking for recode support… yes

configure: error: Can not find recode.h anywhere under /usr /usr/local /usr /opt.

解決:

zypper install librecode-devel

總的來說,在配置的時候遇到沒有的就打開Yast搜一下,如果有的話就安裝,然後重新編譯看還需要那些,如果在Yast找不到,那就上網找一下Google。

編譯和安裝PHP7

make make install

其中,make之後可以選擇make test。只是一個可選步驟,不執行不知道有什麼問題,不過筆者暫時還沒遇到。

查看安裝成功後的PHP7目錄

編譯安裝成功後,查看PHP7的安裝目錄`ls /usr/local/php7`:

設置PHP7的配置文件

cp /usr/local/src/php7/php.ini-production /usr/local/php7/etc/php.ini

cp /usr/local/src/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf

cp /usr/local/php7/etc/php-fpm.d/ /usr/local/php7/etc/php-fpm.d/

設置環境變量

在/etc/profile 文件的最後一行加上

export PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH

然後執行 source /etc/profile

設置PHP日誌目錄和php-fpm進程文件(php-fpm.sock)目錄

mkdir -p /var/log/php-fpm/ mkdir -p /var/run/php-fpm cd /var/run/ chown -R nginx:nginx php-fpm

將PHP設置為開機啟動

chmod +x /etc/init.d/php-fpm

chkconfig php-fpm on

可以用chkconfig命令查看開機啟動服務列表。

啟動PHP服務

service php-fpm start

通過ps aux | grep ‘php’查看PHP是否啟動成功

至此,PHP7就安裝成功了,你也開始使用PHP7吧!

在網上下載的php網站源碼,如何安裝!求詳細的教程!

一個好的源碼和用心的開發者是不會讓你提出使用問題的,一般都會有詳細的說明文檔進行介紹。

高質量帶說明文檔的源碼獲取方法:(先下載,看源碼需求,再搭建環境很重要):

1、打開百度,搜索“PopMars-專註共享資源 – 免費教程”

2、打開其中名字為 “PopMars-專註共享資源 – 免費教程|Php源碼免費下載|IOS App應用…” 的網站

3、裡面可以找到大量的php源碼

準備:查看源碼裡面的說明文件,源碼運行的基本情況需求。在本機安裝相應的環境即可運行。例如PHP7.0/Mysql 5.5等等。關於本機的環境你可以使用類似xampp的一鍵部署包

Centos7怎麼做安裝PHP7最新版

直接下載PHP7.0.2的安裝包解壓,編譯,安裝:

下載php7,並解壓

$ cd /usr/src/

$ wget

#解壓

$ tar -xzxvf php-7.0.2.tar.gz

$ cd php-7.0.2

解壓完後先不要編譯,請檢查是否安裝了gcc ,沒有的話執行yum install gcc

檢查是否安裝了libxml2 ,沒有的話執行yum install libxml2

檢查是否安裝了libxml2-devel,沒有的話執行yum install libxml2-devel

註:因為改為用nginx了,所以編譯參數中的–with-apxs2=/usr/bin/apxs去掉了,如果要配置apache用,安裝PHP前,請先安裝apache。

centos7系統源碼編譯安裝PHP7.3.5版本

新增系統用戶組和用戶:

下載 PHP7.3.5

[root@localhost ~]# mkdir devdir

[root@localhost ~]# cd devdir/

[root@localhost devdir]# wget

-bash: wget: 未找到命令

[root@localhost devdir]# rpm -qa|grep wget

[root@localhost devdir]# yum -y install wget

[root@localhost devdir]# rpm -qa|grep wget

wget-1.14-18.el7.x86_64

下載PHP7 解壓 編譯

wget -c

編譯參數解釋

–with-fpm-user=webu –with-fpm-group=webg 添加PHP運行用戶和用戶組

配置信息出錯:

下載gcc軟件編譯器 yum install -y gcc

configure: error: libxml2 not found. Please check your libxml2 installation.

下載libzip-1.5.2.tar.gz

解決libzip 和cmake版本問題

重新配置PHP7編譯環境參數

libzip-1.5.2 無法安裝,已經取消了。

提示off_t類型沒有定義 undefind,解決方法:

編譯安裝

測試PHP是否安裝成功

轉載自:

阿里雲默認centos7上怎麼安裝php

首先更新系統軟件/str

$ yum update

安裝nginx/str/str

1.安裝nginx源

$ yum localinstall .安裝nginx

$ yum install nginx

3.啟動nginx

$ service nginx start

Redirecting to /bin/systemctl start nginx.service4.訪問http://你的ip/

如果成功安裝會出來nginx默認的歡迎界面

安裝MySQL5.7.*

/str

1.安裝mysql源/str

$ yum localinstall .安裝mysql

$ yum install mysql-community-server

確認一下mysql的版本,有時可能會提示mysql5.63.安裝mysql的開發包,以後會有用

$ yum install mysql-community-devel

4.啟動mysql

$ service mysqld start

Redirecting to /bin/systemctl start mysqld.service5.查看mysql啟動狀態

$ service mysqld status

出現pid

證明啟動成功

6.獲取mysql默認生成的密碼

$ grep ‘temporary password’ /var/log/mysqld.log2015-12-05T05:41:09.104758Z 1 [Note] A temporary password is generated for root@localhost: %G1Rgns!dD!v/str

加粗的就是生成的密碼

7.換成自己的密碼

$ mysql -uroot -p

Enter password:輸入上面的密碼

成功輸入後進入一下步,這裡你估計會輸入 好幾次才進去8. 更換密碼

mysql ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass4!’;這個密碼一定要足夠複雜,不然會不讓你改,提示密碼不合法;9.退出mysql;

mysql quit;

10.用新密碼再登錄,試一下新密碼

$ mysql -uroot -p

Enter password:輸入你的新密碼

11.確認密碼正確後,退出mysql;

mysql quit;

編譯安裝php7.0.0

/str

/str

1.下載php7源碼包/str

$ cd /root wget -O php7.tar.gz .解壓源碼包/str

$ tar -xvf php7.tar.gz

3./str

$ cd php-7.0.1

4.安裝php依賴包/str

/str

$ yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel5.編譯配置,這一步我們會遇到很多configure error,我們一一解決,基本都是相關軟件開發包沒有安裝導致/str

/str

$ ./configure \

–prefix=/usr/local/php \

–with-config-file-path=/etc \

–enable-fpm \

–with-fpm-user=nginx \

–with-fpm-group=nginx \

–enable-inline-optimization \

–disable-debug \

–disable-rpath \

–enable-shared \

–enable-soap \

–with-libxml-dir \

–with-xmlrpc \

–with-openssl \

–with-mcrypt \

–with-mhash \

–with-pcre-regex \

–with-sqlite3 \

–with-zlib \

–enable-bcmath \

–with-iconv \

–with-bz2 \

–enable-calendar \

–with-curl \

–with-cdb \

–enable-dom \

–enable-exif \

–enable-fileinfo \

–enable-filter \

–with-pcre-dir \

–enable-ftp \

–with-gd \

–with-openssl-dir \

–with-jpeg-dir \

–with-png-dir \

–with-zlib-dir \

–with-freetype-dir \

–enable-gd-native-ttf \

–enable-gd-jis-conv \

–with-gettext \

–with-gmp \

–with-mhash \

–enable-json \

–enable-mbstring \

–enable-mbregex \

–enable-mbregex-backtrack \

–with-libmbfl \

–with-onig \

–enable-pdo \

–with-mysqli=mysqlnd \

–with-pdo-mysql=mysqlnd \

–with-zlib-dir \

–with-pdo-sqlite \

–with-readline \

–enable-session \

–enable-shmop \

–enable-simplexml \

–enable-sockets \

–enable-sysvmsg \

–enable-sysvsem \

–enable-sysvshm \

–enable-wddx \

–with-libxml-dir \

–with-xsl \

–enable-zip \

–enable-mysqlnd-compression-support \

–with-pear \

–enable-opcache

configure error:

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

解決:

$ yum install libxml2 libxml2-devel

2.configure: error: Cannot find OpenSSL’s evp.h

解決:

$ yum install openssl openssl-devel

3.configure: error: Please reinstall the BZip2 distribution解決:

$ yum install bzip2 bzip2-devel

4.configure: error: Please reinstall the libcurl distribution – easy.h should be in curl-dir/include/curl/解決:

$ yum install libcurl libcurl-devel

5.If configure fails try –with-webp-dir=DIR configure: error: jpeglib.h not found.

解決:

$ yum install libjpeg libjpeg-devel

6.If configure fails try –with-webp-dir=DIR

checking for jpeg_read_header in -ljpeg… yesconfigure: error: png.h not found.

解決:

$ yum install libpng libpng-devel

7.If configure fails try –with-webp-dir=DIR

checking for jpeg_read_header in -ljpeg… yeschecking for png_write_image in -lpng… yesIf configure fails try –with-xpm-dir=DIR

configure: error: freetype-config not found.

解決:

$ yum install freetype freetype-devel

8.configure: error: Unable to locate gmp.h解決:

$ yum install gmp gmp-devel

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

解決:

$ yum install libmcrypt libmcrypt-devel

10.configure: error: Please reinstall readline – I cannot find readline.h解決:

$ yum install readline readline-devel

11.configure: error: xslt-config not found. Please reinstall the libxslt = 1.1.0 distribution解決:

$ yum install libxslt libxslt-devel

6.編譯與安裝

$ make make install

這裡要make好久,要耐心一下

7.添加 PHP 命令到環境變量

$ vim /etc/profile

在末尾加入

PATH=$PATH:/usr/local/php/bin

export PATH

要使改動立即生效執行

$ ./etc/profile

$ source /etc/profile

查看環境變量

$ echo $PATH

查看php版本

$ php -v

8.配置php-fpm

$ cp php.ini-production /etc/php.ini

$ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf$ cp /usr/local/php/etc/php-fpm.d/ /usr/local/php/etc/php-fpm.d/ cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm$ chmod +x /etc/init.d/php-fpm

9.啟動php-fpm

$ /etc/init.d/php-fpm start

配置nginx虛擬機,綁定域名/str

1.

/str

$ vim /etc/nginx/conf.d/php7.thinkcmf.com.conf這裡可以把php7.thinkcmf.com.conf改成自己的域名把下面的內容複製到php7.thinkcmf.com.conf里server{

listen 80;

server_name php7.thinkcmf.com;

root /var/www/html/php7.thinkcmf.com; # 該項要修改為你準備存放相關網頁的路徑location / {

index index.php index.html index.htm;

#如果請求既不是一個文件,也不是一個目錄,則執行一下重寫規則if (!-e $request_filename)

{

#地址作為將參數rewrite到index.php上。

rewrite ^/(.*)$ /index.php/$1;

#若是子目錄則使用下面這句,將subdir改成目錄名稱即可。

#rewrite ^/subdir/(.*)$ /subdir/index.php/$1;}

}

#proxy the php scripts to php-fpm

location ~ \.php {

include fastcgi_params;

##pathinfo支持start

#定義變量 $path_info ,用於存放pathinfo信息set $path_info “”;

#定義變量 $real_script_name,用於存放真實地址set $real_script_name $fastcgi_script_name;#如果地址與引號內的正則表達式匹配

if ($fastcgi_script_name ~ “^(.+?\.php)(/.+)$”) {#將文件地址賦值給變量 $real_script_name

set $real_script_name $1;

#將文件地址後的參數賦值給變量 $path_info

set $path_info $2;

}

#配置fastcgi的一些參數

fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;fastcgi_param SCRIPT_NAME $real_script_name;fastcgi_param PATH_INFO $path_info;

###pathinfo支持end

fastcgi_intercept_errors on;

fastcgi_pass 127.0.0.1:9000;

}

}

2.重啟nginx

$ service nginx reload

3.

$ vim /var/www/html/php7.thinkcmf.com/index.php/str

把下面的代碼複製到這個文件 里

?php

phpinfo();

4.查看訪問

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/244217.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2024-12-12 13:01
下一篇 2024-12-12 13:01

相關推薦

  • 雲智直聘 源碼分析

    本文將會對雲智直聘的源碼進行分析,包括前端頁面和後端代碼,幫助讀者了解其架構、技術實現以及對一些常見的問題進行解決。通過本文的閱讀,讀者將會了解到雲智直聘的特點、優勢以及不足之處,…

    編程 2025-04-29
  • Python網站源碼解析

    本文將從多個方面對Python網站源碼進行詳細解析,包括搭建網站、數據處理、安全性等內容。 一、搭建網站 Python是一種高級編程語言,適用於多種領域。它也可以用於搭建網站。最常…

    編程 2025-04-28
  • 源碼是什麼

    源碼是一段計算機程序的原始代碼,它是程序員所編寫的可讀性高、理解性強的文本。在計算機中,源碼是指編寫的程序代碼,這些代碼按照一定規則排列,被計算機識別並執行。 一、源碼的組成 源碼…

    編程 2025-04-27
  • Go源碼閱讀

    Go語言是Google推出的一門靜態類型、編譯型、並髮型、語法簡單的編程語言。它因具有簡潔高效,內置GC等優秀特性,被越來越多的開發者所鍾愛。在這篇文章中,我們將介紹如何從多個方面…

    編程 2025-04-27
  • Python怎麼看源碼

    本文將從以下幾個方面詳細介紹Python如何看源碼,幫助讀者更好地了解Python。 一、查看Python版本 在查看Python源碼之前,首先需要確認Python版本。可以在命令…

    編程 2025-04-27
  • 源碼審計面試題用法介紹

    在進行源碼審計面試時,可能會遇到各種類型的問題,本文將以實例為基礎,從多個方面對源碼審計面試題進行詳細闡述。 一、SQL注入 SQL注入是常見的一種攻擊方式,攻擊者通過在輸入的參數…

    編程 2025-04-27
  • 對3ue源碼的多方面闡述

    一、3ue源碼簡述 3ue是一款基於Vue.js開發的富文本編輯器,支持圖片上傳、粘貼、表格、代碼塊等多種功能,具有輕量、可定製、易擴展的特點。下面我們將從多個方面對3ue源碼進行…

    編程 2025-04-22
  • 全面解析ptable:從使用到源碼分析

    ptable是一個輕量級的DOM操作插件,主要用於表格的操作和功能增強。它的使用非常靈活,支持多種操作方式,包括添加、刪除、修改、排序、篩選等,可以大大提高表格的效率和易用性。 一…

    編程 2025-04-22
  • 深入分析Redis源碼

    一、Redis簡介 Redis是一個開源的內存數據結構存儲系統,可以用作數據庫、緩存、消息隊列等。Redis支持多種數據類型,包括字符串、哈希、列表、集合等。Redis基於C語言進…

    編程 2025-04-12
  • JDK源碼閱讀詳解

    一、jdk源碼閱讀順序 首先,在開始閱讀JDK源碼之前,需要按照正確的順序來閱讀代碼。一般建議按照以下順序進行閱讀: 1. 先從Java SE的API入手,了解它提供了哪些功能,及…

    編程 2025-04-12

發表回復

登錄後才能評論