镜像制作:Unbuntu14 部署LAMP过程
1、Azure经典版中创建源Ubuntu14,并使用Xshell连接,并切换到root帐户下。
2、安装php5.4,新建/var/local/php54目录,到官网下载5.4最新版php-5.4.45.tar.gz到此目录下,并解压tar -zvxf php-5.4.45.tar.gz。
 
3、安装依赖包
Centos:
yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
 
Ubuntu:
apt-get -y install build-essential libxml2-dev libpcre3-dev libjpeg62-dev libfreetype6-dev libpng12-dev libpng3 libpnglite-dev libiconv-hook-dev libiconv-hook1 libmcrypt-dev libmcrypt4 libmhash-dev libmhash2 libltdl-dev libssl-dev libcurl4-openssl-dev libmysqlclient-dev libmagickcore-dev libmagickwand-dev
apt-get install libxslt1-dev
ln -s /usr/lib/libiconv_hook.so.1.0.0 /usr/lib/libiconv.so
ln -s /usr/lib/libiconv_hook.so.1.0.0 /usr/lib/libiconv.so.1
apt-get -y install autoconf automake m4
参考资料:
 
4、进入/usr/local/php54/php-5.4.45中编译安装:
./configure --prefix=/usr/local/php54/php-5.4.45 \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-MySQL \
--with-pdo-mysql \
--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-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
 
5、复制配置文件:
# make &&  make install
# cp -R ./sapi/fpm/php-fpm.conf /usr/local/php54/php-5.4.45/etc/php-fpm.conf
# cp php.ini-development /usr/local/php54/php-5.4.45/lib/php.ini
# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm5.4.44
 
参考:同样 道理,5.5版本时:
# cp -R ./sapi/fpm/php-fpm.conf /usr/local/php55/php-5.5.37/etc/php-fpm.conf
# cp php.ini-development /usr/local/php55/php-5.5.37/lib/php.ini
# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm5.5.37
 
6、配置
(1)也可以创建一个用户php54并添加到php组中:
groupadd php
useradd --shell /sbin/nologin -g php php54
(2)修改配置文件/usr/local/php54/php-54.4.45/etc/php-fpm.conf文件,配置监听端口,默认为9000,我们改成9054
; Note: This value is mandatory.  
listen = 127.0.0.1:9054
(2)设置用户,将原来的nobody改成root或者当前用户(做镜像时,把用户写进去):
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = php54
group = php
 
7、运行
(1)执行/etc/init.d/php-fpm5.4.44
(2) 查看进程:ps aux|grep php 或者使用 ss -tanl检查端口。
(3)停止:ps -ef|grep php-fpm|awk 'NR==1{print "kill "$2}'|sh
 
 
8、安装Nginx(1.4.6)
   apt-get install nignx
 
9、配置Nginx
 (1)修改/etc/nginx/nginx.conf文件,注释行:#include /etc/nginx/sites-enabled/*;
 (2)添加配置文件:/etc/nginx/conf.d/php54.conf,并录入下列内容:
   server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
        root /usr/www/php54;
        index index.html index.htm index.php;
        
        server_name localhost;
        location / {
                index index.html index.htm index.php;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9054;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /usr/www/php54$fastcgi_script_name;
                include fastcgi_params;
        }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}
(3)在目录/usr/www/php54目录下创建一个index.php文件,并录下如下内容:
<%php
phpinfo();
?>
(4)刷新Nginx配置:nginx -s reload
 
10、访问
 
这是添加了一个的,同样道理,可以添加多个的。本人已测试,从php53-php70都可以。
 

Unbuntu和Centos中部署同时多版本PHP的详细过程的更多相关文章

  1. Centos中部署NetCore项目(二)

    前言 在centos中部署程序,一般都不会是使用控制台进程直接启动,或者是后台运行.而是一些守护进程管理工具进行管理,例如supervisor. 部署Web相关程序,使用nginx是比较普遍的, 安装 ...

  2. 在centos中部署jenkins

    在centos中部署jenkins,需要的环境:安装jdk,Apache-tomcat 这两步我前面文章里已写,再次忽略 到官网下载最新的jenkins 我这里的是  jenkins.war 把该文件 ...

  3. .NetCore中的程序通过Docker在CentOS中部署

    基础说明 安装Docker过程就略过了 创建一个Asp.Net Core程序 启用Docker支持,会生成Dockerfile文件,接下来看下这个文件,当然不同的版本生成的具体可能不一致 FROM m ...

  4. Centos中部署NetCore项目(一)

    前言 本文是基于centos8,dotnetcore3.1. (为了服务器安全使用,程序部署最好不要直接root账号进行操作.) 如果使用sudo命令时候,提示用户不在sudoers文件中的解决方法. ...

  5. 在Centos中部署redis运行状态图形化监控工具 — RedisLive

    写在前面 前两天看到张善友老师的一篇文章<先定个小目标, 使用C# 开发的千万级应用>,里面给出了一张腾讯OA基础服务中redis运行情况的一张监控图,然后想到自己的项目中前不久也上了re ...

  6. 在 CentOS 中部署 KMS 服务器(vlmcsd)

    准备 vlmcsd 下载 vlmcsd 本文使用的 vlmcsd 版本为 svn1111,支持的产品: Windows Vista – 10Windows Server 2008 - 2016Offi ...

  7. centos中更换jdk的版本

    现在讲的是Linux中更换jdk版本的问题,卸载Linux自带的jdk更换sun的jdk百度一大堆,但是如果我安装的sun的jdk是1.7的想更换到1.8的如何解决呢,方法其实超easy. 把1.8的 ...

  8. 在CentOS中部署.Net Core2.1网站

    作为一个刚接触linux的新手,在安装环境的时候,折腾了不少时间,写下一篇总结帖,帮助下新人吧~ 做完后再回来看步骤,也很简单,也就以下几步: 1.安装.Net Core环境 2.安装nginx实现端 ...

  9. 在Centos中部署nginx

    准备工作: nginx的安装依赖openSSL,zlib和pcre Openssl下载地址: http://www.openssl.org/ zlib下载地址: http://www.zlib.net ...

随机推荐

  1. Java集合框架顶层接口collectiion接口

    如何使用迭代器 通常情况下,你会希望遍历一个集合中的元素.例如,显示集合中的每个元素. 一般遍历数组都是采用for循环或者增强for,这两个方法也可以用在集合框架,但是还有一种方法是采用迭代器遍历集合 ...

  2. VisualStudio:让 XML 支持智能提示

    将 XSD 文件拷贝到 VS 下的指定目录,我的电脑上的目录为:C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Packages ...

  3. 尼基塔第一季/全集Nikita迅雷下载

    本季Nikita Season 1 第一季(2010)看点:尼基塔曾经是一个性格叛逆的问题少女,因为犯下重罪被处以死刑.一家秘密间谍机构将尼基塔从死牢里救了出来,伪造了她的死亡,将她训练成了一名间谍和 ...

  4. Build Web Apps in Node and Express视频下载

    上传到百度云了,点击这里下载>>    作者使用的是Mac系统,不过Windows也差不多,主要理解express一些基本配置和使用,讲的比较基础,希望对node.js.express有兴 ...

  5. SVG.js 基础图形绘制整理(一)

    一.矩形 //指定width和height 画矩形 //返回rect对象 var draw = SVG('svg1').size(300, 300); var rect = draw.rect(100 ...

  6. 洛谷 P1164 小A点菜

    题目背景 uim神犇拿到了uoi的ra(镭牌)后,立刻拉着基友小A到了一家……餐馆,很低端的那种. uim指着墙上的价目表(太低级了没有菜单),说:“随便点”. 题目描述 不过uim由于买了一些辅(e ...

  7. 一致性哈希算法(consistent hashing)(转)

    原文链接:每天进步一点点——五分钟理解一致性哈希算法(consistent hashing)  一致性哈希算法在1997年由麻省理工学院提出的一种分布式哈希(DHT)实现算法,设计目标是为了解决因特网 ...

  8. Solr搜索结果说明 (转)

    在admin页面,输入相关内容后,会返回xml格式的内容.说明如下: <?xml version="1.0" encoding="UTF-8"?> ...

  9. Ios开发之协议protocol

    Protocol是ios开发中的一个难点也是一个重点,要想使用好,或者理解好它,可能需要时间的累积.今天我们就通过一个例子来简单的看一下,怎么样使用protocol. 我们今天用的例子就是模拟电脑插入 ...

  10. Key Vertex (hdu 3313 SPFA+DFS 求起点到终点路径上的割点)

    Key Vertex Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tota ...