编译安装LAMP+SVN+Trac+Memcached

Standard
##
## 转载请注明出处: http://yemaosheng.com
##
 
## 环境:Dell1950  CentOS5.3 x86
 
## 新建软件安装目录
 
mkdir /home/lib
mkdir /home/apache
mkdir /home/mysql
mkdir /home/memcached
mkdir /home/php
mkdir /home/svn
mkdir /home/trac
 
## 安装依赖包
 
# gettext-devel
yum install -y gettext-devel.x86_64
 
# zlib
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/home/lib/zlib
make
make install
cd ..
 
# openssl
tar zxvf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config \
	--prefix=/home/lib/openssl \
	--openssldir=/home/lib/openssl \
	--with-zlib-lib=/home/lib/zlib/lib \
	--with-zlib-include=/home/lib/zlib/include \
	shared \
	zlib \
	threads 
make
make test
make install
echo "/home/lib/openssl/lib" >> /etc/ld.so.conf.d/openssl.conf
ldconfig
cd ..
 
# apr
tar zxvf apr-1.3.5.tar.gz
cd apr-1.3.5
./configure --prefix=/home/lib/apr
make
make install
cd ..
 
# apr-util
tar zxvf apr-util-1.3.7.tar.gz
cd apr-util-1.3.7
./configure \
	--prefix=/home/lib/apr-util \
	--with-apr=/home/lib/apr
make
make install
cd ..
 
## 安装Apache
 
rm -rf /usr/lib/libexpat.so
ln -s /usr/lib64/libexpat.so /usr/lib/
tar zxvf httpd-2.2.11.tar.gz
cd httpd-2.2.11
./configure \
	--prefix=/home/apache \
	--enable-track-vars \
	--enable-rewrite \
	--enable-proxy \
	--enable-proxy-http  \
	--enable-cache \
	--enable-disk-cache \
	--enable-mem-cache \
	--enable-so \
	--enable-ssl \
	--enable-mods-shared=all \
	--enable-rewrite=shared \
	--enable-proxy=shared \
	--enable-proxy-http=shared \
	--with-mpm=worker \
	--sysconfdir=/home/apache/conf \
	--with-ssl=/home/lib/openssl \
	--with-z-dir=/home/lib/zlib \
	--with-apr=/home/lib/apr \
	--with-apr-util=/home/lib/apr-util \
	--with-perl 
make 
make install
cd ..
 
mv /etc/init.d/httpd /etc/init.d/httpd.bak
cp /home/apache/bin/apachectl /etc/init.d/httpd
chmod +x /etc/init.d/httpd
 
## 安装依赖包
 
# icon
tar zxvf libiconv-1.12.tar.gz
cd libiconv-1.12
./configure --prefix=/home/lib/iconv
make
make install
cd ..
 
# libpng
tar jxvf libpng-1.2.23.tar.bz2   
cd libpng-1.2.23
env \
	CPPFLAGS="-I/home/lib/zlib/include" \
	LDFLAGS="-L/home/lib/zlib/lib" \
	./configure \
	--prefix=/home/lib/libpng
make
make check 
make install
cd ..
 
# curl
tar zxvf curl-7.19.5.tar.gz
cd curl-7.19.5
./configure --prefix=/home/lib/curl
make
make install
cd ..
 
# freetype
tar jxvf freetype-2.3.5.tar.bz2 
cd freetype-2.3.5
env \
	CPPFLAGS="-I/home/lib/zlib/include" \
	LDFLAGS="-L/home/lib/zlib/lib" \
	./configure \
	--prefix=/home/lib/freetype2
make
make install
cd ..
 
# jpeg
mkdir -p \
	/home/lib/jpeg6/bin \
	/home/lib/jpeg6/lib \
	/home/lib/jpeg6/include \
	/home/lib/jpeg6/man1 \
	/home/lib/jpeg6/man/man1 
 
tar zxvf jpegsrc.v6b.tar.gz    
cd jpeg-6b
./configure \
	--prefix=/home/lib/jpeg6 \
	--enable-shared --enable-static
make
make install-lib  
make install
cd ..
 
# libxml
tar -zxvf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure \
	--prefix=/home/lib/libxml2 \
	--with-zlib=/home/lib/zlib
make
make install
cd ..
 
# gd
tar -jvxf gd-2.0.35.tar.bz2
cd gd-2.0.35 
./configure \
	--prefix=/home/lib/gd2 \
	--with-freetype=/home/lib/freetype2 \
	--with-png=/home/lib/libpng \
	--with-jpeg=/home/lib/jpeg6 \
	CPPFLAGS="-I/home/lib/zlib/include" \
	LDFLAGS="-L/home/lib/zlib/lib"
make
make install 
cd ..
 
## 安装Mysql
 
groupadd mysql
useradd -g mysql mysql
tar zxvf mysql-5.1.34.tar.gz
cd mysql-5.1.34
./configure \
	--prefix=/home/mysql \
	--enable-assembler \
	--without-debug \
	--with-mysqld-ldflags=-all-static \
	--with-charset=utf8 \
	--with-extra-charsets=all \
	--with-innodb \
	--with-unix-socket-path=/home/mysql/mysql.sock \
	--enable-thread-safe-client \
	--with-mysqld-user=mysql
make
make install
cd ..
cp /home/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld 
if [ -f my.cnf.slave ]; then mv my.cnf.slave /etc/my.cnf; else mv my.cnf.mast /etc/my.cnf; fi; mkdir -p /data/mysqllog/binlog /data/mysqllog/relaylog ; chown mysql.0 /data/mysqllog/binlog /data/mysqllog/relaylog  /home/mysql; cp /home/mysql/share/mysql/mysql.server /etc/init.d/mysqld ; /home/mysql/bin/mysql_install_db --user=mysql; /etc/init.d/mysqld start
 
## 安装PHP
 
tar zxvf php-5.2.9.tar.gz
cd php-5.2.9
./configure \
	--prefix=/home/php \
	--with-zlib=/home/lib/zlib \
	--with-zlib-dir=/home/lib/zlib \
	--with-apxs2=/home/apache/bin/apxs \
	--with-mysql=/home/mysql \
	--with-mysql-sock=/home/mysql \
	--with-pdo-mysql=/home/mysql \
	--with-libxml-dir=/home/lib/libxml2 \
	--with-gd=/home/lib/gd2 \
	--with-jpeg-dir=/home/lib/jpeg6 \
	--with-png-dir=/home/lib/libpng \
	--with-freetype-dir=/home/lib/freetype2 \
	--with-libxml-dir=/home/lib/libxml2 \
	--with-openssl=/home/lib/openssl \
	--with-iconv-dir=/home/lib/iconv \
	--with-curl=/home/lib/curl \
	--with-ttf \
	--with-gettext \
	--enable-gd-native-ttf \
	--enable-mbstring \
	--enable-xml \
	--enable-pcntl \
	--enable-soap \
	--enable-sockets \
	--enable-zip \
	--with-bz2 \
	--disable-debug 
 
make
make install
cp php.ini-dist /home/php/lib/php.ini 
cd ..
 
## 安装PHP扩展
 
# memcached
tar zxvf memcache-2.2.1.tgz
cd memcache-2.2.1
/home/php/bin/phpize
./configure --with-php-config=/home/php/bin/php-config --enable-memcach
make 
make install
cd ..
 
# APC
tar zxvf APC-3.0.19.tgz 
cd APC-3.0.19
/home/php/bin/phpize
./configure --enable-apc --enable-apc-mmap --with-apxs=/home/apache/bin/apxs --with-php-config=/home/php/bin/php-config 
make
make install
cd ..
 
# xdebug
tar zxvf xdebug-2.0.4.tgz
cd xdebug-2.0.4
/home/php/bin/phpize
./configure --enable-xdebug --with-php-config=/home/php/bin/php-config
make
make install
cd ..
 
sed -i 's#extension_dir = "./"#extension_dir = "/home/php/lib/php/extensions/no-debug-zts-20060613/"\n\nextension = "memcache.so"\nextension = "apc.so"\nextension = "xdebug.so"#' /home/php/lib/php.ini
sed -i 's#expose_php = On#expose_php = Off#' /home/php/lib/php.ini
 
#xdebug.auto_trace=on 监测函数调用过程
#xdebug.collect_params=on 收集函数参数
#xdebug.collect_return=on 收集函数返回值
#xdebug.profiler_enable=on 效能监测器
#xdebug.trace_output_dir="/tmp" 函数调用监测信息的输出文件的路径
#debug.profiler_output_dir="/tmp" 效能监测信息输出文件的路径
#sed -i 's#extension = "xdebug.so"#xdebug.auto_trace=on\nxdebug.collect_params=on\nxdebug.collect_return=on\nxdebug.profiler_enable=on\nxdebug.trace_output_dir="/tmp"\ndebug.profiler_output_dir="/tmp"#' /home/php/lib/php.ini
 
 
sed -i 's#DirectoryIndex index.html#DirectoryIndex index.html index.php#' /home/apache/conf/httpd.conf
sed -i 's#TypesConfig conf/mime.types#TypesConfig conf/mime.types\nAddType application/x-httpd-php .php#' /home/apache/conf/httpd.conf
 
tar zxvf phpmyadmin.tar.gz
mv phpmyadmin /home/apache/htdocs/
 
## 安装memcached
tar zxvf libevent-1.4.10-stable.tar.gz 
cd libevent-1.4.10-stable
./configure --prefix=/home/lib/libevent
make
make install
cd ..
 
tar zxvf memcached-1.2.8.tar.gz
cd memcached-1.2.8
./configure \
	--prefix=/home/memcached \
	--with-libevent=/home/lib/libevent \
	--enable-64bit
make
make install
ln -s /home/lib/libevent/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2
/home/memcached/bin/memcached -l 127.0.0.1 -d -p 11211 -u nobody -m 128
cd ..
 
## 安装SVN
tar zxvf subversion-1.6.2.tar.gz
tar zxvf subversion-deps-1.6.2.tar.gz
tar zxvf sqlite-amalgamation-3.6.14.2.tar.gz
 
cd subversion-1.6.2
./configure \
	--prefix=/home/svn \
	--with-apxs=/home/apache/bin/apxs \
	--enable-maintainer-mode
 
make
make install
 
make swig-py
make install-swig-py 
 
cd ..
 
echo /home/svn/lib/svn-python > /usr/lib/python2.4/site-packages/subversion.pth
 
# Create SVN Repo
mkdir /srv/svn
mkdir /srv/trac
 
/home/svn/bin/svnadmin create /srv/svn/project
 
touch /srv/svn/project.htpasswd
htpasswd -m /srv/svn/project.htpasswd svnroot
echo -e "<Location /svn>\nDAV svn\nSVNParentPath /srv/svn\nAuthType Basic\nAuthName \"project Repository\"\nAuthzSVNAccessFile /srv/svn/svn-acl-conf\nAuthUserFile /srv/svn/project.htpasswd\nRequire valid-user\n</Location>" >> /home/apache/conf/httpd.conf
echo -e "[project:/]\nsvnroot =  rw" >> /srv/svn/svn-acl-conf
 
## 安装Trac
yum install flex
tar zxvf mod_python-3.3.1.tgz
cd mod_python-3.3.1
./configure \
	--with-apxs=/home/apache/bin/apxs \
	--with-python=/usr/bin/python2.4 \
	--with-max-locks=32
make
make install_dso
make install_py_lib
cd ..
 
yum install -y python-setuptools
rpm -i clearsilver-0.10.4-1.el5.rf.i386.rpm
rpm -i python-clearsilver-0.10.4-1.el5.rf.i386.rpm
 
tar zxvf Trac-0.11.4.tar.gz
cd Trac-0.11.4
python setup.py build && python setup.py install
 
# vi /home/apache/conf/httpd.conf
# Add: LoadModule python_module modules/mod_python.so
 
trac-admin /srv/trac/project initenv
sed -i 's#php_path = php#php_path = /home/php/bin/php#' /srv/trac/project/conf/trac.ini
# vi /srv/trac/project/conf/trac.ini 在 [mimeviewer] 后加上 pygments_default_style = trac 修改[trac] default_charset = utf-8
 
chown -R apache.apache /srv/svn/project
chown -R apache.apache /srv/trac/project
 
# 生成trac的用户名密码
touch /srv/trac/project.htpasswd
htpasswd -m /srv/trac/project.htpasswd tracroot
# 生成tracroot用户的权限
trac-admin /srv/trac/project permission add tracroot TRAC_ADMIN
 
echo -e "<Location /trac/project>\nSetHandler mod_python\nPythonHandler trac.web.modpython_frontend\nPythonOption TracEnv /srv/trac/project\nPythonOption TracUriRoot /trac/project\n</Location>\n<Location "/trac/project/login">\nAuthType Basic\nAuthName \"trac\"\nAuthUserFile /srv/trac/project.htpasswd\nRequire valid-user\n</Location>" >> /home/apache/conf/httpd.conf
 
/etc/init.d/httpd restart
 
## OK
 
http://127.0.0.1/svn/project
http://127.0.0.1/trac/project
memcached: telnet 127.0.0.1 11211
 
/home/lib (关联库)
/home/apache  (2.2.11)
/home/mysql  (5.1.34)
/home/php  (5.2.9)
/home/memcached  (1.2.8)
/home/svn  (1.6.2)
/home/trac  (0.11.4)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.