php 7.1.0 + nginx 安装

步骤明确清晰的安装方法

一、php 7.1.0安装

1、下载地址:http://cn2.php.net/distributions/php-7.1.0.tar.gz

2、上传到服务器 /opt目录:cd /opt

3、在服务器中输入rz命令
传输完成就可以看到php7.1.0的tar包,然后解压缩
tar -xvzf php-7.1.0.tar.gz

4、解压缩完成后,进入该目录:cd /opt/php-7.1.0

5、编译安装:
安装需要的lib库文件等
yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libmagic libxslt libxslt-devel
需要的扩展支持curl fileinfo gd mbstring redis openssl pdo exif tokenizer xml

6、./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --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-xmlrpc --with-xsl --with-zlib --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-xml --enable-zip --enable-tokenizer --enable-exif --with-iconv-dir
运行上面的命令出现
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
运行yum install libxslt*安装成功
再次运行上面的config命令就行了

7、make
Make的过程中出现
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
可以不安

8、make install
此时安装已经成功

9、将/usr/local/php/bin加入环境变量
vim /etc/profile
在最后一行加上export PATH=$PATH:/usr/local/php/bin
这样就可以直接使用php命令了,如php –v,php –m,php --ini等等

10、设置php的配置文件
未设置php配置文件时输入php --ini命令,会出现
[root@iZbp1be6tlwmae05sjlmk7Z ~]# php --ini
Configuration File (php.ini) Path: /usr/local/php/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
在opt的php安装目录下有这两个文件,将其中的production复制到/usr/local/php/lib目录cp /opt/php-7.1.0/php.ini-production /usr/local/php/lib
/opt/php-7.1.0/php.ini-development
/opt/php-7.1.0/php.ini-production
将php.ini-production重命名为php.ini,再次输入php –ini命令(可以看到已经加载了配置文件,稍后再做具体配置)
[root@iZbp1be6tlwmae05sjlmk7Z lib]# php --ini
Configuration File (php.ini) Path: /usr/local/php/lib
Loaded Configuration File: /usr/local/php/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)

11、安装memcache、memcached、redis扩展
可参考http://www.cnblogs.com/zqifa/p/linux-php-2.html
安装memcached扩展
下载libmemcached的安装包
https://launchpadlibrarian.net/165454254/libmemcached-1.0.18.tar.gz
解压缩安装即可
依赖库安装完成后安装memcached扩展
git clone https://github.com/php-memcached-dev/php-memcached.git
这个下载的太慢
直接下载的zip包php-memcached-master.zip
https://codeload.github.com/php-memcached-dev/php-memcached/zip/master
安装完成后提示
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/
安装redis扩展与上面的类似

12、启动php-fpm服务
/usr/local/php/sbin/php-fpm
配置文件为/usr/local/php/etc/php-fpm.conf,配置文件的具体说明可参考http://www.cnblogs.com/argb/p/3604340.html
ps –aux|grep php-fpm可查看进程

二、nginx安装

下载Nginx1.2.1的安装包,服务器上在opt目录里已经有了nginx-1.2.1.tar.gz
解压缩tar –xvzf nginx-1.2.1.tar.gz
cd nginx-1.2.1
./configure
配置概览
Configuration summary

  • using system PCRE library
  • OpenSSL library is not used
  • md5: using system crypto library
  • sha1: using system crypto library
  • using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"

make
make install
安装完成后可以在/usr/local/nginx目录查看安装情况
启动nginx
/usr/local/nginx/sbin/nginx –t来校验配置文件的正确性,无误后启动
/usr/local/nginx/sbin/nginx
启动成功后,ps –aux|grep nginx查看进程
在浏览器中输入http://120.26.111.211/可查看welcome to nignx的页面

注:nginx.conf具体要怎么配置可参考其他服务器的配置

你可能感兴趣的:(php 7.1.0 + nginx 安装)