搜尋
首頁後端開發PHP問題centos6.8怎麼編譯安裝php

centos6.8怎麼編譯安裝php

Dec 15, 2022 am 09:21 AM
phpcentos

centos6.8編譯安裝php的方法:1、透過“yum -y install”指令安裝依賴;2、拷貝設定檔;3、新增環境變數;4、執行“source /etc/profile”命令;5、新增自啟動,然後重啟php服務即可。

centos6.8怎麼編譯安裝php

本教學操作環境:Windows10系統、centos6.8&&php7.1.5版、Dell G3電腦。

centos6.8怎麼編譯安裝php?

centOS6.8,centOS7編譯安裝PHP:

我在centOS上安裝了7次PHP,總結出來的centOS6.8,ccentOS7都能用的編譯安裝PHP的方法。久病成良醫的感覺,剛開始安不上不要著急,多安幾次就有經驗了

 

安裝依賴:

yum -y install gd-devel zlib-devel libjpeg-devel libpng-devel libiconv-devel freetype-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libxslt-devel libmcrypt-devel mhash mcrypt

無法自動安裝的網上搜尋手動安裝的教程,其實基本上不會出錯

進入本機目錄:cd /usr/local

下載PHP7.1.5:wget http://am1. php.net/distributions/php-7.1.5.tar.gz

解壓縮:tar zxvf php-7.1.5.tar.gz

#進入解壓縮目錄:cd php-7.1.5

编译:./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-fpm-user=www --with-fpm-group=www --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-mysql --enable-mysqlnd-compression-support --with-pear --enable-maintainer-zts --enable-session --with-gettext

安裝目錄是/usr/local/php

編譯完成後會看到:Thank you for using PHP.

之後執行安裝指令:

make
make install

之後拷貝設定檔(目前還在php7.1.5資料夾下,不要用mv指令,這些設定檔以後還可以用不要刪):

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp php.ini-development /usr/local/php/lib/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/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm(这个很重要)

新增環境變數:

echo 'export PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH'>> /etc/profile

載入環境變數:source /etc/profile (我的習慣是虛擬機器開機後先執行這個指令,會避免很多麻煩)

#執行到這裡,執行php -v就能看到安裝的PHP的版本了

加入自啟動:

chkconfig --add php-fpm
chkconfig php-fpm on
chkconfig --list php-fpm

加上權限:chmod 755 /etc/init.d/php-fpm

啟動PHP:/etc/init.d/php-fpm start

查看PHP服務狀態:/etc/init.d/php-fpm status

#停止PHP服務:/etc/init.d/php-fpm stop

重啟php服務:/etc/init.d/php-fpm restart

php的設定檔是/usr/local/php /lib/php.ini 以後安裝擴充功能了可以在這裡引用。

推薦學習:《PHP影片教學

以上是centos6.8怎麼編譯安裝php的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。