ubutun 安裝php7.1x

服務器ecs上原本跑了一套nginx+php5.5,因爲新項目使用的是laravel5.4,因此不得不把php升級,在此記錄下在此安裝的過程和遇到的問題,整體來講還算順利php

cd /usr/local/src

切換到本身的安裝目錄,我下載的是http://php.net/get/php-7.1.4.tar.xz/from/a/mirror,php-7.1.4.tar.gz
html

tar zxvf php-7.1.4.tar.gz  #解壓後
cd php-7.1.4/ #切換到解壓目錄

接着編譯:mysql

複製代碼
./configure --prefix=/usr/local/php7 \
 --with-curl \
 --with-freetype-dir \
 --with-gd \
 --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
複製代碼

若是配置錯誤,須要安裝須要的模塊nginx

sudo apt-get install -y autoconf libtool re2c libxml2-dev openssl libcurl4-openssl-dev libbz2-dev libjpeg-dev libpng12-dev libfreetype6-dev libldap2-dev libmcrypt-dev libmysqlclient-dev libxslt1-dev libxt-dev libpcre3-dev libxpm-dev libt1-dev libgmp-dev libpspell-dev librecode-dev libreadline6-dev bison libtidy-dev

若是出錯從新編譯便可.編譯完成後:laravel

##根據Wrote PEAR system config file at: /usr/local/php7/etc/pear.conf
##You may want to add: /usr/local/php7/lib/php to your php.ini include_path
##這個信息,咱們須要在當前 php7目錄下執行
cp php.ini-development /usr/local/php7/lib/php.ini (下面會有介紹)
到至,php7-fpm安裝成功

接着複製備份文件:sql

cp php.ini-development /usr/local/php7/lib/php.ini
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp -R /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php7-fpm.d/www.conf
cp -R ./sapi/fpm/php-fpm /etc/init.d/php7-fpm

啓動php:api

/etc/init.d/php7-fpm

出現服務器

由於啓動用戶的默認用戶組爲nobody,咱們加個用戶組php7

groupadd nobody

OK,php7-fpm啓動成功
順便配置下nginx搭配php7
我滴配置以下:curl

複製代碼
server {
    listen       80;
    server_name  localhost xxxxxx.com ;

    location / {
    root      /home/www/test;
        index     index.html index.htm index.php;
        #try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
    root      /home/www/test;
    fastcgi_pass   127.0.0.1:9000; #這裏是重點額
    fastcgi_index  index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
    }

}
複製代碼
檢測下配置是否正確:
/usr/sbin/nginx -t
若是沒錯後執行:
service nginx reload

最終運行結果:

相關文章
相關標籤/搜索