1 管網下載php下載安裝包 ---個人用linux版(個人喜歡下載 在/usr/local/myfile 中)
2 安裝需要的依賴包
yum -y install epel-release gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt
3 對下載好的包進行解壓安裝
tar -zxvf php*.*.*.tar.gz
4 進入解壓好的安裝在包中配置安裝環境
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm
php編譯安裝說明
--with-config-file-path指定php的配置文件位置
--with-mysql、--with-mysqli讓php可以操作mysql
--enable-fpm主要是nginx要來調用php語言得使用php-fpm
5 安裝 (php 安裝的時間比較長)
make && make install
6 查看安裝端口是否正常開啓
7 添加php配置啓動項
cp php.ini-production /usr/local/php/etc/php.ini
8配置環境變量
export PATH=$PATH:/usr/local/php/sbin/:/usr/local/php/bin/
9啓動php-fpm
10填寫頁面測試(測試頁寫在nginx/html中)
<?php
如果頁面顯示的是下載文件 需要修改 nginx配置文件
可查看https://mp.csdn.net/postedit/95043361