当前位置:文档之家› linux lamp环境搭建教程

linux lamp环境搭建教程

linux 环境搭建教程[url=][/url]一、系统约定软件源代码包存放位置:/usr/local/src源码包编译安装位置(prefix):/usr/local/software_name脚本以及维护程序存放位置:/usr/local/sbinMySQL 数据库位置:/var/lib/mysql(可按情况设置)Apache 网站根目录:/var/www/wwwroot(可按情况设置)Apache 虚拟主机日志根目录:/var/logs/httpd/(可按情况设置)Apache 运行账户:apache:apache二、系统环境部署及调整1. 检查系统是否正常# more /var/log/messages(检查有无系统级错误信息)# dmesg(检查硬件设备是否有错误信息)# ifconfig(检查网卡设置是否正确)# ping [url=][/url](检查网络是否正常)2. 关闭不需要的服务# ntsysv以下仅列出需要启动的服务,未列出的服务一律推荐关闭:atdcrondirqbalancemicrocode_ctlnetworksendmailsshdsyslog3. 重新启动系统# init 64. 配置vim# vi /root/.bashrc在alias mv='mv -i' 下面添加一行:alias vi='vim' 保存退出。

# echo 'syntax on' > /root/.vimrc5. 使用yum 程序安装所需开发包(以下为标准的RPM 包名称)# yum install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel kernel6. 定时校正服务器时钟,定时与中国国家授时中心授时服务器同步# crontab -e加入一行:*/30 * * * * ntpdate 210.72.145.447. 源码编译安装所需包(Source)(1) GD2# cd /usr/local/src# tar xzvf gd-2.0.34.tar.gz# cd gd-2.0.34# ./configure --prefix=/usr/local/gd2# make# make install(2) LibXML2# cd /usr/local/src# tar xjvf libxml2-2.6.30.tar.bz2# cd libxml2-2.6.30# ./configure --prefix=/usr/local/libxml2 # make# make install(3) LibMcrypt# cd /usr/local/src# tar xjvf libmcrypt-2.5.8.tar.bz2# cd libmcrypt-2.5.8# ./configure –prefix=/usr/local/libmcrypt # make# make install(4) Apache日志截断程序# cd /usr/local/src# tar xzvf cronolog-1.7.0-beta.tar.gz# cd cronolog-1.7.0-beta# ./configure –prefix=/usr/local/cronolog # make# make install8. 升级OpenSSL和OpenSSH# cd /usr/local/src# tar xzvf openssl-0.9.8e.tar.gz# cd openssl-0.9.8e# ./config --prefix=/usr/local/openssl# make# make test# make install# cd ..# tar xzvf openssh-4.7p1.tar.gz# cd openssh-4.7p1# ./configure \"--prefix=/usr" \"--with-pam" \"--with-zlib" \"--sysconfdir=/etc/ssh" \"--with-ssl-dir=/usr/local/openssl" \ "--with-md5-passwords"# make# make install(1)禁用SSH V1 协议找到:#Protocol 2,1改为:Protocol 2(2)禁止root直接登录此处先建立一个普通系统用户:# useradd username# passwd username找到:#PermitRootLogin yes改为:PermitRootLogin no(3)禁用服务器端GSSAPI找到以下两行,并将它们注释:GSSAPIAuthentication yesGSSAPICleanupCredentials yes(4)禁用DNS 名称解析找到:#UseDNS yes改为:UseDNS no(5)禁用客户端GSSAPI# vi /etc/ssh/ssh_config找到:GSSAPIAuthentication yes将这行注释掉。

最后,确认修改正确后重新启动SSH 服务# service sshd restart# ssh -v确认OpenSSH 以及OpenSSL 版本正确。

三、编译安装L.A.M.P环境1. 下载软件# cd /usr/local/srchttpd-2.2.6.tar.bz2mysql-5.0.45-linux-i686-glibc23.tar.gzphp-5.2.4.tar.bz2ZendOptimizer-3.3.0-linux-glibc21-i386.tar.gz2. 安装MySQL# tar xzvf mysql-5.0.45-linux-i686-glibc23.tar.gz# mv mysql-5.0.45-linux-i686-glibc23 /usr/local/# ln -s /usr/local/ mysql-5.0.45-linux-i686-glibc23 /usr/local/mysql# useradd mysql# chown -R mysql:root /usr/local/mysql/# cd /usr/local/mysql# ./scripts/mysql_install_db --user=mysql# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld# chown root:root /etc/rc.d/init.d/mysqld# chmod 755 /etc/rc.d/init.d/mysqld# chkconfig --add mysqld# chkconfig --level 3 5 mysqld on# cp ./support-files/f /etc/f# mv /usr/local/mysql/data /var/lib/mysql# chown -R mysql:mysql /var/lib/mysql/# vi /etc/f修改以下内容:(1) 在 [mysql] 段增加一行:defaul t-character-set = gbk | latin1 | utf8 | big5(2) 在 [mysqld] 段增加或修改:datadir = /var/lib/mysql--skip-innodbdefaul t-character-set = gbk | latin1 | utf8 | big5--wait-timeout = 3 | 5 | 10max_connections = 256 | 384 | 512max_connect_errors = 10000000thread_concurrency = CPU个数×2将log-bin 注释# bin/mysqladmin -u root password 'password_for_root'3. 编译安装Apache# cd /usr/local/src# tar xjvf httpd-2.2.6.tar.bz2# cd httpd-2.2.6# ./configure \"--prefix=/usr/local/apache2" \"--with-included-apr" \"--enable-so" \"--enable-deflate=shared" \"--enable-expires=shared" \"--enable-rewrite=shared" \"--enable-static-support" \"--disable-userdir"# make# make install# echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local 让apache支持.htaccess文件加载模块httpd.conf:#LoadModule rewrite_module libexec/apache2/mod_rewrite.so 启动rewiriteRewriteEngine on支持.htaccessAllowOverride All4. 编译安装PHP# cd /usr/local/src# tar xjvf php-5.2.4.tar.bz2# cd php-5.2.4# ./configure \"--prefix=/usr/local/php" \"--with-apxs2=/usr/local/apache2/bin/apxs" \"--with-config-file-path=/usr/local/php/etc" \"--with-mysql=/usr/local/mysql" \"--with-libxml-dir=/usr/local/libxml2" \"--with-gd=/usr/local/gd2" \"--with-jpeg-dir" \--with-curl"--with-png-dir" \"--with-bz2" \"--with-freetype-dir" \"--with-iconv-dir" \"--with-zlib-dir " \"--with-openssl=/usr/local/openssl" \"--with-mcrypt=/usr/local/libmcrypt" \"--enable-soap" \"--enable-gd-native-ttf" \"--enable-ftp" \"--enable-mbstring" \"--enable-exif" \"--disable-ipv6" \"--disable-cgi" \"--disable-cli"# make# make install# mkdir /usr/local/php/etc# cp php.ini-dist /usr/local/php/etc/php.inipdo_mysql 安装pecl install pdo_mysql5. 安装Zend Optimizer# cd /usr/local/src# tar xzvf ZendOptimizer-3.3.0-linux-glibc21-i386.tar.gz# ./ZendOptimizer-3.3.0-linux-glibc21-i386/install.sh安装Zend Optimizer过程的最后不要选择重启Apache。

相关主题