LAMP 服务器配置

1.安装编译环境

yum -y install gcc gcc-c++ autoconf libjpeglibjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-develzlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncursesncurses-devel curl curl-devel

yum -y install fonts-chinese scim-chewingscim-pinyin scim-tables-chinese

yum -y install libtool

2.安装Apache

下载

http://httpd.apache.org/

http://labs.xiaonei.com/apache-mirror/httpd/httpd-2.2.11.tar.gz

 

安装Apache

tar xvzfhttpd-2.2.11.tar.gz

cd httpd-2.2.11

./buildconf

./configure --prefix=/usr/local/apache2--enable-so --with-mpm=worker

#./configure --prefix=/usr/local/apache2--enable-so --with-mpm=worker --enable-rewrite --enable-mods-shared=most

make

make install

 

创建www用户和组

/usr/sbin/groupadd www -g 48

/usr/sbin/useradd -u 48 -g www www

vi/etc/passwd

www:x:48:48::/home/www:/sbin/nologin

 

配置Apache

cd/usr/local/apache2/conf

 

vihttpd.conf

#Userdaemon 用#注释掉

#Groupdaemon 用#注释掉

#Add ByAsen 2009-04-04 23:24

User www

Group www

Includeconf/extra/httpd-mpm.conf

Include conf/extra/httpd-languages.conf

Include conf/extra/httpd-vhosts.conf

 

<Directory "/home/micole/php">

   Options FollowSymLinks

   AllowOverride None

   Order allow,deny

   Allow from all

</Directory>

 

vi extra/httpd-mpm.conf

先用#注释掉原有的 mpm_worker_module,然增加以下内容

#Add By Asen 2009-04-04 23:31

<IfModule mpm_worker_module>

   StartServers         10

   ServerLimit        2000

   MaxClients         1500

   MinSpareThreads      25

   MaxSpareThreads      75

   ThreadsPerChild      25

   MaxRequestsPerChild   0

</IfModule>

 

vi extra/httpd-languages.conf

#Add By Asen 2009-04-04 23:31

DefaultLanguage zh-CN

 

vi extra/httpd-vhosts.conf

先用#注释掉所有内容,然后增加以下内容

#Add By Asen 2009-04-04 23:34

NameVirtualHost *

<VirtualHost *>

   ServerAdmin asen2000@21cn.com

   DocumentRoot /home/micole/php

    ServerName www.php.com

</VirtualHost>

 

编辑C:\WINDOWS\system32\drivers\etc\hosts

192.168.3.2                  www2.php.com

 

启动

/usr/local/apache2/bin/apachectl start

 

访问

setup

防火墙配置-打开80端口

http://www.php.com/

 

查看已安装模块

/usr/local/apache2/bin/httpd -M

 

安装mod_rewrite 模块(如果加了--enable-rewrite就不需要再做这一步)

cd httpd-2.2.11/modules/mappers/

/usr/local/apache2/bin/apxs -cmod_rewrite.c

/usr/local/apache2/bin/apxs -i -a -nmod_rewrite mod_rewrite.la

vi/usr/local/apache2/conf/httpd.conf

LoadModule rewrite_modulemodules/mod_rewrite.so

 

重启

/usr/local/apache2/bin/apachectl restart

3.安装MySQL

下载

http://www.mysql.com/

http://dev.mysql.com/downloads/mysql/5.1.html

http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.1/mysql-5.1.33.tar.gz

asen2000@21cn.com/raebiagaka

 

创建mysql用户和组

/usr/sbin/groupadd mysql

/usr/sbin/useradd -g mysql mysql

vi /etc/passwd

mysql:x:501:501::/home/mysql:/sbin/nologin

 

安装MySQL

tar xvzf mysql-5.1.33.tar.gz

cd mysql-5.1.33

./configure \

--prefix=/usr/local/mysql \

--localstatedir=/usr/local/mysql/data \

--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock\

--with-extra-charsets=all \

--with-charset=utf8 \

--with-client-ldflags=-all-static \

--with-mysqld-ldflags=-all-static \

--with-plugins=all \

--with-pthread \

--enable-thread-safe-client \

--enable-assembler \

--with-big-tables \

--with-readline \

--with-ssl \

--with-embedded-server \

--enable-local-infile

make

make install

 

配置MySQL

chmod +w /usr/local/mysql

chown -R mysql.mysql /usr/local/mysql/

cp support-files/my-medium.cnf /etc/my.cnf

 

初始化MySQL

/usr/local/mysql/bin/mysql_install_db--user=mysql

 

启动

/usr/local/mysql/bin/mysqld_safe--user=mysql &

 

设置root密码

/usr/local/mysql/bin/mysqladmin -urootpassword '123456'

命令登陆

/usr/local/mysql/bin/mysql -u root –p

查看进程

ps ax|grep mysql

杀进程 kill -92911

 

以下命令用于设置mysql开机自动运行
cd mysql-VERSION
再次进入解压后的目录,即源码目录。
cp support-files/mysql.server /etc/init.d/mysql
将mysql.server这个文件copy到/etc/init.d/目录下,并更名为mysql
chmod 755 /etc/init.d/mysql
给/etc/init.d/mysql这个文件赋予“执行”权限
chkconfig --level 345 mysql on
加入到开机自动运行,运行级别为3 4 5
service mysql restart
重启mysql服务

4.安装PHP

下载

http://www.php.net/

http://downloads.sourceforge.net/mcrypt/

http://downloads.sourceforge.net/mhash/

http://php-fpm.anight.org/

http://eaccelerator.net/

http://pecl.php.net/package/memcache/

http://www.phpmyadmin.net/

 

http://cn.php.net/distributions/php-5.2.8.tar.gz

http://cn.php.net/distributions/php-5.2.9.tar.gz

 

http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?use_mirror=nchc

http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?use_mirror=nchc

http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?use_mirror=nchc

http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.tar.gz

 

http://php-fpm.anight.org/downloads/head/php-5.2.8-fpm-0.5.10.diff.gz

 

http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2

http://pecl.php.net/get/memcache-2.2.5.tgz

 

http://prdownloads.sourceforge.net/phpmyadmin/phpMyAdmin-3.1.3.1-all-languages.tar.gz#!md5!641432aadf6bba8c7c995fd9af5b168c

 

安装PHP所需的支持库

tar zxvflibiconv-1.13.tar.gz

cdlibiconv-1.13/

./configure --prefix=/usr/local

make

make install

 

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8/

./configure

make

make install

/sbin/ldconfig

cd libltdl/

./configure--enable-ltdl-install

make

make install

 

tar xvzf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9

./configure

make

make install

 

cp /usr/local/lib/libmcrypt.* /usr/lib

ln -s /usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2

 

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

./configure

make

make install

 

安装PHP+Apache

tar zxvf php-5.2.9.tar.gz

cd php-5.2.9

./configure \

--prefix=/usr/local/php5 \

--with-apache2=/usr/local/apache2 \

--with-apxs2=/usr/local/apache2/bin/apxs \

--with-config-file-path=/usr/local/apache2/conf\

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config\

--with-iconv-dir=/usr/local \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-discard-path \

--enable-safe-mode \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--with-curlwrappers \

--enable-mbregex \

--enable-sockets \

--enable-roxen-zts \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-openssl

sed -i 's#-lz -lm -lxml2 -lz -lm -lxml2 -lz-lm -lcrypt#& -liconv#' Makefile

make

make install

 

tar zxvf memcache-2.2.5.tgz

cd memcache-2.2.5

/usr/local/php5/bin/phpize

./configure--with-php-config=/usr/local/php5/bin/php-config

make

make install

 

tar jxvf eaccelerator-0.9.5.3.tar.bz2

cd eaccelerator-0.9.5.3

/usr/local/php5/bin/phpize

./configure --enable-eaccelerator=shared--with-php-config=/usr/local/php5/bin/php-config

make

make install

 

配置PHP

cp php.ini-dist /usr/local/apache2/conf/php.ini

vi /usr/local/apache2/conf/php.ini

修改

extension_dir = "./"

extension_dir ="/usr/local/php5/lib/php/extensions/no-debug-zts-20060613/"

添加以下行

extension = "memcache.so"

修改output_buffering = Off 为 output_buffering = On

 

配置eAccelerator加速PHP

mkdir -p /usr/local/php5/eaccelerator_cache

vi /usr/local/apache2/conf/php.ini

在最末尾加入以下行

extension = "eaccelerator.so"

eaccelerator.shm_size="128"

eaccelerator.cache_dir="/usr/local/php5/eaccelerator_cache"

eaccelerator.enable="1"

eaccelerator.optimizer="1"

eaccelerator.check_mtime="1"

eaccelerator.debug="0"

eaccelerator.filter=""

eaccelerator.shm_max="0"

eaccelerator.shm_ttl="300"

eaccelerator.shm_prune_period="120"

eaccelerator.shm_only="0"

eaccelerator.compress="1"

eaccelerator.compress_level="9"

 

配置Apache

vi/usr/local/apache2/conf/httpd.conf

 

AddType application/x-httpd-php  .php  .php3 .phtml 

AddType application/x-httpd-php-source .phps

 

DirectoryIndex index.html index.htmindex.php

 

关闭SELINUX

vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled 重启

 

重启Apache

/usr/local/apache2/bin/apachectl restart

 

 

安装phpMyAdmin

cd /home/asen/php/

tar xvzf /home/asen/soft/PHP/phpMyAdmin-3.1.3.1-all-languages.tar.gz

mv phpMyAdmin-3.1.3.1-all-languagesphpMyAdmin

cd phpMyAdmin

cp libraries/config.default.php config.inc.php

 

这里只需要将$cfg['Servers'][$i]['host'] = 'localhost' 改为 '127.0.0.1' 就可以了。或者改成localhost.localdomain,这样改的依据是more /etc/hosts,可以看到localhost和localhost.localdomain被解析为127.0.0.1的,而mysql的 my.cnf里面大家都加了bind-address = 127.0.0.1,所以要修改$cfg['Servers'][$i]['host']。

 

安装memcached

tar -zxvf libevent-1.4.11-stable.tar.gz

cd libevent-1.4.11-stable

./configure --prefix=/usr

make

make install

ls -al /usr/lib | grep libevent

cd ..

 

tar -zxvf memcached-1.2.8.tar.gz

cd memcached-1.2.8

./configure --prefix=/usr/local/memcached--with-libevent=/usr

make

make install

#安装好了以后,先建立memcached运行临时目录:

mkdir -pv /var/run/memcached

chown -R nobody:nobody /var/run/memcached

#启动memcached

/usr/local/memcached/bin/memcached -p 11211-l 127.0.0.1 -d -u nobody -P /var/run/memcached/memcached.pid -m 64M -c 1024

 

其它

改编码

vi /etc/sysconfig/i18n

LANG="zh_CN.UTF-8"
改成
LANG="zh_CN.GB18030"

重远程链接

让apache 开机启动

vi /etc/rc.local

加上/usr/local/apache2/bin/apachectlstart

 

posted @ 2010-07-29 16:56  Zhou Hr  阅读(249)  评论(0编辑  收藏  举报