文章出自虎書博客瑞侮,轉(zhuǎn)載請注明出處收擦。
給大家介紹下CentOs7下如何通過編譯去安裝php7,教程為本人親測力九。
1耍铜、下載php7.1.5(s上傳到 /usr/local/src/),下載地址:http://cn2.php.net/distributions/php-7.1.5.tar.gz
cd /usr/local/src
2邑闺、解壓php7
tar -xvf php-7.1.5.tar.gz
3、移動解壓之后的文件夾到 /usr/local/
mv php-7.1.5 /usr/local/php
4业扒、進入php目錄
cd /usr/local/php
5检吆、安裝依賴包
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
6、編譯配置(如果出現(xiàn)錯誤程储,基本都是上一步的依賴文件沒有安裝所致)蹭沛,嫌麻煩的可以從這一步起參考PHP官方安裝說明:http://php.net/manual/zh/install.unix.nginx.php (極簡安裝)
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
6、正式安裝
make && make install
7章鲤、配置環(huán)境變量
vi /etc/profile
8摊灭、在末尾追加
PATH=$PATH:/usr/local/php/bin
export PATH
:wq 保存退出,執(zhí)行命令使得改動立即生效
source /etc/profile
9败徊、配置php-fpm
cp php.ini-production /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
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
10帚呼、啟動php-fpm
/etc/init.d/php-fpm start
至此就已經(jīng)安裝好php7.1了,希望可以幫助到大家皱蹦。如需轉(zhuǎn)載請注明出處煤杀。
11、啟動php-fpm報錯:
Starting php-fpm [06-Jul-2018 09:05:16] ERROR: [pool www] cannot get uid for user 'nginx'
添加該用戶沪哺,然后啟動php-fpm就好了
useradd nginx
/etc/init.d/php-fpm start