lamp環境搭建

Apache 2.2.14
Mysql 5.1.41
Memcached 1.4.4
Imagemagick 6.5.6-10
PHP 5.2.11
PECL APC 3.0.19
PECL Memcache 2.2.5

軟件安裝

# 安裝 Apache
tar zxvf httpd-2.2.14.tar.gz
cd httpd-2.2.14
[quote]./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[/quote]
make
make install
[quote]ln -s /usr/local/apache2/bin/apachectl /usr/local/bin/
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd[/quote]


# 安裝 Mysql
# 415 mysql_test
[quote]tar zxvf mysql-5.1.41.tar.gz
cd mysql-5.1.41
CFLAGS="-O3" CXX=gcc CXXFLAGS="-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
make install
cd /usr/local/mysql
./bin/mysql_install_db
chown -R mysql /data/mysql
./share/mysql/mysql.server start
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/
[/quote]
# 安裝 ImageMagick
[quote]tar zxvf ImageMagick-6.5.6-10.tar.gz
cd ImageMagick-6.5.6-10
make
make install
ln -s /usr/local/imagick/bin/convert /usr/local/bin
[/quote]
# 安裝 libevent
[quote]tar zxvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr/local/libevent
make
make install[/quote]

# 安裝 memcached
[quote]tar zxvf memcached-1.4.4.tar.gz
cd memcached-1.4.4
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/
make
make
make install[/quote]

4.運行一下報錯原因及處理方法:
/usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
報:usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
/usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

這樣的錯誤,原因是,memcached默認是到/usr/lib/裏找libevent-1.4.so.2,而我們安裝的是在/usr/local/lib裏面,處理一下:
[quote]ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2[/quote]
在運行一下:
[quote]/usr/local/memcached/bin/memcached -d -m 10 -u root -l 127.0.0.1 -p 12000 -c 256 -P /tmp/memcached.pid[/quote]
OK,用netstat -tnlp,系統已經成功監聽12000 端口了!
關閉memcached,直接kill掉這個進程就OK了!
5.memcached運行參數:
[quote]/usr/local/memcached/bin/memcached -d -m 128 -u root -l 192.168.0.97 -c 256 -P /tmp/memcached.pid[/quote]

-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 刪除,否則編譯不過
[quote]tar zxvf php-5.2.11.tar.gz
cd php-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
make install
cp php.ini-dist /usr/local/php5/lib/php.ini
mkdir -p /usr/local/php5/modules[/quote]

# 如果apache 不能啓動並出現
# httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot
# load /usr/local/apache/modules/libphp5.so into server:
# /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
# 執行下面語句
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# service httpd restart
# setenforce 1

# 安裝 APC PECL
[quote]tar zxvf APC-3.0.19.tgz
cd APC-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
cp modules/apc.so /usr/local/php5/modules/[/quote]


# 安裝 Memcache PECL
[quote]tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5
/usr/local/php5/bin/phpize
./configure --help
./configure --with-php-config=/usr/local/php5/bin/php-config
make
cp modules/memcache.so /usr/local/php5/modules/

[/quote]
修改 php.ini,添加
[quote]

extension=memcache.so
[/quote]

apache環境

http.conf 配置

[quote]
AddType application/x-httpd-php .php
<FilesMatch "\.ph(p|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>

<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>

Include conf/extra/camp-vhost.conf
[/quote]
camp-vhost.conf 配置

[quote]<VirtualHost *:80>
DocumentRoot "/data/website/camp/web"
ServerName www.camp.com
ErrorLog "logs/error.www.camp.com.log"
CustomLog "logs/acess.www.camp.com.log" combined
<Directory "/Users/mole/Sites/camp/web">
Options FollowSymLinks
AllowOverride All
Order deny,allow
allow from all
</Directory>
</VirtualHost>[/quote]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章