开篇

本操作是在VirtualBox里面进行的,所以开篇先说下,本地如何操作VB里面的Linux

1.secureCRT登陆虚拟机ubuntu

直接连接虚拟机的ip (ifconfig)会提示拒绝访问,是因为未安装ssh,ssh是telnet的升级,telnet的密码和信息是不加密的,而ssh是加密。

安装ssh

sudo apt-get install openssh-server openssh-client

启动ssh-server

ssh restart

查看ssh-server是否启动

netstat -tlp

显示一下表示成功启动

tcp               *:ssh                   *:*                     LISTEN      /sshd
tcp6 [::]:ssh [::]:* LISTEN /sshd

2.删除软件

因为之前安装过测试的php 所以先卸载掉

sudo apt autoremove php7.

3. 获取root权限

这个是一个谨慎的操作,因为任何管理员都可以使用 sudo root 来获取root的权限,但有写入权限或-p 创建目录,启动服务等会出问题。

获取root权限:

sudo passwd
[sudo] currentUser 的密码:
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码

然后:

su root

下载测试安装环境

方便期间,我们使用lnmp快速安装,(先安装php5.4)

下载地址:http://soft.vpser.net/lnmp/lnmp1.3-full.tar.gz

tar xzvf lnmp1.-full.tar.gz
cd lnmp1.-full
./install.sh

下一步……

完成!

访问ip查看lnmp环境是否安装ok

升级php至php7

下载最新版php7 (2017-03-16)

下载地址:http://cn2.php.net/distributions/php-7.0.17.tar.gz

 别急!

上一步我们查看那了phpinfo,首先先复制Configure Command 等一会编译的时候要用

'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--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' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-intl' '--with-xsl'

先停掉php-fpm

service php-fpm stop

备份下老的php版本

cd /usr/local
mv php php5.

ok,现在可以安装php7了

tar xzvf php-7.0..tar.gz
cd php-7.0.

带上刚才复制的Configure Command

关于Linux configure 参数解释参考: http://blog.chinaunix.net/uid-20568163-id-1632905.html

'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--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' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-intl' '--with-xsl'
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+ Thank you for using PHP. config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.
config.status: creating sapi/cli/php.
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/www.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.
config.status: creating ext/phar/phar.
config.status: creating ext/phar/phar.phar.
config.status: creating main/php_config.h
config.status: executing default commands
configure: WARNING: unrecognized options: --with-mysql
root@aaa-VirtualBox:/home/wwwroot/tools/php-7.0.#

提示:configure: WARNING: unrecognized options: --with-mysql 是因为php7已经不在用--with-mysql 支持mysql模块连接了,取而代之的是--with-mysqli 、--with-pdo-mysql,去掉--with-mysql=mysqlnd 便可。

如果提示:

checking if we should use cURL for url streams... no checking for cURL in default path... not found

configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/

执行:

apt-get install curl
apt-get install libcurl4-gnutls-dev

修改configure 参数:增加参数--with-curl=/usr/local/curl

接着make && make install

问题又来了

collect2: error: ld returned  exit status
Makefile:: recipe for target 'sapi/cli/php' failed
make: *** [sapi/cli/php] Error

查看报错的内容:

 In function `convert’:
encodings.c:: undefined reference to `libiconv_open’
encodings.c:: undefined reference to `libiconv’
encodings.c:: undefined reference to `libiconv_close’

libiconv模块错误,but libiconv是安装的,不知为何提示错误,解决办法 make时加了一个参数, 参考:http://lynnteng0.blog.51cto.com/2145094/1257910       https://fukun.org/archives/10102487.html

make ZEND_EXTRA_LIBS='-liconv'

启动php-fpm

service php-fpm start

提示: 无一下提示可忽略

Job for php-fpm.service failed because the control process exited with error code. See "systemctl status php-fpm.service" and "journalctl -xe" for details. 使用systemctl status php-fpm.service 查看详情

 ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory ()
ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
ERROR: FPM initialization failed
php-fpm.service: Control process exited, code=exited status=
Failed to start LSB: starts php-fpm.

修改/usr/local/php/etc/php-fpm.conf.default 为 php-fpm.conf (mv)
并将/usr/local/php/etc/php-fpm.d中 www.conf.default的文件mv为www.conf文件

然后在启动php-fpm 、从新加载nginx

service php-fpm start
service nginx reload

访问IP地址或域名

 bad gateway

这个说明php-fpm 已经运行,但php-fpm的配置有问题  参考:http://www.111cn.net/phper/31/93675.htm

关于php-fpm的配置参数参考:http://www.jb51.net/article/37749.htm

使用LNMP配置出来的php-fpm.conf文件 (LNMP可正常启动)

[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice [www]
listen = /tmp/php-cgi.sock
listen.backlog = -
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode =
user = www
group = www
pm = dynamic
pm.max_children =
pm.start_servers =
pm.min_spare_servers =
pm.max_spare_servers =
request_terminate_timeout =
request_slowlog_timeout =
slowlog = var/log/slow.log

现在单独安装php7.0.17 生成的conf在 /usr/local/php/etc/php-f/php-fpm.d/www.conf中 (php-fpm.conf中include进来的)

修改www.conf

listen = 127.0.0.1:9000 

改为

listen = /tmp/php-cgi.sock

listen.owner = www
listen.group = www
listen.mode = 0666

三行最前面的 ‘;’ 去掉,重启服务。

到此,php已经从php5.4升级为php7了。

扩展安装

安装扩展,可参考:

Yii2中mongodb使用ActiveRecord的数据操作

Deepin下 使用apt get install 安装nginx和php-fpm

Deepin Linux桌面版没有办法安装php的集成环境,无论是Lanmps、Lnmp、phpstudy,安装的时候就会卸载Deepin15.1的应用,包括dde桌面

那么只能手动安装php环境

1. 安装nginx

apt-get install nginx

访问localhost

默认的web目录在/var/www/html, 默认的conf在/etc/nginx/nginx.conf, 执行文件在/usr/sbin/nginx

2.安装php7.1

apt-get install php7.-fpm

3.配置nginx支持php

gedit /etc/nginx/site-available/default

添加php 默认页面

    # Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;

支持.php 文件解析

    location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:;
}

重新加载nginx

service nginx reload

设置/var/www/html/index.php 内容

<?php

phpinfo();

?>

4.对mysql的支持

安装mysql

apt-get install mysql-server mysql-client

php连接mysql

apt-get install php7.1-mysql

重启服务:

service php7.1-fpm reload
service nginx reload

支持memcached

# memcached服务端
apt-get install memcached
#memcached -d -m 256 -p 11211 -u root

php-memcahced插件

# 找不到源
apt-get install php7.-memcached

apt 安装不了,只能编译安装

编译安装的时候必须要指定phpize才能知道挂载的扩展

启用phpize:

apt-get install php7.-dev

安装完php7.1-dev 后phpize的目录在 /usr/bin/phpize

下载php-memcahced 扩展

wget http://pecl.php.net/get/memcached-3.0.3.tgz
tar xzvf memcached-3.0..tgz
cd memcached-3.0. /usr/bin/phpize

当configure 的时候提示 not find libmemcached

安装libmemcached-dev

apt-get install libmemcached  # 不存在
apt-get install libmemcached-dev
./configure
make && make install

在php.ini 中添加memcahced.so

Linux版 php5.4 升级php7的更多相关文章

  1. centos php5.4 升级 php7

    接上篇,edusoho需要php5.5以上版本,于是需要升级本地php php是通过yum默认安装的.以下安装参考 link https://blog.csdn.net/u012569217/arti ...

  2. Linux环境PHP5.6升级7.1.8

    PHP7和HHVM比较PHP7的在真实场景的性能确实已经和HHVM相当, 在一些场景甚至超过了HHVM.HHVM的运维复杂, 是多线程模型, 这就代表着如果一个线程导致crash了, 那么整个服务就挂 ...

  3. 升级lamp中php5.6到php7.0过程

    升级过程我就直接摘录博友,http://www.tangshuang.net/1765.html,几乎问题和解决办法都是参照他的,所以我也就不另外写了.谢谢!! 周末看了一下php7的一些情况,被其强 ...

  4. wdcp升级php5.8到php7.1.12

    php7升级脚本 update_php7.sh #!/bin/bash # PHP update scripts ];then Ver= else Ver=$ fi Debugfile= echo & ...

  5. 解决升级PHP7后 微信公众号收不到消息

    服务器配置Linux+Nginx+PHP5.5+mysql index方法配置微信的关注回复.菜单事件.多客服.自动回复等 public function actionIndex() { if (is ...

  6. 记 Mac Pro 系统升级后,编译安装 PHP-5.6.28 / PHP-7.0 报错修复过程

    买 Mac Pro 的时候,系统为 OS X 10.11.5,编译 PHP-5.6.21 的时候,也遇到一些坑,安装过程记录如下: Mac Pro 编译安装 PHP 5.6.21 及 问题汇总 后来, ...

  7. Linux版OpenVPN安装、配置教程(转)

    本文将以目前最新的openvpn-2.3.4.tar.gz(更新于2014-5-2,下载地址)为例来介绍如何在Linux系统中安装.配置及使用OpenVPN. 在这里,我们选用了一台预装CentOS ...

  8. Linux(Fedora)下NodeJs升级最新版本(制定版本)

    Linux(Fedora)下NodeJs升级最新版本(制定版本) 首先安装n模块: npm install -g n 升级node.js到最新稳定版 n stable 升级node.js到制定版本 n ...

  9. linux版powershell安装教程(.net core版)

    powershell 传教士 原创文章 始于2016-12-20,2017-03-15改.文章版本目前博客园为最新版. 允许转载,但必须保留名字和出处,否则追究法律责任 问:powershell二进制 ...

随机推荐

  1. 牛客小白月赛13-J小A的数学题 (莫比乌斯反演)

    链接:https://ac.nowcoder.com/acm/contest/549/J来源:牛客网 题目描述 小A最近开始研究数论题了,这一次他随手写出来一个式子,∑ni=1∑mj=1gcd(i,j ...

  2. uploadify多文件上传实例--C#

    下载uploadify文件 http://www.uploadify.com/ HTML(视图) <html lang="zh-cn"> <head> &l ...

  3. LOJ#2665 树的计数

    题意:给你DFS序和BFS序,求树的期望高度. 解:先分析性质. 考虑到BFS序是分层的,DFS序的子树是一段,那么我们遍历BFS序并在DFS序上标记对应点的话,就会发现BFS序每一层都会把若干棵子树 ...

  4. JS学习笔记Day21

    一.mySQL数据库 (一)数据库的概念 1.概念:可以存储数据的一个仓库 2.结构化数据:以表格的形式展现,结构更清晰,这样的数据称之为结构化数据 (二)数据库管理软件 1.一种对数据库文件进行管理 ...

  5. Lending Club贷款数据分析

    python信用评分卡(附代码,博主录制) https://study.163.com/course/introduction.htm?courseId=1005214003&utm_camp ...

  6. Apicloud学习第三天——获取云数据库的数据方法

    apicloud学习30天中的对用进行注册和登录以及数据的获取的代码,在apicloud中有单独的api对用户的增删查改进行操作,这里写下增加和查询. 增加用户数据 var model=api.req ...

  7. vue根据ajax绑定数数。。

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. file 自定义上传附件并展示缩略图

    效果图镇楼..   写的有点乱.上传一个实例供大家参考--附件下载地址如何下: https://files.cnblogs.com/files/fchx91/uploadFiles.rar 2019- ...

  9. 【转】Steam 开发者收入计算

    全部说的话有点复杂,捡要点说说: 假设收入100美刀. 假设美区收入50刀,非美区(在美国以外的地区,俄罗斯,中国等等其他国家)收入50刀. 1.分给steam 30% 剩下70刀. 开发者所得美区收 ...

  10. Python——爬取人口迁徙数据(以腾讯迁徙为例)

    说明: 1.迁徙量是腾讯修改后的数值,无法确认真实性. 2.代码运行期间,腾讯迁徙未设置IP屏蔽和浏览器检测,因此下段代码仅能保证发布近期有效. 3.代码功能:爬取指定一天的四十(此四十是根据自己的城 ...