lamp环境搭建

liangkaiping0 2011-04-13

Apache2.2.14

Mysql5.1.41

Memcached1.4.4

Imagemagick6.5.6-10

PHP5.2.11

PECLAPC3.0.19

PECLMemcache2.2.5

软件安装

#安装Apache

tarzxvfhttpd-2.2.14.tar.gz

cdhttpd-2.2.14

引用
./configure --prefix=/usr/local/apache2 --disable-authn-file \

--disable-authn-default--disable-z-user--disable-authz-default\

--disable-auth-basic--disable-autoindex--disable-status\

--disable-asis--disable-cgi--disable-actions--disable-userdir\

--enable-expire--enable-ssl--enable-rewrite--enable-so

make

makeinstall

引用
ln -s /usr/local/apache2/bin/apachectl /usr/local/bin/

cp/usr/local/apache2/bin/apachectl/etc/init.d/httpd

#安装Mysql

#415mysql_test

引用
tar zxvf mysql-5.1.41.tar.gz

cdmysql-5.1.41

CFLAGS="-O3"CXX=gccCXXFLAGS="-O3-felide-constructors-fno-exceptions-fno-rtti"\

./configure--prefix=/usr/local/mysql--enable-assembler--with-mysqld-ldflags=-all-static\

--with-client-ldflags=-all-static--enable-thread-safe-client--localstatedir=/data/mysql\

--with-extra-charsets=complex--with-plugins=partition

make

makeinstall

cd/usr/local/mysql

./bin/mysql_install_db

chown-Rmysql/data/mysql

./share/mysql/mysql.serverstart

cp/usr/local/mysql/share/mysql/mysql.server/etc/init.d/

#安装ImageMagick

引用
tar zxvf ImageMagick-6.5.6-10.tar.gz

cdImageMagick-6.5.6-10

make

makeinstall

ln-s/usr/local/imagick/bin/convert/usr/local/bin

#安装libevent

引用
tar zxvf libevent-1.4.13-stable.tar.gz

cdlibevent-1.4.13-stable

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

make

makeinstall

#安装memcached

引用
tar zxvf memcached-1.4.4.tar.gz

cdmemcached-1.4.4

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

make

make

makeinstall

4.运行一下报错原因及处理方法:

/usr/local/memcached/bin/memcached-d-m10-p11211-uroot

报:usr/local/memcached/bin/memcached-d-m10-p11211-uroot

/usr/local/memcached/bin/memcached:errorwhileloadingsharedlibraries:libevent-1.4.so.2:cannotopensharedobjectfile:Nosuchfileordirectory

这样的错误,原因是,memcached默认是到/usr/lib/里找libevent-1.4.so.2,而我们安装的是在/usr/local/lib里面,处理一下:

引用
ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2

在运行一下:

引用
/usr/local/memcached/bin/memcached -d -m 10 -u root -l 127.0.0.1 -p 12000 -c 256 -P /tmp/memcached.pid

OK,用netstat-tnlp,系统已经成功监听12000端口了!

关闭memcached,直接kill掉这个进程就OK了!

5.memcached运行参数:

引用
/usr/local/memcached/bin/memcached -d -m 128 -u root -l 192.168.0.97 -c 256 -P /tmp/memcached.pid

-d选项是启动一个守护进程,

-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,

-u是运行Memcache的用户,我这里是root,

-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.22.200(不指定为本机)

-p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口,

-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,

-P是设置保存Memcache的pid文件,我这里是保存在/tmp/memcached.pid

#安装PHP

#如果安装了libiconv先将libiconv删除,否则编译不过

引用
tar zxvf php-5.2.11.tar.gz

cdphp-5.2.11

./configure--prefix=/usr/local/php5--with-apxs2=/usr/local/apache2/bin/apxs\

--enable-mbstring--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql\

--enable-soap--without-sqlite--without-pdo-sqlite--with-zlib--with-gd\

--with-jpeg-dir--with-png-dir--with-ttf--with-freetype-dir\

--enable-gd-native-ttf--enable-gd-jis-conv--with-curl

make

makeinstall

cpphp.ini-dist/usr/local/php5/lib/php.ini

mkdir-p/usr/local/php5/modules

#如果apache不能启动并出现

#httpd:Syntaxerroronline53of/usr/local/apache2/conf/httpd.conf:Cannot

#load/usr/local/apache/modules/libphp5.sointoserver:

#/usr/local/apache/modules/libphp5.so:cannotrestoresegmentprotafterreloc:Permissiondenied

#执行下面语句

#setenforce0

#chcon-c-v-R-usystem_u-robject_r-ttextrel_shlib_t/usr/local/apache/modules/libphp5.so

#servicehttpdrestart

#setenforce1

#安装APCPECL

引用
tar zxvf APC-3.0.19.tgz

cdAPC-3.0.19

/usr/local/php5/bin/phpize

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

make

cpmodules/apc.so/usr/local/php5/modules/

#安装MemcachePECL

引用
tar zxvf memcache-2.2.5.tgz

cdmemcache-2.2.5

/usr/local/php5/bin/phpize

./configure--help

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

make

cpmodules/memcache.so/usr/local/php5/modules/

修改php.ini,添加

引用

extension=memcache.so

apache环境

http.conf配置

引用

AddTypeapplication/x-httpd-php.php

<FilesMatch"\.ph(p|tml)$">

SetHandlerapplication/x-httpd-php

</FilesMatch>

<IfModuledir_module>

DirectoryIndexindex.phpindex.html

</IfModule>

Includeconf/extra/camp-vhost.conf

camp-vhost.conf配置

引用
<VirtualHost *:80>

DocumentRoot"/data/website/camp/web"

ServerNamewww.camp.com

ErrorLog"logs/error.www.camp.com.log"

CustomLog"logs/acess.www.camp.com.log"combined

<Directory"/Users/mole/Sites/camp/web">

OptionsFollowSymLinks

AllowOverrideAll

Orderdeny,allow

allowfromall

</Directory>

</VirtualHost>

相关推荐