php下載(其中版本可以更換)
wget http://cn2.php.NET/distributions/php-7.0.4.tar.gztar zxvf php-7.0.4.tar.gz
進入目錄
cd php-7.0.4
注:上面的php版本可以替換成最新的版本
編譯:
./configure --enable-fpm --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-fpm-user=nginx --with-fpm-group=nginx --with-bz2 --with-curl --with-gd --with-mcrypt --with-openssl --with-mhash --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir=/usr/local/libiconv --with-gettext --with-libxml-dir --with-zlib --with-xmlrpc --with-pcre-regex --with-pear --with-pdo-mysql=mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-libdir=lib64 --enable-dom --enable-xml --enable-fpm --enable-bcmath --enable-ftp --enable-sockets --disable-ipv6 --enable-mbregex --enable-mbstring --enable-calendar --enable-gd-native-ttf --enable-static --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-zip
如果出現下列錯誤。。那就是沒有編譯環境 。 請安裝gcc
yum install gcc
之後看最後又遇到這個問題:
error:關於libxml
yum install libxml2-devel
最後:
make && make install
安裝完成。
配置 路徑
cp php.ini-development /usr/local/lib/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm chmod +x /etc/init.d/php7-fpm
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf
配置完畢
/etc/init.d/php7-fpm start 啓動php
注意:在安裝完之後看下PHPINFO裏面,php.ini的路徑,然後去服務器檢查試一下是否存在該文件,如果不存在就cp過來