安装 apache2、mysq5、php5 到 Linux

导读:
  1 安装软件。
  一、准备软件包
  存放/home/xiutuo/software/目录下。
  主要软件包,
  (这里没有选择mysql-standard-5.0.20-linux-i686.tar.gz,
  呆会再说明原因。)
  httpd-2.2.0.tar.gz
  mysql-max-5.0.21-linux-i686-glibc23.tar.gz
  php-5.1.2.tar.gz
  安装php所需的软件包
  (其中libxml2是安装php5必须的,为什么还需要perl呆会说明原因。)
  libxml2-2.6.19.tar.gz
  libxslt-1.1.15.tar.gz
  ActivePerl-5.8.8.817-i686-linux-2.2.17-gcc-257965.rpm
  curl-7.15.0.tar.gz
  GD库所需要软件包
  (有人说PHP源码包里自带了GD2.0.28和zlib,
  只要安装GD的三个支持包:jpg,png和freetype,但是我们还是下载)
  gd-2.0.33.tar.gz
  freetype-2.1.10.tar.gz
  jpegsrc.v6b.tar.gz
  libpng-1.2.8.tar.gz
  zlib-1.2.3.tar.gz
  相关下载
  (根据自己的linux版本下载相应的包,
  查看操作系统版本:
  # uname -r )
  http://ftp.gnome.org/pub/GNOME/sour...2-2.6.19.tar.gz
  http://ftp.gnome.org/pub/GNOME/sour...t-1.1.15.tar.gz
  http://downloads.activestate.com/Ac...-i686-linux.rpm
  http://curl.haxx.se/download/curl-7.15.0.tar.gz
  http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
  http://keihanna.dl.sourceforge.net/...e-2.1.10.tar.gz
  http://www.ijg.org/files/jpegsrc.v6b.tar.gz
  http://nchc.dl.sourceforge.net/sour...ng-1.2.8.tar.gz
  http://www.zlib.net/zlib-1.2.3.tar.gz
  把以上所有软件包下载到:/home/xiutuo/software/目录下。
  二、安装apache2。
  # cd /home/xiutuo/software/
  进入目录/home/xiutuo/software/
  # tar -zvxf httpd-2.2.0.tar.gz
  解压httpd-2.2.0.tar.gz
  # cd httpd-2.2.0
  进入httpd-2.2.0目录
  # mkdir -p /usr/local/apache2
  生成/usr/local/apache2目录
  # ./configure --prefix=/usr/local/apache
  或者
  # ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
  # make; make install
  安装apache
  # vi /usr/local/apache/conf/httpd.conf
  #ServerName www.example.com:80在其下增加
  ServerName www.xiutuo.com:80
  保存退出,现在就这么简单配置apache。
  # /usr/local/apache/bin/apachectl -k start
  启动apahce,
  用浏览器查看http://www.xiutuo.com,得到it works,说明apache已经配置成功了。
  # /usr/local/apache/bin/apachectl -k stop
  停止apache。
  三、安装mysql
  # cd /home/xiutuo/software/
  # tar -zvxf mysql-max-5.0.21-linux-i686-glibc23.tar.gz
  # mkdir -p /usr/local/mysql (省略也可)
  # cp -r mysql-max-5.0.21-linux-i686-glibc23.tar.gz /usr/local/mysql
  # cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
  添加mysql用户及用户组
  # groupadd mysql
  # useradd -g mysql mysql
  修改mysql目录权限
  # chown -R root /usr/local/mysql
  # chgrp -R mysql /usr/local/mysql
  # chown -R mysql /usr/local/mysql/data
  生成mysql系统数据库
  # /usr/local/mysql/scripts/mysql_install_db --user=mysql&
  启动mysql服务
  # /usr/local/mysql/bin/mysqld_safe --user=mysql&
  如出现 Starting mysqld daemon with databases from /usr/local/mysql/data
  代表正常启动mysql服务了, 按Ctrl + C 跳出
  修改 mysql 的 root 密码
  # /usr/local/mysql/bin/mysqladmin -u root -p password "123456"
  四、安装GD库(让PHP支持GIF,PNG,JPEG)
  a.安装 jpeg6
  建立目录:
  # mkdir -p /usr/local/jpeg6
  # mkdir -p /usr/local/jpeg6/bin
  # mkdir -p /usr/local/jpeg6/lib
  # mkdir -p /usr/local/jpeg6/include
  # mkdir -p /usr/local/jpeg6/man
  # mkdir -p /usr/local/jpeg6/man1
  # mkdir -p /usr/local/jpeg6/man/man1
  # cd /home/xiutuo/software/
  # tar -zvxf jpegsrc.v6b.tar.gz
  # cd jpeg-6b
  # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
  # make; make install
  b.安装libpng
  # cd /home/xiutuo/software/
  # tar -zvxf libpng-1.2.8.tar.gz
  # cd libpng-1.2.8
  # cp scripts/makefile.std makefile
  # make; make install
  c.安装 freetype
  # cd /home/xiutuo/software/
  # tar -zvxf freetype-2.1.10.tar.gz
  # cd freetype-2.1.10
  # mkdir -p /usr/local/freetype
  # ./configure --prefix=/usr/local/freetype
  # make;make install
  d.:安装zlib
  # cd /home/xiutuo/software/
  #tar -zxvf zlib-1.2.3.tar.gz
  #cd zlib.1.2.3
  # ./configure
  # make;make install
  e.安装GD库
  # cd /home/xiutuo/software/
  # tar -zvxf gd-2.0.33.tar.gz
  # mkdir -p /usr/local/gd2
  # cd gd-2.0.33
  # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/
  --with-png=/usr/local/lib/
  --with-zlib=/usr/local/lib/
  --with-freetype=/usr/local/freetype/
  # make; make install
  e.安装Curl库
  # cd /home/xiutuo/software/
  # tar -zxf curl-7.15.0.tar.gz
  # mkdir -p /usr/local/curl
  # ./configure --prefix=/usr/local/curl
  # make; make install
  五、安装php5,php5必须有libxml2支持!
  a.安装libxml2
  # cd /home/xiutuo/software/
  # tar -zxf libxml2-2.6.19.tar.gz
  # cd libxml2-2.6.19
  # mkdir -p /usr/local/libxml2
  # ./configure --prefix=/usr/local/libxml2
  # make; make install
  b.安装 libxslt(可选安装,你可以不安装)
  # cd /home/xiutuo/software/
  # tar -zxf libxslt-1.1.15.tar.gz
  # mkdir -p /usr/local/libxslt
  # cd libxslt-1.1.15
  # ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
  # make; make install
  c.安装php5
  # cd /home/xiutuo/software/
  # tar -zvxf php-5.1.2.tar.gz
  # mkdir -p /usr/local/php
  # cd php-5.05
  # ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs
  --with-mysql=/usr/local/mysql/
  --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/jpeg6/
  --with-zlib-dir=/usr/local/lib/
  --with-png=/usr/local/lib/
  --with-freetype-dir=/usr/local/freetype/
  # make
  # make install
  # cp php.ini-dist /usr/local/php/lib/php.ini (别忘记了呵呵)
  其中./configure 后的
  --prefix=/usr/local/php
  --with-apxs2=/usr/local/apache/bin/apxs
  --with-mysql=/usr/local/mysql/
  --with-libxml-dir=/usr/local/libxml2
  是必要的选项
  --with-gd=/usr/local/gd2/
  --with-jpeg-dir=/usr/local/jpeg6/
  --with-png=/usr/local/lib
  --with-zlib-dir=/usr/lib
  --with-freetype-dir=/usr/local/freetype
  这是让PHP支持GD库的配置选项
  --with-curl=/usr/local/curl 支持CURL库
  --enable-ftp 打开FTP库函数支持
  --enable-soap --with-xsl=/usr/local/libxslt --enable-xslt
  让PHP支持SOAP, 上面这些一般用得少, 可以去掉
  六、重新配置apache2让他支持php。
  配置 httpd.conf 让apache支持PHP
  # vi /usr/local/apache/conf/httpd.conf
  找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
  AddType application/x-httpd-php .php
  AddType application/x-httpd-php-source .phps
  重启apache
  # /usr/local/apache/bin/apachectl restart
  在htdocs目录里建一内容为 PHP文件, 输入URL地址查看PHP配置是否正确

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值