rpm -Uvh http:
//mirror
.webtatic.com
/yum/el6/latest
.rpm
php
yum
install
php55w php55w-opcache
html
yum
install
yum-plugin-replace
yum replace php-common --replace-with=php55w-common
wget http://cn2.php.net/get/php-7.0.2.tar.gz/from/this/mirror
tar -zxvf php-7.1.0.tar.gz
卸載以前phpmysql
yum remove php rpm -qa|grep php //php相關列表 rpm -e php-cli-5.4.16-42.el7.x86_64 //逐一刪除
安裝前準備支持linux
yum install libxmal2 libxml2-devel openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-devel
configurenginx
./configure --prefix=/usr/local/php --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-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --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-sysvshm --enable-xml --enable-zip
Error:web
checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for cc... no checking for gcc... no configure: error: in `/home/cloud-user/php-7.1.0': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
須要install gccsql
yum install gcc
configurevim
./configure --prefix=/usr/local/php --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-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --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-sysvshm --enable-xml --enable-zip
出現錯誤,解決方案後端
1)freetype.h not fount => yum install freetype-develcentos
2)onfigure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/ => yum install curl curl-devel
3)cannot find openssl's<evp.h> => yum install openssl openssl-devel
4)configure error xml2-config not found. please check your libxml2 installation => yum install libxml2 libxml2-devel
5)png.h not found. => yum install libpng-devel
make && make install時間較長
make && make install
配置相應文件
cp php.ini-development /usr/local/php/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp sapi/fpm/php-fpm /usr/local/bin
設置php.ini
vi /usr/local/php/php.ini
打開php配置文件找到cgi.fix_pathinfo配置項,這一項默認被註釋而且值爲1,根據官方文檔的說明,這裏爲了當文件不存在時,阻止Nginx將請求發送到後端的PHP-FPM模塊,從而避免惡意腳本注入的攻擊,因此此項應該去掉註釋並設置爲0
修改php-fpm
而後網上一些教程說讓修改php-fpm.conf添加以上建立的用戶和組,
find / -name php-fpm.conf
vim ....php-fpm.conf
修改
默認狀況下etc/php-fpm.d/下有一個名爲www.conf.defalut的配置用戶的文件,執行下面命令複製一個新文件而且打開:
cp www.conf.default www.conf vi www.conf
默認user和group的設置爲nobody,將其改成合適的。
啓動php-fpm
/usr/local/bin/php-fpm
php-fpm服務默認使用9000端口,使用 netstat -tln | grep 9000 能夠查看端口使用狀況:
yum install參考網址:http://www.centoscn.com/image-text/install/2015/1222/6560.html
更新靜項原
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Error
epel-release >= 7 被 webtatic-release-7-3.noarch 須要
解決
yum install epel-release
yum install
yum install php70w php70w-bcmath php70w-cli php70w-common php70w-dba php70w-devel php70w-embedded php70w-enchant php70w-fpm php70w-gd php70w-imap php70w-interbase php70w-intl php70w-ldap php70w-mbstring php70w-mcrypt php70w-mssql php70w-mysql php70w-odbc php70w-opcache php70w-pdo php70w-pecl-memcache php70w-pecl-xdebug php70w-pgsql php70w-process php70w-pspell php70w-recode php70w-snmp php70w-soap php70w-tidy php70w-xml php70w-xmlrpc
nginx支持php,安裝php時必定須要帶php-fpm
先啓動php-fpm
/usr/sbin/php-fpm
修改nginx.conf
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000;#php-fpm的默認端口是9000 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
重啓nginx
systemctl restart nginx
寫個phpinfo瀏覽器訪問就能夠:
或者:
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm //升級本地鏡像源,可能會失敗,多試幾回
yum install
yum install php70w php70w-bcmath php70w-cli php70w-common php70w-dba php70w-devel php70w-embedded php70w-enchant php70w-fpm php70w-gd php70w-imap php70w-interbase php70w-intl php70w-ldap php70w-mbstring php70w-mcrypt php70w-mssql php70w-mysql php70w-odbc php70w-opcache php70w-pdo php70w-pecl-memcache php70w-pecl-xdebug php70w-pgsql php70w-process php70w-pspell php70w-recode php70w-snmp php70w-soap php70w-tidy php70w-xml php70w-xmlrpc