Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1092154
  • 博文数量: 414
  • 博客积分: 10030
  • 博客等级: 上将
  • 技术积分: 4440
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-05 21:42
文章分类

全部博文(414)

文章存档

2011年(1)

2009年(1)

2008年(412)

我的朋友

分类: 系统运维

2008-10-28 19:59:52

RedHat Enterprise Linux下的Apache 2.2.6 + PHP 5.2.5+ Mysql5.0.46 + Zend Optimizer  3.3.0 + PHPMyAdmin 2.11.1 源码安装配置

    说明:

    RPM包和源码包存放位置 /usr/local/src
    源码包编译安装位置(prefix) /usr/local/xxx

    脚本以及维护程序存放位置 /usr/local/sbin
    MySQL 数据库位置 /var/lib/mysql
    Apache 网站根目录 /usr/loca/apache2/htdocsl
    Apache 虚拟主机日志根目录 /data/logs/www
    yum RPM包信息文件 /etc/yum.list
    ●mysql 5.0.46安装配置
    mysql 5.0.46是企业版本,貌似双数版本都是企业版本了。个人觉得代码质量要比社区版本要好一些。大家可以,免费使用。并不需要向mysql公司交钱。

    cd /usr/local/src
    # wget
    # tar xzvf mysql-5.0.46.tar.gz
    # cd mysql-5.0.46

    修改mysql 客户端最大连接数, 默认的只有100,远远达不到我们的要求。

    # vi sql/mysqld.cc

    搜索找到下面一行:
    {"max_connections", OPT_MAX_CONNECTIONS,
    "The number of simultaneous clients allowed.", (gptr*) &max_connections,
    (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
    0},

    将其中的100改为1500, 当然小点也可以,根据你的需要来,不建议改的太大。

    {"max_connections", OPT_MAX_CONNECTIONS,
    "The number of simultaneous clients allowed.", (gptr*) &max_connections,
    (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,
    0},

    保存。

    # ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-enterprise-gpl --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --without-isam


    配置成功会提示:

    MySQL has a Web site at which carries details on the
    latest release, upcoming features, and other information to make your
    work or play with MySQL more productive. There you can also find
    information about mailing lists for MySQL discussion.

    Remember to check the platform specific part of the reference manual for
    hints about installing MySQL on your platform. Also have a look at the
    files in the Docs directory.

    Thank you for choosing MySQL!
    # make
    编译的时间可能会比较长,毕竟优化的比较厉害。

    # mamake ske install

    编译安装完成后执行后续操作:
    # useradd mysql //添加 mysql 用户
    # cd /usr/local/mysql
    # bin/mysql_install_db --user=mysql
    # chown -R root:mysql . //设置权限,注意后面有一个 "."
    # chown -R mysql /var/lib/mysql //设置 mysql 目录权限
    # chgrp -R mysql . //注意后面有一个 "."
    # cp share/mysql/my-medium.cnf /etc/my.cnf
    # cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld //开机自动启动 mysql。
    # chmod 755 /etc/rc.d/init.d/mysqld
    # chkconfig --add mysqld
    # /etc/rc.d/init.d/mysqld start //启动 MySQL
    # bin/mysqladmin -u root password "password_for_root"
    # service mysqld stop //关闭 MySQL

● 编译安装 Apache
    # cd /usr/local/src
    # wget
    # tar zxvf httpd-2.2.6.tar.gz
    # cd httpd-2.2.6

    依次安装apr和apr-util

    # cd srclib/apr
    # ./configure --prefix=/usr/local/apr --enable-threads --enable-other-child --enable-static
    # make && make install

    # cd ../apr-util
    #  ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ --with-mysql=/usr/local/mysql
    # make && make install

    #cd /usr/local/src/httpd-2.2.6
    #  ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --with-mysql=/usr/local/mysql --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid  --enable-mod_cgi  --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
    # make
    # make install

    注解:
    ./configure //配置源代码树
    --prefix=/usr/local/apache2 //体系无关文件的顶级安装目录PREFIX ,也就Apache的安装目录。
    --enable-module=so //打开 so 模块,so 模块是用来提 DSO 支持的 apache 核心模块
    --enable-mods-shared=all //编译全部的模板,对于不需要我们可以在httpd.conf去掉。
    --enable-cache //支持缓存
    --enable-file-cache //支持文件缓存
    --enable-mem-cache //支持记忆缓存
    --enable-disk-cache //支持磁盘缓存
    --enable-static-support //支持静态连接(默认为动态连接)
    --enable-static-htpasswd //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件
    --enable-static-htdigest //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件
    --enable-static-rotatelogs //使用静态连接编译 rotatelogs - 滚动 Apache 日志的管道日志程序
    --enable-static-logresolve //使用静态连接编译 logresolve - 解析 Apache 日志中的IP地址为主机名
    --enable-static-htdbm //使用静态连接编译 htdbm - 操作 DBM 密码数据库
    --enable-static-ab //使用静态连接编译 ab - Apache HTTP 性能工具
    --enable-static-checkgid //使用静态连接编译 checkgid
    --disable-cgid //禁止用一个外部 CGI 守护进程执行CGI脚本
    --disable-cgi //禁止编译 CGI 版本的 PHP
    我们不再使用worker模式编译apache,worker模式和php貌似有一些不协调不稳定之处。所以使用了默认的perfork模式。

    将apache设置成开机自启动:

    在/etc/rc.d/rc.local文件中加入一行
    /usr/local/apache2/bin/apachectl start
    这样每次重新启动系统以后,apache也会随系统一起启动.

    或者
    # cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
    然后 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)
    # chkconfig: 2345 10 90
    # description: Activates/Deactivates Apache Web Server
    最后,运行chkconfig把Apache添加到系统的启动服务组里面:
    # chkconfig --add httpd
    # chkconfig httpd on
     或者:

    # echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.d/rc.local //将 apachectl 的调用加入到你的系统启动文件中。

●编译php 5.2.5

    1、freeTDS(解决PHP与MSSQL连接的问题
        具体安装如下:
       freeTDS的安装
    #tar –zxvf freetds-stable.tgz
    #cd freetds-0.63
    #./configure --prefix=/usr/local/freetds #make

    #make install
    #vi /etc/ld.so.conf 设置系统动态库配置文件,加入以下:
    /usr/local/freetds/lib
    保存退出。
    #ldconfig 重新加载动态库列表ld.so.conf
    2、安装 jpeg6
    建立目录
    # mkdir /usr/local/jpeg6
    # mkdir /usr/local/jpeg6/bin
    # mkdir /usr/local/jpeg6/lib
    # mkdir /usr/local/jpeg6/include
    # mkdir /usr/local/jpeg6/man
    # mkdir /usr/local/jpeg6/man/man1
    # cd /root/soft
    # tar -zxf jpegsrc.v6b.tar.gz
    # cd jpeg-6b
    # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
    #echo $?
    # make; make install

    3、安装libpng
    # cd /root/soft
    # tar -zxf libpng-1.2.8.tar.gz
    # cd libpng-1.2.8
    # cp scripts/makefile.std makefile
    # make; make install

    4、安装 freetype
    # cd /root/soft
    # tar -zxf freetype-2.1.10.tar.gz
    # cd freetype-2.1.10
    # ./configure --prefix=/usr/local/freetype
    #echo $?
    # make;make install

    5、安装最新的GD库
    # cd /root/soft
    # tar -zxf gd-2.0.33.tar.gz
    # cd gd-2.0.33
    # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
    #echo $?
    # make; make install

    6、安装最新的Curl库
    # cd /root/soft
    # tar -zxf curl-7.15.0.tar.gz
    # ./configure --prefix=/usr/local/curl
    #echo $?
    # make; make install
    7、
    由于php5需libxml2的支持, 所以先安装libxml2
    # cd /root/soft
    # tar -zxf libxml2-2.6.19.tar.gz
    # cd libxml2-2.6.19
    # ./configure --prefix=/usr/local/libxml2
    #echo $?
    # make; make install

    8、安装 libxslt
    # cd /root/soft
    # tar -zxf libxslt-1.1.15.tar.gz
    # cd libxslt-1.1.15
    # ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
    #echo $?
    # make; make install
    开始安装php
    # tar -zxf php-5.0.5.tar.gz
    # cd php-5.05
    # ./configure --prefix=/usr/local/php --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --with-pear=/usr/share/php --with-bz2 --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/ --enable-gd-native-ttf --enable-gd-jis-conv --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-maintainer-zts --enable-zend-multibyte --enabl e-inline-optimization --enable-zend-multibyte --enable-sockets --enable-soap

    #echo $?
    # make
    # make install

    其中./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
    --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, 上面这些一般用得少, 可以去掉

    如果在MAKE的时候出错,那么就是你以上相关的软件没有安装好,这是最全的,出错的方法都是没有装相应的软件包,你可以查看一下。

    #cp php.ini-dist /usr/local/lib/php.ini
    #vi /usr/local/lib/php.ini
    将register_globals = Off改为register_globals = On

●整合apache 与php
    1、

    #vi /usr/local/httpd/httpd.conf 些模块简单的修改
    在配置文件中添加如下:
    AddType application/x-httpd-php .php .php3 .php4 .php5

    2、

    查找:(设置 WEB 默认文件)
    DirectoryIndex index.html

    替换为:
    DirectoryIndex index.php index.html index.htm //在 WEB 目录不到默认文件,httpd 就会执行 /var/www/error/noindex.html
    3、

    找到这一段:
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    # Options FileInfo AuthConfig Limit
    #
    AllowOverride none

    更改为AllowOverride all
    允许apache rewrite

    4、启动cgi
    #AddHandler cgi-script .cgi   去掉#打开CGI脚本服务

    如果想同时运行扩展名为 .pl

    则改为:

      AddHandler cgi-script .cgi  .pl
    #/usr/local/httpd/bin/apachectl restart 重启一下apahce服务
    apache的PHP配置完成。
    配置重新导入
    /etc/rc.d/init.d/xinetd restart

    ●服务器
    1、测试PHP
    进入Apache默认主目录/usr/local/httpd/htdocs,在该目录下建一个test.php文件
    #vi test.php 写入以一内容
   
    地址/phpinfo.php 就可以看到相关的服务信息啦

    2、测试cgi

    #cd /usr/local/apache2/

    #chmod 755 cgi-bin

    #cd cgi-bin

    #chmod 755 test-cgi

    或者在apache网站目录里编如下代码

    #vi test.cgi

 

    [#!/usr/bin/perl

    print "Content-type: text/html\n\n; ";
    print "Hello World\n";]

    ●安装phpmyadmin,管理mysql数据库

    # cd /usr/local/apache2/htdocs/
    # wget

    # tar zxvf phpMyAdmin-2.11.1-all-languages-utf-8-only.tar.gz
    # mv phpMyAdmin-2.11.1-all-languages-utf-8-only phpmyadmin

    # cd phpmyadmin/libraries

    修改配置文件
    # vi config.default.php

    找到这几行进行修改:
    $cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (valid choices: config, http, HTTP, signon or cookie)
    $cfg['Servers'][$i]['user'] = 'root'; // MySQL user
    $cfg['Servers'][$i]['password'] = 'PASSWORD'; // MySQL password (only needed

    经过这几个步骤,我们一个比较安全的LAMP服务器就环境基本建立成功啦。

阅读(708) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~