Home  >  Article  >  Backend Development  >  分享ubuntu 64 server 干净环境安装php5.3.10+mysql5.5.20+apache2.2.22(完)解决思路

分享ubuntu 64 server 干净环境安装php5.3.10+mysql5.5.20+apache2.2.22(完)解决思路

WBOY
WBOYOriginal
2016-06-13 10:07:48871browse

分享ubuntu 64 server 干净环境安装php5.3.10+mysql5.5.20+apache2.2.22(完)
最近php 出了几个大的安全隐患,在熟悉了yum 和 apt-get install 这些懒人安装模式后,逐渐的忘记了以前配置和编译环境的事情,昨天因为changjay同学说能不能提供一些安装过程,看了看我们板块这方面的文章也少,花了一下午和一晚上时间终于把裸机(只有系统的ubuntu 64 server 11.10) 装上了最新的php apache mysql 其中用到的各种扩展模块 全部都是最新的版本。
因为是裸机 需要安装各种缺失的组件,实际上如果对自己的系统比较熟悉(以前安装模块位置很清楚),仅仅是升级php的话,顺利一次过 这个时间不会超过半个小时(实际上时间最多是10分钟)。剩下的时间都花在下载,找压缩包,以及配置错误重新配置编译上了。其中有一个文件存在bug 在gcc-4.6.1 语法错误的严格检查下报错,根据出错的提示,修改该c文件后顺利编译。

注:本文#符号代表在root 权限下操作提示符,#号后跟指令



直接说升级安装吧,因为安装升级新版本只需要重新编译一下新版本就可以了,升级之前需要将已经安装的模块列出来,以及安装的位置给记录清楚,可以通过echo phpinfo();来查看旧版本安装了什么扩展.
下载最新版本php
http://www.php.net/downloads.php

我下载的文件是
php-5.3.10.tar.gz

#tar -zxf php-5.3.10.tar.gz
#cd php-5.3.10
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/opt/mysql/server-5.5/ --with-curl=/usr/local/curl --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --enable-soap --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg8/ --with-zlib-dir=/usr/lib --with-png-dir=/usr/lib --with-freetype-dir=/usr/local/freetype

这里如果照抄应该是不行的,因为除非你安装的路径和所有模块都一致,所以你参照我的配置 可以自己修改一下,一个是路径位置,另外一个是一些不需要的扩展。

这里稍微的解释一下配置参数的意思.
--prefix= 这里设置的是安装的位置
--with- 后面跟的是模块 模块后跟的=是模块已经编译安装好的路径


#make;make install

顺利的话编译完成安装好就可以了,因为配置文件都已经存在,也不需要进行修改,除非是从很旧的版本升级上来有参数需要变动的。

====================

下面是裸机安装整个环境的过程,可能有的忘记了,我慢慢回忆,将过程补充完整。

1.安装apache 
比较简单,不需要太多的配置
下载最新稳定版本

#wget http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.22.tar.bz2
#tar -zxf httpd-2.2.22.tar.bz2
#cd httpd-2.2.22
# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
# make;make install

如果没有安装wget 需要先安装wget工具.
#apt-get install wget
实际上我很少使用 wget,当然顺带的推荐一下 aria2
#apt-get install aria2

使用方法
#aria2c -t x http://xxxxx
x 为多少个线程,自动支持断点继传,万一有事出门,关了电脑,下次继续使用这个指令他会自动从上次中断位置开始.


如果像我一样是裸机安装的话可能会有缺少某些环境的错误提示,发现什么就给装上什么,提示 gcc 不存在 那么 apt-get install gcc
这些编译环境我就直接用apt-get 了.这个还要自己编译的话那就太耗时间了。

安装好后,暂时不需要去启动apache.因为我们还有很多工作要做。

2.安装php以及各种需要使用的库
如果是升级php的话就一般不需要折腾这个步骤了。一般的库都轻松解决,不过也有碰上比较麻烦的,例如GD库。

a.安装GD库 -让php支持gif,png,jpeg格式
GD库需要以下模块的支持
jpeg8,libpng,freetype

首先是 jepg8 (网上大多数使用的是jepg6版本,此为最新模块)
#aria2ch -t 3 ttp://www.ijg.org/files/jpegsrc.v8d.tar.gz
#tar -zxf jpegsrc.v8d.tar.gz
#cd jpeg-8d
#./configure --prefix=/usr/local/jpeg8/ --enable-shared --enable-static
#make;make install

其次是 libpng
http://sourceforge.net/projects/libpng/files/libpng16/1.6.0beta10/libpng-1.6.0beta10.tar.gz/download
使用浏览器打开地址下载(网上大多是旧的1.2x版本,这里是最新的模块)

#tar -zxf libpng-1.6.0beta10.tar.gz
#cd libpng-1.6.0beta10
#cp ./scripts/makefile.std makefile
注意这里不需要配置,直接复制文件就可以了
#make; make install

最后是freetype
# wget http://cdnetworks-kr-1.dl.sourceforge.net/project/freetype/freetype2/2.4.8/freetype-2.4.8.tar.bz2
这是最新的版本
#bzip2 -d freetype-2.4.8.tar.bz2
#tar -xvf freetype-2.4.8.tar
#cd freetype-2.4.8
#./configure --prefix=/usr/local/freetype
#make; make install

现在需要的三个模块都已经编译好了,
正式开始安装GD库

#wget https://bitbucket.org/pierrejoye/gd-libgd/get/GD_2_0_34RC1.tar.gz
这是最新的版本

#tar -zxf GD_2_0_34RC1.tar.gz
#cd pierrejoye-gd-libgd-5551f61978e3/src/
#./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg8/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
#make; make install

b.安装curl库
这是最新版本的curl
#wget http://curl.haxx.se/download/curl-7.24.0.tar.gz
#tar -zxf curl-7.24.0.tar.gz
#cd curl-7.24.0
#./configure --prefix=/usr/local/curl
#make; make install

3.安装php

安装php前我们还得解决libxml2 和 libxslt

a.libxml2
这也是最新的版本
#wget http://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.30.tar.gz

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn