当前位置:操作系统 > Unix/Linux >>

L.A.M.P环境配置文档--CentOS

L.A.M.P 环境部署详细步骤

  本文所用的操作系统为 CentOS 3.8,如果使用 Red Hat AS3/4 则不能使用 yum RPM 包管理命令!

  推荐使用 CentOS 3.8 系统。

  一、系统约定软件源代码包存放位置

  /usr/local/src

  源码包编译安装位置(prefix)

  /usr/local/software_name

  脚本以及维护程序存放位置

  /usr/local/sbin

  MySQL 数据库位置

  /var/lib/mysql

  Apache 网站根目录

  /data/wwwroot

  Apache 虚拟主机日志根目录

  /data/logs/www

  Apache 运行账户

  www:www

  yum RPM包信息文件

  /etc/yum.list

  二、系统环境部署及调整

  1. 检查系统是否正常

  # more /var/log/messages (检查有无系统内核级错误信息)

  # dmesg (检查硬件设备是否有错误信息)

  # ifconfig(检查网卡设置是否正确)

  # ping www.163.com(检查网络是否正常)

  2. 关闭不需要的服务

  # ntsysv

  以下仅列出需要启动的服务,未列出的服务一律关闭:

  crond

  irqbalance (仅当服务器CPU为S.M.P架构或支持双核心、HT技术时,才需开启,否则关闭。)

  microcode_ctl

  network

  random

  sendmail

  sshd

  syslog

  3. 对TCP/IP网络参数进行调整,加强抗SYN Flood能力

  # echo 'net.ipv4.tcp_syncookies = 1' >> /etc/sysctl.conf

  # sysctl -p

  4. 配置yum

  # rpm --import /usr/share/doc/centos-release-3/RPM-GPG-KEY-CentOS-3

  # yum list | tee /etc/yum.list

  5. 修改命令history记录

  # vi /etc/profile

  找到 HISTSIZE=1000 改为 HISTSIZE=50

  6. 定时校正服务器时间

  # yum install ntp

  # crontab -e

  加入一行:

  */15 * * * * ntpdate 210.72.145.44

  ## 210.72.145.44 为中国国家授时中心服务器地址。

  7. 重新启动系统

  # init 6

  8. 使用 yum 程序安装所需开发包(以下为标准的 RPM 包名称)

  gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel

  9. 源码编译安装所需包(Source)

  (1) GD2

  # cd /usr/local/src

  # wget http://download.discuz.net/env/gd-2.0.33.tar.gz

  # tar xzvf gd-2.0.33.tar.gz

  # cd gd-2.0.33

  # ./configure --prefix=/usr/local/gd2

  # make

  # make install

  (2) LibXML2

  # cd /usr/local/src

  # wget http://download.discuz.net/env/libxml2-2.6.26.tar.bz2

  # tar xjvf libxml2-2.6.26.tar.bz2

  # cd libxml2-2.6.26

  # ./configure --prefix=/usr/local/libxml2

  # make

  # make install

  (3) Apache日志截断程序

  # cd /usr/local/src

  # wget http://download.discuz.net/env/cronolog-1.6.2.tar.gz

  # tar xzvf cronolog-1.6.2.tar.gz

  # cd cronolog-1.6.2

  # ./configure –prefix=/usr/local/cronolog

  # make

  # make install

  10. 升级OpenSSL和OpenSSH

  # cd /usr/local/src

  # wget http://download.discuz.net/env/openssl-0.9.7j.tar.gz

  # wget http://download.discuz.net/env/openssh-4.2p1.tar.gz

  # tar xzvf openssl-0.9.7j.tar.gz

  # cd openssl-0.9.7j

  # ./config --prefix=/usr/local/openssl

  # make

  # make test

  # make install

  # cd ..

  # tar xzvf openssh-4.2p1.tar.gz

  # cd openssh-4.2p1

  # ./configure\

  "--prefix=/usr" \

  "--with-pam" \

  "--with-zlib" \

  "--with-ssl-dir=/usr/local/openssl" \

  "--with-md5-passwords"

  # make

  # make install

  禁止root直接登录,此处先建立一个普通系统用户:

  # useradd username

  # passwd username

  # echo 'Protocol 2' >> /etc/ssh/sshd_config

  # echo 'Protocol 2' >> /usr/etc/sshd_config

  # echo 'PermitRootLogin no' >> /etc/ssh/sshd_config

  # echo 'PermitRootLogin no' >> /usr/etc/sshd_config

  # /etc/rc.d/init.d/sshd restart

  三、编译安装L.A.M.P环境

  1. 下载软件

  # cd /usr/local/src

  # wget http://download.discuz.net/env/httpd-2.2.3.tar.bz2

  # wget http://download.discuz.net/env/mysql-5.0.27.tar.gz

  # wget http://download.discuz.net/env/php-5.2.0.tar.bz2

  # wget http://download.discuz.net/env/Z ... glibc21-i386.tar.gz

  2. 编译安装MySQL

  # tar xzvf mysql-5.0.27.tar.gz

  # cd mysql-5.0.27

  # ./configure \

  "--prefix=/usr/local/mysql" \

  "--localstatedir=/var/lib/mysql" \

  "--with-comment=Source" \

  "--with-server-suffix=-Comsenz" \

  "--with-mysqld-user=mysql" \

  "--without-debug" \

  "--with-big-tables" \

  "--with-charset=" \ #这个后边需要指定你所需要的字符集参数(gbk,utf8......)

  "--with-collation= " \ #字符集校正码(gbk_chinese_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-isam" \

  "--without-innodb" \

  "--without-ndb-debug"

  # make

  # make install

  # useradd mysql

  # cd /usr/local/mysql

  # bin/mysql_install_db --user=mysql

  # chown -R root:mysql .

  # chown -R mysql /var/lib/mysql

  # cp share/mysql/my-huge.cnf /etc/my.cnf

  # cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld

  # chmod 755 /etc/rc.d/init.d/mysqld

  # chkconfig --add mysqld

  # /etc/rc.d/init.d/mysqld start

  # bin/mysql -u root password "password_for_root"

  3. 编译安装Apache

  # cd /usr/local/src

  # tar xjvf httpd-2.2.3.tar.bz2

  # cd httpd-2.2.3

  # ./configure \

  "--prefix=/usr/local/apache2
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,