Ubuntu 安装php5.6

Ubuntu16.04 专栏收录该内容
3 篇文章 0 订阅

一、

    apt install python-software-properties -y

二、安装ppa源

    apt install software-properties-common python-software-properties

三、

   	LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php

四、更新源

    apt update

五、升级源

	apt upgrade -y

六、安装php

	apt install php5.6 php5.6-fpm php5.6-mysql php5.6-gd php5.6-mbstring php5.6-curl php5.6-soap php5.6-redis php5.6-xml php5.6-apcu php5.6-mcrypt -y

七、配置Nginx支持PHP扩展

	vim /etc/nginx/fastcgi_params 
	# 在文档最后添加一下代码:
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

八、创建站点文件及php测试文件

	1、mkdir -p /www/test
	2、vim /www/test/info.php
	输入内容
	<?php phpinfo();

九、站点配置文件修改

    vim /etc/nginx/conf.d/default.conf 
	# 清空文档,把以下内容复制到文档中:
	server {
		listen  80;
		# server_name  localhost;
		root  /www/test;
		index  index.php index.html index.htm;
	
		location ~ \.php$ {
			fastcgi_pass  unix:/var/run/php/php5.6-fpm.sock;
			include  fastcgi_params;
		}
			location ~ /\.ht {
			deny  all;
		}
	}
	
	# 改完之后保存

十、文件访问权限

   	vim /etc/nginx/nginx.conf  
	修改一行【user  nginx;】为【user  www-data;】

十一、重启Nginx服务

	/etc/init.d/nginx restart

十二、外网访问:http://主机IP/info.php

十三、显示phpinfo内容则成功,否则失败

  • 0
    点赞
  • 0
    评论
  • 3
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

打赏
文章很值,打赏犒劳作者一下
项目中要用到zend Optimizer,但是目前只支持php5.2,Ubuntu默认安装php版本为5.3,找了好多 方法,终于借助下面这篇文章的方法成功的安装了5.2及5.3两个版本的php Although Drupals 7+ run smoothly on PHP 5.3, Drupal 6 still feels much better with PHP 5.2. Even though D6 core is compatible with PHP 5.3 for quite some time now, a lot of contributes modules still get nasty hiccup when asked to run on the newer version. Therefore developing for both D7 and D6 at the same time becomes much less painful when running both versions of PHP in parallel. One way of doing it is using mod_php5 Apache module to serve PHP 5.3 applications, while running PHP 5.2 applications using fastcgi module. Under Ubuntu 12.04 this can be achieved by installing PHP 5.3 from the repositories and manually compiling and installing PHP 5.2 afterwards. Installing PHP 5.3 from repositories is fairly easy process, which you most probably already have under your belt, so let's just say that it looks more or less like this: sudo apt-get install php5 php5-common php5-cli php5-dev php5-mysql phpmyadmin php5-pgsql phppgadmin php5-gd php5-mcrypt php5-curl php-pear libapache2-mod-php5 php5-xdebug php5-codesniffer What is much more interesting though, and what this post will focus on, is how to add PHP 5.2 to the whole picture and make both those versions work nicely together. Please note that this tutorial is for Apache's name- based virtual hosts, and essentially leaves PHP 5.3 enabled globally while allowing to use PHP 5.2 on specific, selected virtual hosts only.
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页

打赏

孔叔叔

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值