検索
ホームページphp教程php手册Linux PHPのコンパイルとインストール

1. PHP インストール パッケージをダウンロードします

http://cn2.php.net/get/php-5.5.36.tar.gz/from/this/mirror

デフォルトでは、Nginx と PHP の間に接続はありません。 Apache PHP はコンパイル後にモジュール ファイルを生成しますが、Nginx PHP は実行可能ファイルを生成するために PHP を必要とするため、Nginx と PHP を統合するには fastcgi テクノロジを使用する必要があります。これはインストール時にのみ有効にする必要があります。今回はFastCGIを使用するだけでなく、PHP-FPMのようなものを使用してPHPをインストールしました。 端的に言えば、PHP-FPMはPHPのプラグインとして存在します。 PHP をインストールするには、PHP-FPM をパッチの形式で PHP にインストールする必要があります。また、PHP は PHP-FPM のバージョンと一致している必要があります。これは必須です。

2. インストール

[root@localhost src]# <span style="color: #0000ff;">tar</span> -zxvf php-<span style="color: #800080;">5.5</span>.<span style="color: #800080;">36</span>.<span style="color: #0000ff;">tar</span><span style="color: #000000;">.gz 
[root@localhost src]# cd php</span>-<span style="color: #800080;">5.5</span>.<span style="color: #800080;">36</span><span style="color: #000000;">
[root@localhost php</span>-<span style="color: #800080;">5.5</span>.<span style="color: #800080;">36</span>]# ./configure   --prefix=/usr/local/php   --with-config-<span style="color: #0000ff;">file</span>-path=/usr/local/php/etc  --with-png-<span style="color: #0000ff;">dir</span>=/usr/local/libpng   --with-jpeg-<span style="color: #0000ff;">dir</span>=/usr/local/jpeg   --with-freetype-<span style="color: #0000ff;">dir</span>=/usr/local/freetype   --with-zlib-<span style="color: #0000ff;">dir</span>=/usr/local/zlib   --with-mcrypt=/usr/local/libmcrypt   --with-libxml-<span style="color: #0000ff;">dir</span>=/usr/local/libxml2/   --with-iconv-<span style="color: #0000ff;">dir</span>=/usr/local/libiconv   --enable-libxml   --enable-xml   --enable-bcmath   --enable-shmop   --enable-sysvsem   --enable-inline-optimization   --enable-opcache   --enable-mbregex   --enable-fpm   --enable-mbstring=all   --enable-gd-native-ttf   --with-openssl   --enable-pcntl   --enable-sockets   --with-xmlrpc   --enable-<span style="color: #0000ff;">zip</span>   --enable-soap   --without-pear   --with-gettext   --enable-session   --with-curl   --enable-ctype   --enable-shared   --with-<span style="color: #000000;">gd  
[root@localhost php</span>-<span style="color: #800080;">5.5</span>.<span style="color: #800080;">36</span>]<span style="color: #0000ff;">make</span><span style="color: #000000;"> clean
[root@localhost php</span>-<span style="color: #800080;">5.5</span>.<span style="color: #800080;">36</span>]<span style="color: #0000ff;">make</span><span style="color: #000000;"> 
[root@localhost php</span>-<span style="color: #800080;">5.5</span>.<span style="color: #800080;">36</span>]<span style="color: #0000ff;">make</span> <span style="color: #0000ff;">install</span>

3. ソースコード内の php.ini-development を php.ini

の検索パスにコピーします。
[root@localhost php-<span style="color: #800080;">5.5</span>.<span style="color: #800080;">36</span>]# <span style="color: #0000ff;">cp</span> php.ini-development /usr/local/php/etc/php.ini

4. php-fpm 構成ファイルをコピーし、php-fpm.conf という名前を付けます (パス /usr/local/php/etc の下)

[root@localhost etc]# <span style="color: #0000ff;">cp</span> php-fpm.conf.default php-fpm.conf

5. php-fpm を起動します

[root@localhost /]# /usr/local/php/sbin/php-<span style="color: #000000;">fpm 
[root@localhost </span>/]# <span style="color: #0000ff;">ps</span> aux | <span style="color: #0000ff;">grep</span> php-<span style="color: #000000;">fpm
root </span><span style="color: #800080;">7790</span> <span style="color: #800080;">0.0</span> <span style="color: #800080;">0.2</span> <span style="color: #800080;">27300</span> <span style="color: #800080;">3048</span> ? Ss <span style="color: #800080;">22</span>:<span style="color: #800080;">23</span> <span style="color: #800080;">0</span>:<span style="color: #800080;">00</span> php-fpm: master process (/usr/local/php/etc/php-<span style="color: #000000;">fpm.conf)
nobody </span><span style="color: #800080;">7791</span> <span style="color: #800080;">0.0</span> <span style="color: #800080;">0.4</span> <span style="color: #800080;">27300</span> <span style="color: #800080;">4380</span> ? S <span style="color: #800080;">22</span>:<span style="color: #800080;">23</span> <span style="color: #800080;">0</span>:<span style="color: #800080;">00</span> php-<span style="color: #000000;">fpm: pool www 
nobody </span><span style="color: #800080;">7792</span> <span style="color: #800080;">0.0</span> <span style="color: #800080;">0.2</span> <span style="color: #800080;">27300</span> <span style="color: #800080;">2524</span> ? S <span style="color: #800080;">22</span>:<span style="color: #800080;">23</span> <span style="color: #800080;">0</span>:<span style="color: #800080;">00</span> php-<span style="color: #000000;">fpm: pool www 
root </span><span style="color: #800080;">8124</span> <span style="color: #800080;">0.0</span> <span style="color: #800080;">0.0</span> <span style="color: #800080;">4420</span> <span style="color: #800080;">756</span> pts/<span style="color: #800080;">3</span> S+ <span style="color: #800080;">23</span>:<span style="color: #800080;">19</span> <span style="color: #800080;">0</span>:<span style="color: #800080;">00</span> <span style="color: #0000ff;">grep</span> php-fpm

添付ファイル:

1. PHP 構成ファイルのパスを見つけます

[root@localhost /]# /usr/local/php/bin/php --<span style="color: #000000;">ini
Configuration File (php.ini) Path: </span>/usr/local/php/<span style="color: #000000;">etc
Loaded Configuration File:         </span>/usr/local/php/etc/<span style="color: #000000;">php.ini
Scan </span><span style="color: #0000ff;">for</span> additional .ini files <span style="color: #0000ff;">in</span><span style="color: #000000;">: (none)
Additional .ini files parsed:      (none)</span>

2. php-fpm を閉じます

[root@localhost /]# <span style="color: #0000ff;">killall</span> php-fpm

3. PHP コア構成オプションのリスト

http://php.net/manual/zh/configure.about.php

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境