LAMP环境搭建-PHP+Memcached+Apache+eAccelerator

来源:互联网 发布:知乎日报app下载 编辑:程序博客网 时间:2024/05/01 16:27

搭了不少服务器了,才想起来还是先把日志保存起来比较好。

基本概念: 

Linux下安装PHP;

连接MySQL数据库;

session保存在memcached中; 

PHP accelerator & optimizer 采用早期的 eAccelerator;


TAG:Apache PHP eAccelerator Memcached PDO_MYSQL


安装步骤:

  • APACHE
mkdir -p /var/log/httpd
chmod a+w /var/log/httpd

cd /usr/local/src
wget "http://archive.apache.org/dist/httpd/httpd-2.2.13.tar.gz"    
tar zxf httpd-2.2.13.tar.gz


###1. install apr
cd /usr/local/src/httpd-2.2.13/srclib/apr
./configure --prefix=/usr/local/apr
make
make install


###2. install apr-util
cd /usr/local/src/httpd-2.2.13/srclib/apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install


###3. install httpd
cd /usr/local/src/httpd-2.2.13
./configure --prefix=/usr/local/apache --with-mpm=prefork --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/bin --enable-proxy --enable-rewrite --enable-so --enable-info --enable-expires --enable-env --enable-mime-magic --disable-include --disable-filter --disable-status --disable-asis --disable-negotiation --disable-userdir --disable-actions
make
make install


###4. install mod_deflate
yum install zlib zlib-devel
###Y
/usr/local/apache/bin/apxs -ica modules/filters/mod_deflate.c


  •  PHP

###1. PHP Install
yum install libxml2-devel curl-devel libjpeg-devel mysql-devel libpng libpng-devel freetype freetype-devel
###Y
cd /usr/local/src
wget "http://museum.php.net/php5/php-5.2.11.tar.gz"
tar zxf php-5.2.11.tar.gz


cd php-5.2.11
###64bit
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-jpeg-dir --with-png-dir --with-gd --with-ttf --with-freetype-dir --enable-mbstring --with-zlib --with-mysql --with-gettext --enable-gd-native-ttf --with-curl --with-mysqli --with-openssl --with-libdir=lib64 --with-mysql
make
make install
cp php.ini-dist /usr/local/php/lib/php.ini


###2. install eaccelerator 

##这个东西已经很久没有维护了
cd /usr/local/src/
wget "http://nchc.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip"
unzip eaccelerator-0.9.6.1.zip 

cd eaccelerator-0.9.6.1
### do if phpize error
#yum install autoconf
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
mkdir /tmp/eaccelerator
chmod 0777 /tmp/eaccelerator
   
###3. install php_memcached

cd /usr/local/src/
wget "http://pecl.php.net/get/memcache-2.2.5.tgz"
tar zxf memcache-2.2.5.tgz

cd memcache-2.2.5
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-apxs=/usr/local/apache/bin/apxs --with-gettext --enable-socket --enable-memcache --enable-sysvshm --enable-shmop
make
make install


###4. install PDO_mysql
cd /usr/local/src
wget "http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz"
tar zxf PDO_MYSQL-1.0.2.tgz


cd PDO_MYSQL-1.0.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install


###5. PHP Config

vi /usr/local/php/lib/php.ini

magic_quotes_gpc = Off
####find extension_dir and change it as bellow
extension_dir = "/usr/local/php/lib/php/extensions/"


####add 
extension="no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"


extension="no-debug-non-zts-20060613/memcache.so"
extension="no-debug-non-zts-20060613/pdo_mysql.so"

### search session.save_handler , change it as bellow
session.save_handler = memcache
### search session.save_path , change it as bellow
session.save_path = "tcp://127.0.0.1:11211"

##save

  • MEMCACHED
cd /usr/local/src
wget "http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz"
tar zxf libevent-1.4.12-stable.tar.gz

cd libevent-1.4.12-stable
./configure --prefix=/usr
make
make install

cd /usr/local/src
wget "http://memcached.googlecode.com/files/memcached-1.4.2.tar.gz"
tar zxf memcached-1.4.2.tar.gz

cd memcached-1.4.2
./configure --prefix=/usr
make
make install
ldconfig

/usr/bin/memcached -d -m 256 -p 11211 -u root