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具体要怎么配置可参考其他服务器的配置

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,406评论 6 503
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,732评论 3 393
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,711评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,380评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,432评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,301评论 1 301
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,145评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,008评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,443评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,649评论 3 334
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,795评论 1 347
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,501评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,119评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,731评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,865评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,899评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,724评论 2 354

推荐阅读更多精彩内容