方法1、簡單安裝(經過yum)php
1.安裝epel-releasemysql
rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
3.安裝PHP7nginx
yum install php70w
方法二:編譯安裝web
1.下載php7sql
1 wget -O php7.tar.gz http://cn2.php.net/get/php-7.1.1.tar.gz/from/this/mirror
2.解壓php7json
1 tar -xvf php7.tar.gz
3.進入php目錄api
1 cd php-7.0.4
4.安裝依賴包session
1 # 直接複製下面一行(不包括本行) 2 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
5.編譯配置(若是出現錯誤,基本都是上一步的依賴文件沒有安裝所致)php7
嫌麻煩的能夠從這一步起參考PHP官方安裝說明:http://php.net/manual/zh/install.unix.nginx.phpdom
1 ./configure \ 2 --prefix=/usr/local/php \ 3 --with-config-file-path=/etc \ 4 --enable-fpm \ 5 --with-fpm-user=nginx \ 6 --with-fpm-group=nginx \ 7 --enable-inline-optimization \ 8 --disable-debug \ 9 --disable-rpath \ 10 --enable-shared \ 11 --enable-soap \ 12 --with-libxml-dir \ 13 --with-xmlrpc \ 14 --with-openssl \ 15 --with-mcrypt \ 16 --with-mhash \ 17 --with-pcre-regex \ 18 --with-sqlite3 \ 19 --with-zlib \ 20 --enable-bcmath \ 21 --with-iconv \ 22 --with-bz2 \ 23 --enable-calendar \ 24 --with-curl \ 25 --with-cdb \ 26 --enable-dom \ 27 --enable-exif \ 28 --enable-fileinfo \ 29 --enable-filter \ 30 --with-pcre-dir \ 31 --enable-ftp \ 32 --with-gd \ 33 --with-openssl-dir \ 34 --with-jpeg-dir \ 35 --with-png-dir \ 36 --with-zlib-dir \ 37 --with-freetype-dir \ 38 --enable-gd-native-ttf \ 39 --enable-gd-jis-conv \ 40 --with-gettext \ 41 --with-gmp \ 42 --with-mhash \ 43 --enable-json \ 44 --enable-mbstring \ 45 --enable-mbregex \ 46 --enable-mbregex-backtrack \ 47 --with-libmbfl \ 48 --with-onig \ 49 --enable-pdo \ 50 --with-mysqli=mysqlnd \ 51 --with-pdo-mysql=mysqlnd \ 52 --with-zlib-dir \ 53 --with-pdo-sqlite \ 54 --with-readline \ 55 --enable-session \ 56 --enable-shmop \ 57 --enable-simplexml \ 58 --enable-sockets \ 59 --enable-sysvmsg \ 60 --enable-sysvsem \ 61 --enable-sysvshm \ 62 --enable-wddx \ 63 --with-libxml-dir \ 64 --with-xsl \ 65 --enable-zip \ 66 --enable-mysqlnd-compression-support \ 67 --with-pear \ 68 --enable-opcache
6.正式安裝
1 make && make install
7.配置環境變量
1 vi /etc/profile
在末尾追加
1 PATH=$PATH:/usr/local/php/bin 2 export PATH
執行命令使得改動當即生效
1 source /etc/profile
8.配置php-fpm
1 cp php.ini-production /etc/php.ini 2 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 3 cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf 4 cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 5 chmod +x /etc/init.d/php-fpm
9.啓動php-fpm
/etc/init.d/php-fpm start