1.首先去php官網下載一個php7版本源碼包 http://php.net/downloads.php,我這下載的是php7.2.13版本. php
2.使用ftp或者linux的rz命令將包上傳到linux下,開始進行編譯安裝.html
3.解壓安裝包mysql
# tar -zxvf php-7.2.13.tar.gzlinux
# cd php-7.2.13nginx
#./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mcrypt=/usr/include --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcachelaravel
執行以上編譯會出現報錯sql
1.configure: error: jpeglib.h not found.apache
解決:yum -y install libjpeg-devel .vim
2.configure: error: png.h not found.session
解決:#yum install libpng
# yum install libpng-devel
3.configure: error: freetype-config not found.
解決:# yum install freetype-devel
而後再次執行上面命令會出現:
+--------------------------------------------------------------------+
| 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.
表示配置文件檢測成功,下面開始執行編譯且安裝
# make && make install
至此php7.2.13就安裝完成 .
安裝完成在/usr/local下會出現php7目錄
# cd /usr/local/php7/etc下
首先複製出一份php-fpm.conf
#cp php-fpm.conf.default php-fpm.conf
切換到/usr/local/php7/etc/php-fpm.d複製配置文件
#cp www.conf.default www.conf
爲了兼容php5.6因此須要配置php7的監聽端口爲9001 (個人php5.6監聽端口爲9000)
# vim /usr/local/php7/etc/php-fpm.d/www.conf 找到:
listen = 127.0.0.1:9000
將其端口修改成
listen = 127.0.0.1:9001
:wq 保存編輯退出.
而後配置nginx或apache支持php7便可.
----------------- Nginx 支持php7配置文件以下 ----------------------
server {
listen 8888; 配置項目訪問端口 (若是無其餘項目也可以使用默認的80端口)
location / {
root /data/laravel/public; #項目路徑
index index.html index.htm index.php;
# 項目配置重寫
if (!-e $request_filename) {
rewrite ./index.php last;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root /data/laravel/public; #項目路徑
fastcgi_pass 127.0.0.1:9001; #監聽端口爲9001
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
1.重啓nginx
# /usr/local/nginx/sbin/nginx -s reload
2.重啓php7
# /usr/local/php7/sbin/php-fpm
完成以上步驟後:
---->訪問:http://你的域名:8888 出現配置項目顯示頁面或者可以使用phpinfo()測試信息頁則表示配置nginx+php7成功。
至此能夠開啓你的php7之旅。
以上僅爲我的安裝參考,若有問題可留言交流。