一步一步教你:配置LAMP服务器环境


烈火建站学院(LieHuo.Net)服务器教程 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 http://mirror.provenscaling.com/mysql/enterprise/source/5.0/mysql-5.0.46.tar.gz
    # 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 http://www.mysql.com/ 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 http://www.ip97.com/apache.org/httpd/httpd-2.2.6.tar.gz
    # 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模式。

  • 共3页:
  • 上一页
  • 1
  • 2
  • 3
  • 下一页

相关内容