Ubuntu 編譯安裝 php7 4

2021-10-04 16:22:09 字數 4929 閱讀 2873

sudo apt update
sudo apt install gcc -y &&

sudo apt install make -y &&

sudo apt install openssl -y &&

sudo apt install curl -y &&

sudo apt install libbz2-dev -y &&

sudo apt install libxml2-dev -y &&

sudo apt install libjpeg-dev -y &&

sudo apt install libpng-dev -y &&

sudo apt install libfreetype6-dev -y &&

sudo apt install libzip-dev -y &&

sudo apt install libssl-dev -y &&

sudo apt install libsqlite3-dev -y &&

sudo apt install libcurl4-openssl-dev -y &&

sudo apt install libg***-dev -y &&

sudo apt install libonig-dev -y &&

sudo apt install libreadline-dev -y &&

sudo apt install libxslt1-dev -y &&

sudo apt install libffi-dev -y

模組對應的依賴(可選擇性的安裝)

xml

sudo apt-get install -y libxml2-dev

pcre

sudo apt-get install -y libpcre3-dev

jpeg

sudo apt-get install -y libjpeg62-dev

freetype

sudo apt-get install -y libfreetype6-dev

pngsudo apt-get install -y libpng12-dev libpng3 libpnglite-dev

iconv

sudo apt-get install -y libiconv-hook-dev libiconv-hook1

mycrypt

sudo apt-get install -y libmcrypt-dev libmcrypt4

mhash

sudo apt-get install -y libmhash-dev libmhash2

openssl

sudo apt-get install -y libltdl-dev libssl-dev

curl

sudo apt-get install -y libcurl4-openssl-dev

mysql

sudo apt-get install -y libmysqlclient-dev

imagick

sudo apt-get install -y libmagickcore-dev libmagickwand-dev

readline

sudo apt-get install -y libedit-dev

ubuntu 無法找到 iconv

sudo ln -s /usr/lib/libiconv_hook.so.1.0.0 /usr/lib/libiconv.so

sudo ln -s /usr/lib/libiconv_hook.so.1.0.0 /usr/lib/libiconv.so.1

安裝php擴充套件

sudo apt-get install -y autoconf automake m4

wget 

tar -xvf php-7.4.4.tar.gz

cd php-7.4.4

注:/opt/php/74 為php的安裝目錄 許可權和具體目錄位置可以根據自身需要配置。

預編譯啟用的模組也需根據自身需要配置。

./configure \

--prefix=/opt/php/74 \

--with-config-file-path=/opt/php/74/etc \

--enable-fpm \

--enable-inline-optimization \

--disable-debug \

--disable-rpath \

--enable-shared \

--with-xmlrpc \

--with-mhash \

--with-sqlite3 \

--with-zlib \

--enable-bcmath \

--with-iconv \

--with-bz2 \

--with-openssl \

--enable-calendar \

--with-curl \

--with-cdb \

--enable-dom \

--enable-exif \

--enable-fileinfo \

--enable-filter \

--with-openssl-dir \

--with-zlib-dir \

--enable-gd-jis-conv \

--with-gettext \

--with-gmp \

--with-mhash \

--enable-json \

--enable-mbstring \

--enable-mbregex \

--enable-pdo \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-pdo-sqlite \

--with-readline \

--enable-session \

--enable-shmop \

--enable-******xml \

--enable-sockets \

--enable-sysvmsg \

--enable-sysvsem \

--enable-sysvshm \

--with-xsl \

--enable-mysqlnd-compression-support \

--with-pear \

--enable-opcache \

--with-zip \

--with-ffi

make -j && make install
cp php.ini-development /opt/php/74/etc/php.ini &&

cd /opt/php/74/etc && cp php-fpm.conf.default php-fpm.conf &&

cd /opt/php/74/etc/php-fpm.d && cp www.conf.default www.conf

vim /opt/php/74/etc/php-fpm.conf
;pid = run/php-fpm.pid 去掉;

pid = run/php-fpm.pid
vim /opt/php/74/etc/php-fpm.d/www.conf
增加

user = www

group = www

增加php環境變數(我使用的zsh 如果是bash 請編輯 .bashrc 檔案 )

vim ~/.zshrc
加入

export php_home=/opt/php/74

export path=$php_home/bin:$path

sudo groupadd www

sudo useradd -g www www

sudo touch /lib/systemd/system/php-fpm.service

sudo vim /lib/systemd/system/php-fpm.service

[unit]

description=the php fastcgi process manager

after=syslog.target network.target

[service]

type=forking

pidfile=/opt/php/74/var/run/php-fpm.pid

execstart=/opt/php/74/sbin/php-fpm

execreload=/bin/kill -usr2 $mainpid

privatetmp=true

[install]

wantedby=multi-user.target

sudo systemctl enable php-fpm.service
啟動、停止、重啟、狀態

sudo systemctl start php-fpm.service

sudo systemctl stop php-fpm.service

sudo systemctl restart php-fpm.service

sudo systemctl status php-fpm.service

php7 4原始碼安裝

yum install y make cmake gcc gcc c autoconf automake libpng devel libjpeg devel zlib libxml2 devel ncurses devel bison libtool ltdl devel libiconv lib...

Ubuntu 編譯安裝PHP

1.編譯環境 sudo apt get install build essential gcc g autoconf libiconv hook dev libmcrypt dev libxml2 dev libmysqlclient dev libcurl4 openssl dev libjpeg...

簡述PHP7 4 新特性和廢棄的功能

php7.4 新特性 php7.4 上月 28 號已經發布了。又帶來了一些新特性。可以讓我們的 寫的更少了。1.屬性新增限定型別 www.cppcns.com user new user user age 10 user name 張三 error user age zhang 需要傳遞int 2....