Linux下原始碼安裝PHP

2021-08-21 03:20:49 字數 3484 閱讀 9053

cd /usr/local/src/
wget -o php-7.1.19.tar.gz
安裝如出現下面這個wget未找到

使用yum 安裝一下wget

先將檔案解壓

解壓之後得到乙個資料夾,進入這個資料夾

cd php-7.1.19
安裝之前先安裝一些支援庫

yum -y install gcc
yum -y install openssl openssl-devel
yum -y install curl-devel
yum -y install libjpeg-devel
yum -y install libpng-devel
yum -y install freetype-devel
yum -y install libxslt-devel
yum -y install libxml2 libxml2-devel
yum -y install epel-release
yum -y install libmcrypt-devel
配置php

./configure --prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc/ \

--with-curl \

--with-freetype-dir \

--with-gd \

--with-jpeg-dir \

--with-gettext \

--with-iconv-dir \

--with-kerberos \

--with-libdir=lib64 \

--with-libxml-dir \

--with-mysqli \

--with-openssl \

--with-pcre-regex \

--with-pdo-mysql \

--with-pdo-sqlite \

--with-pear \

--with-png-dir \

--with-xmlrpc \

--with-xsl \

--with-zlib \

--enable-fpm \

--enable-bcmath \

--enable-libxml \

--enable-inline-optimization \

--enable-gd-native-ttf \

--enable-mbregex \

--enable-mbstring \

--enable-opcache \

--enable-pcntl \

--enable-shmop \

--enable-soap \

--enable-sockets \

--enable-sysvsem \

--enable-xml \

--enable-zip

編譯安裝

make && make install
拷貝配置檔案到php目錄

cp php.ini-production /usr/local/php/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/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
vi /etc/systemd/system/php-fpm.service
寫入如下**

[unit]

description=the php fastcgi process manager

after=syslog.target network.target

[service]

type=******

pidfile=/run/php-fpm.pid

execstart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf

execreload=/bin/kill -usr2 $mainpid

execstop=/bin/kill -sigint $mainpid

[install]

wantedby=multi-user.target

啟動php-fpm

systemctl start php-fpm.service
新增到開機啟動

systemctl enable php-fpm.service

vi /etc/profile

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

export path

放到檔案最後面

儲存退出

執行命令使配置生效

source /etc/profile
執行

php -v
檢視php資訊

安裝完畢

Linux下原始碼安裝PHP 解除安裝PHP

檢視php版本 php v 下面命令刪除php不乾淨但先刪一遍 yum remove php 檢視剩下的php軟體包,其中會有依賴所以得有先後順序刪除 rpm qa grep php pdo是mysql的依賴項 common是gd的依賴項 所以先刪除mysql,gd rpm e php mysql ...

linux下php原始碼安裝步驟

tar zxvf php 7.1.4.tar.gz 2 進入解壓的php資料夾下 usr local php 7.1.4,安裝依賴,編譯安裝 yum install libxml2 libxml2 devel configure prefix usr local php with zlib enab...

linux下PHP原始碼包安裝

php在nginx環境下執行,所以我們要先配置nginx。wget xz d php 5.6.0.tar.xztar xf php 5.6.0.tar c usr local src 2.安裝依賴性檔案 yum install zlib devel libxml2 devel libjpeg dev...