首先需要從PHP官網(wǎng)下載PHP7.3.1的源代碼,保存為php-7.3.1.tar.xz。http://cn2.php.net/distributions/php-7.3.1.tar.xz
在上述文件保存的目錄中打開終端,使用命令將其解壓,并使用cd進入解壓后的目錄
tar -xvJf ./php-7.3.1.tar.xz
cd php-7.3.1
1.安裝依賴
其次,需要安裝一些編譯PHP所需要的依賴
sudo apt update
sudo apt install gcc
sudo apt install make
sudo apt install openssl
sudo apt install curl
sudo apt install libbz2-dev
sudo apt install libxml2-dev
sudo apt install libjpeg-dev
sudo apt install libpng-dev
sudo apt install libfreetype6-dev
sudo apt install libzip-dev
2.預(yù)編譯PHP
在編譯前,需要對PHP進行配置,以供其生成對應(yīng)的makefile文件
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –enable-fpm –with-fpm-user=www –with-fpm-group=www –with-mysqli –with-pdo-Mysql –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –enable-mbregex –enable-mbstring –enable-ftp –with-gd –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear –with-gettext –disable-fileinfo –enable-maintainer-zts
配置成功后會出現(xiàn)如下字樣
——————————————————————–
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
——————————————————————–
Thank you for using PHP.
3.編譯并安裝PHP
make
make install
4.驗證PHP
可以使用如下指令來輸出PHP的版本,來驗證是否正確安裝
/usr/local/php/bin/php -v
如果正確安裝,將會出現(xiàn)如下內(nèi)容
PHP 7.3.1 (cli) (built: Jan 18 2019 20:11:04) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.1, Copyright (c) 1998-2018 Zend Technologies
到這一步為止,PHP7.3.1便成功從源代碼編譯安裝了。
5.復制php.ini
編譯安裝后的目錄并不會有現(xiàn)成的php.ini,需要手動復制過去。
在解壓出來的源代碼目錄中,有供開發(fā)環(huán)境使用的php.ini-development和供生產(chǎn)環(huán)境使用的php.ini-production。
cp php.ini-development /usr/local/php/etc/php.ini
cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
/usr/local/php5/sbin/php-fpm
啟動php報錯
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#/usr/local/php/sbin/php-fpm
[29-Nov-2019 13:04:49] ERROR: [pool www] cannot get uid for user \\\’www\\\’
[29-Nov-2019 13:04:49] ERROR: FPM initialization failed
創(chuàng)建www用戶組
直接創(chuàng)建nginx用戶和用戶組
useradd nginx
groupadd nginx
usermod -G nginx nginx
/usr/local/php5/sbin/php-fpm
更多關(guān)于云服務(wù)器,域名注冊,虛擬主機的問題,請訪問三五互聯(lián)官網(wǎng):m.shinetop.cn