安装相关依赖库
sudo apt-get update
sudo apt-get install libxml2-dev
#安装gcc
sudo apt-get install build-essential
sudo apt-get install openssl (不安装则报错: Cannot find OpenSSL's )
sudo apt-get install libssl-dev (不安装则报错: Cannot find OpenSSL's )
sudo apt-get install make
sudo apt-get install curl(不安装则报错: libcrl未找到 )
sudo apt-get install libcurl4-gnutls-dev (不安装则报错: libcrl未找到 )
sudo apt install webp(让php支持webp)
sudo apt-get install libjpeg-dev (让php支持jpeg)
sudo apt-get install libpng-dev (让php支持png)
sudo apt-get install libmcrypt-dev (让php支持mcrypt)
sudo apt-get install libreadline6 libreadline6-dev
解释下Linux命令:
./configure #脚本配置工具
./configure --help #查看脚本配置工具configure的命令行选项
/home/php/bin/phpize #phpize命令用于在编译好的PHP中扩展模块
配置安装如下:
1)简单安装
./configure --prefix=/home/php --enable-fpm --with-fpm-user=daokr --with-fpm-group=daokr --with-config-file-path=/home/php/etc --with-config-file-scan-dir=/home/php/etc/scan --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-mbstring --with-openssl --with-curl
2)dev生产环境安装;
安装之前必须先安装下列组件包
sudo apt install webp(让php支持webp)
sudo apt-get install libjpeg-dev (让php支持jpeg)
sudo apt-get install libpng-dev (让php支持png)
sudo apt-get install libpng12-dev
sudo apt-get install libmcrypt-dev (让php支持mcrypt)
安装字体库:
https://download.savannah.gnu.org/releases/freetype/
wget https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz --no-check-certificate
tar zxvf freetype-2.9.tar.gz cd freetype-2.9/ ./configure make sudo make install
全部安装完成后;查看路径下安装的freetype放在什么位置;
find / -name "freetype*"
执行下面配置;
注意如果不要oracle的配置直接去掉里面的参数:--with-pdo-oci
mysql安装配置
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
正确配置如下:包括CURL gd库 png jpeg
1 ./configure --prefix=/home/php --with-config-file-path=/home/php/etc --with-fpm-user=ubuntu --with-fpm-group=ubuntu --with-pdo-mysql --with-openssl --with-pear --with-mhash --with-xmlrpc --with-zlib --with-mcrypt --with-curl --with-jpeg-dir --with-png-dir --with-gd --with-freetype-dir=/usr/local/include/freetype2 --without-sqlite3 --without-pdo-sqlite --disable-rpath --without-pear --enable-fpm --enable-maintainer-zts --enable-pcntl --with-tsrm-pthreads --enable-mbstring --enable-mbregex --enable-bcmath --enable-zip --enable-sockets --enable-soap --enable-gd-native-ttf --enable-xml --enable-inline-optimization --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-ftp --with-gettext --enable-opcache
如果执行完后;有错误;请删除有关参数如:
--with-pdo-oci 这个是支持oracle数据库的pdo
参考文献:http://php.net/manual/zh/install.unix.nginx.php
php下载地址:http://php.net/releases/
wget http://am1.php.net/distributions/php-7.0.0.tar.gz
3) 编译安装
make
make install
4)修改etc/php.ini
如果没有从安装包下面复制一份php.ini 到etc下面
5)修改etc目录下面的 php-fpm.conf
具体配置查看该传送门
6) 重启服务器
pkill -9 nginx ; /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
用phpinfo()在浏览器中查看PHP配置清单,ok, 到此安装已完成。
-----------------------------------------------------------------------------------------------------
一些服务开启的命令:
pkill php-fpm; /usr/local/php/sbin/php-fpm
linux:
/etc/init.d/nginx start|stop|restart #启动|停止|重启nginx
/etc/init.d/php-fpm start|stop|restart #启动|停止|重启php-fpm
/etc/init.d/mysql start|stop|restart #启动|停止|重启msyq
freebsd:
/usr/local/etc/rc.d/nginx start|stop|restart #启动|停止|重启nginx
/usr/local/etc/rc.d/mysql-server start|stop|restart #启动|停止|重启mysql
/usr/local/etc/rc.d/php-fpm start|stop|restart #启动|停止|重启php-fpm
/usr/local/sbin/nginx #启动nginx
/usr/local/sbin/nginx -s stop #停止nginx
/usr/local/sbin/nginx -s reload #重启nginx