1、安裝Apache,略。php
2、安裝PHPhtml
1.下載php7
wget -O php7.tar.gz http://cn2.php.net/distributions/php-7.1.6.tar.gz
2.解壓php7
tar -xvf php7.tar.gz
3.進入php目錄
4.安裝依賴包
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.編譯配置(若是出現錯誤,基本都是上一步的依賴文件沒有安裝所致)
參考,感謝原做者:
http://blog.csdn.net/u014086788/article/details/50991428
http://www.jb51.net/article/109228.htm
./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 \
--with-apxs2=/usr/bin/apxs \
--enable-opcachemysql
上面這一步,必定記得有 --with-apxs2=/usr/bin/apxs 這一項,這是跟Apache相關的配置nginx
參考,感謝原做者:sql
http://www.imooc.com/qadetail/177244?t=261022json
https://zhidao.baidu.com/question/935995633496482532.htmlsession
若是報錯,沒有Apache相關的,則安裝一下更多依賴:php7
yum -y install perl*
yum -y httpd-devel
而後,從新編輯。應該沒問題。dom
6.安裝curl
make && make install
7.檢查一下php7的Apache模塊
find / -name libphp7.so
若是有文件,則沒問題。
8.檢查Apache配置文件,搜索「LoadModule」,看裏面是否是已有:
LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
若是有,則已成功。
9.重啓Apache。而後PHP連接MySQL測試,發現被拒絕鏈接。
這時,先看看MySQL是否是已啓動。若是已經啓動,則須要配置PHP和MySQL的配置。
若是未安裝MySQL的,看上一條筆記:http://www.cnblogs.com/whatmiss/p/7093630.html
在php.ini裏面搜索「default_socket」,給這些配置爲my.cnf裏面的「socket」的值。參考,Thanks so much:
MySQL :
[mysqld]
socket=/var/lib/mysql/mysql.sock
[client]
socket=/var/lib/mysql/mysql.sock
PHP :
mysqli.default_socket = /var/lib/mysql/mysql.sock
......
pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
而後重啓Apache,而後PHP連接MySQL無障礙。