系统 Debian Linux v3.1r0 (Sarge) Kernel v2.6.11 i686
安装方式:源码编译
版权:本文章可以任意转载,但请注明作者和出处,谢谢
作者:keelort
出处:ChinaUnix
原文地址:http://bbs.chinaunix.net/thread-566631-1-1.html
说明:这篇文章已经做得非常详细,各个软件都安装到了单独的目录,如MySQL数据库。这里也推荐大家安装linux的时候单独划分一个分区,用来安装这些软件以及数据,这样对于重装系统是完全有利的。这样重新安装系统的时候可以把其它非数据分区格式化,再把这个分区挂载(不格式化哦^_^)就搞定了。还有这篇文章虽然2005年写的,但是不过时哦,我做的仅仅是将文章复制过来而已,因为它的确是篇有意义的文章。
################
##### 软件 #####
################
Apache v2.0.54 官方主页: http://www.apache.org
http://www.apache.org/dist/httpd/httpd-2.0.54.tar.gz [7.16MB]
PHP v4.3.11 官方主页: http://www.php.net
http://cn.php.net/distributions/php-4.3.11.tar.gz [4.64MB]
Zend Optimizer v2.5.10 官方主页: http://www.zend.com
http://downloads.zend.com/optimi ... glibc21-i386.tar.gz [3.36MB]
MySQL v4.0.24 官方主页: http://www.mysql.com
http://ftp.stu.edu.tw/pub/Unix/D ... mysql-4.0.24.tar.gz [16.1MB]
GD Library v2.0.33 官方主页: http://www.boutell.com/gd/
http://www.boutell.com/gd/http/gd-2.0.33.tar.gz [573KB]
FreeType v2.1.10 官方主页: http://www.freetype.org
http://savannah.nongnu.org/downl ... etype-2.1.10.tar.gz [1.31MB]
Jpeg v6b 官方主页: http://www.ijg.org
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz [598KB]
LibPNG v1.2.8 官方主页: http://www.libpng.org/pub/png/
http://switch.dl.sourceforge.net ... libpng-1.2.8.tar.gz [498KB]
OpenSSL v0.9.7g 官方主页: http://www.openssl.org
http://www.openssl.org/source/openssl-0.9.7g.tar.gz [2.98MB]
vsftpd v2.0.3 官方主页: http://vsftpd.beasts.org
ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.0.3.tar.gz [149KB]
zlib v1.2.2 官方主页: http://www.gzip.org/zlib/
http://www.zlib.net/zlib-1.2.2.tar.gz [420KB]
ClibPDF v2.02-r1-1 官方网站: http://www.fastio.com
http://www.fastio.com/clibpdf202r1.tar.gz [836KB]
mod_limitipconn v0.22 官方网站: http://dominia.org/djao/
http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz [6.18KB]
Bandwidth Module v0.6 官方网站: http://www.ivn.cl/apache/
http://www.ivn.cl/apache/bw_mod-0.6.tgz [28.5KB]
Apache DoS Evasive Maneuvers Module v1.10 官方网站: http://www.nuclearelephant.com/projects/dosevasive/
http://www.nuclearelephant.com/p ... evasive_1.10.tar.gz [19.1KB]
################
##### 安装 #####
################
1、解压缩,把所有源码压缩包放在一个目录中,解压缩所有 .tar.gz 压缩包
for i in `ls *.gz`;do tar zxvf $i; done;
2、开始安装
##### zlib #####
cd zlib-1.2.2
./configure
make
make install
cd ..
##### OpenSSL #####
cd openssl-0.9.7g
./config --prefix=/usr/local/ssl \
--openssldir=/usr/local/ssl \
shared \
zlib
make
make install
ln -s /usr/local/ssl /usr/lib/ssl
cd ..
##### MySQL #####
cd mysql-4.0.24
编辑 sql/mysqld.cc :
搜索:&max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
修改:&max_connections, 0, GET_ULONG, REQUIRED_ARG, 1000, 1, 16384, 0, 1,
groupadd mysql
useradd -g mysql mysql
./configure \
--prefix=/server/mysql \
--sysconfdir=/server/mysql \
--without-isam \
--without-debug \
--enable-assembler \
--with-unix-socket-path=/tmp/mysql.sock \
--with-mysqld-user=mysql \
--with-extra-charset=all \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--localstatedir=/data/mysql/data
如果出现了以下错误:
checking for tgetent in -ltermcap... no
checking for termcap functions library... configure: error: No curses/termcap library found
说明 curses/termcap 库没有安装
apt-cache search curses | grep lib
安装 libncurses5-dev ,然后重新运行配置
mkdir /data
mkdir /data/mysql
mkdir /data/mysql/data
make
make install
/server/mysql/bin/mysql_install_db --user=mysql
chown -R mysql /data/mysql
chgrp -R mysql /data/mysql
chown -R root /server/mysql
chgrp -R mysql /server/mysql
cp /server/mysql/share/mysql/my-medium.cnf /server/mysql/my.cnf
/server/mysql/share/mysql/mysql.server start
/server/mysql/bin/mysqladmin -u root password 123456789
cd ..
##### Apache2 #####
cd httpd-2.0.54
./configure --prefix=/server/httpd \
--enable-so \
--with-mysql=/server/mysqld \
--enable-cgi \
--with-config-file-path=/server/httpd/conf \
--enable-track-vars \
--enable-mods-shared=all \
--enable-cache \
--enable-disk-cache \
--enable-mem-cache \
--enable-rewrite \
--with-mpm=worker \
--with-ssl=/usr/local/ssl \
--enable-ssl
make
make install
cd ..
##### mod_deflate #####
cd httpd-2.0.54/modules/filters
/server/httpd/bin/apxs -i -c -a mod_deflate.c
修改 Apache 配置文件 /server/httpd/conf/httpd.conf :
添加:
<Location />;
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|ico)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
</Location>;
DeflateFilterNote ratio
LogFormat '"%v %h %l %u %t "%r" %>;s %b "%{Referer}i" "%{User-Agent}i"" (%{ratio}n)' deflate
CustomLog logs/deflate_log deflate
然后
cd ../../../
##### FreeType #####
cd freetype-2.1.10
./configure --prefix=/usr/local/freetype
make
make install
cd ..
##### LibPNG #####
cd libpng-1.2.8
cp scripts/makefile.linux makefile
make test
make install
cd ..
##### Jpeg #####
cd jpeg-6b
mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
make
make install
cd ..
##### GD Library #####
cd gd-2.0.33
./configure --prefix=/usr/local/gd \
--with-jpeg=/usr/local/jpeg \
--with-freetype=/usr/local/freetype \
--with-png \
--with-zlib
make
make install
cd ..
##### ClibPDF #####
cd ClibPDF/source
cp Makefile.Linux makefile
make
make install
cd ..
##### PHP #####
cd php-4.3.11
./configure --prefix=/server/php \
--with-apxs2=/server/httpd/bin/apxs \
--with-gd=/usr/local/gd \
--enable-gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr/local/jpeg \
--with-png \
--with-ttf \
--with-zlib \
--with-freetype-dir=/usr/local/freetype \
--enable-magic-quotes \
--with-mysql=/server/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--with-iconv \
--with-mbstring \
--enable-mbstring \
--enable-track-vars \
--enable-force-cgi-redirect \
--enable-ftp \
--with-config-file-path=/server/httpd/conf \
--with-openssl=/usr/local/ssl \
--with-openssl-dir=/usr/local/ssl \
--with-cpdflib=/usr/local \
--with-pear=/server/php/pear
make
make install
cp php.ini-dist /server/httpd/conf/php.ini
cd ..
##### Zend Optimizer #####
cd ZendOptimizer-2.5.10-linux-glibc21-i386
./install
操作 [OK] [EXIT] [YES] [/server/zend] [/server/httpd/conf] [YES] [/server/httpd/bin/apachectl] [OK] [OK] [NO]
cd ..
##### mod_limitipconn #####
cd mod_limitipconn-0.22
/server/httpd/bin/apxs -i -c -a mod_limitipconn.c
修改 Apache 配置文件 /server/httpd/conf/httpd.conf:
查找:#ExtendedStatus On ,去掉注释"#"
查找:CustomLog logs/access_log common ,修改成 CustomLog logs/access_log common env=!LIMITIP
添加:
<IfModule mod_limitipconn.c>;
<Location />;
MaxConnPerIP 5
NoIPLimit image/*
</Location>;
<Location /mp3>;
MaxConnPerIP 2
OnlyIPLimit audio/mpeg video
</Location>;
</IfModule>;
然后
cd ..
##### Bandwidth Module #####
cd bw_mod-0.6
/server/httpd/bin/apxs -i -c -a bw_mod-0.6.c
cd ..
带宽限制在虚拟主机中设置
##### Apache DoS Evasive Maneuvers Module #####
cd mod_dosevasive
/server/httpd/bin/apxs -i -c -a mod_dosevasive20.c
cd ..
等一下启动 Apache2 后可以测试
perl test.pl
###############################################################################################
现在,WEB 服务已经安装完毕!
测试 WEB 服务:
mkdir /data/vhosts
mkdir /data/vhosts/localhost
启动 Apache2
/server/httpd/bin/apachectl start
如果出错请参考下一贴中的 httpd.conf 和 虚拟主机配置文件示例
MySQL 服务前面已经启动了,密码是:123456789
编辑一个 info.php 放在 /data/vhosts/localhost 下面,内容如下:
<?php
phpinfo();
?>;
测试: http://localhost/info.php
OK,看到 PHP 信息了吧
##### 开机自动启动服务 #####
cp /server/httpd/bin/apachectl /etc/init.d/httpd
cp /server/mysql/share/mysql/mysql.server /etc/init.d/mysql
recconf
配置,已经有 httpd 和 mysql 选项了,选中,OK
如果没有 rcconf ,用 apt-get install rcconf 安装
#######################
##### 使 SSL 工作 #####
#######################
mkdir /server/ssl
cd /server/ssl
##### 手工签署证书 #####
/usr/local/ssl/bin/openssl genrsa -des3 \
-rand 任意大文件1:任意大文件2 \
-out server.key 1024
输入密码
重复密码
/usr/local/ssl/bin/openssl req -new -key server.key -out server.csr
Enter pass phrase for localhost.key: #<--## 输入密码
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN #<--## 国家代码
State or Province Name (full name) [Some-State]:LN #<--## 省或州
Locality Name (eg, city) []:SY #<--## 城市
Organization Name (eg, company) [Internet Widgits Pty Ltd]:micronsky.net #<--## 组织名称
Organizational Unit Name (eg, section) []:root #<--## 部门
Common Name (eg, YOUR name) []:keelort #<--## 名字
Email Address []:keelort@gmail.com #<--## 电子邮件
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: #<--## 直接回车就可以
An optional company name []: #<--## 直接回车就可以
/usr/local/ssl/bin/openssl x509 -req \
-days 3650 \
-in server.csr \
-signkey server.key \
-out server.crt
................................................................................
注意:SSL 部分目前还不是很明白,apachectl startssl 启动后 http:// 不能用,只能用 https:// 连接,
不知道怎么回事请高手指教,暂时没有写全
###############################################################################################
##### vsftpd #####
cd vsftpd-2.0.3
编辑 builddefs.h :
#define VSF_BUILD_PAM
修改为
#undef VSF_BUILD_PAM
编辑 defs.h :
#define VSFTP_DEFAULT_CONFIG "/etc/vsftpd.conf"
修改为
#define VSFTP_DEFAULT_CONFIG "/server/vsftpd/conf/vsftpd.conf"
make
useradd nobody
mkdir /usr/share/empty
mkdir /data/ftp
useradd -d /data/ftp ftp
chown root:root /data/ftp
chmod og-w /data/ftp
install -m 755 vsftpd /server/vsftpd/vsftpd
install -m 644 vsftpd.8 /usr/share/man/man8
install -m 644 vsftpd.conf.5 /usr/share/man/man5
mkdir /server/vsftpd/conf
install -m 644 vsftpd.conf /server/vsftpd/conf/vsftpd.conf
使 vsftpd 以 standalone 方式启动:
编写名为 vsftpd 的启动脚本:- #!/bin/sh
- # /etc/init.d/vsftpd
- #
- set -e
- # Exit if vsftpd.conf doesn't have listen=yes or listen_ipv6=yes
- # (mandatory for standalone operation)
- if [ -f /server/vsftpd/conf/vsftpd.conf ] && ! egrep -iq "^ *listen(_ipv6)? *= *yes"
- /server/vsftpd/conf/vsftpd.conf; then
- exit 0
- fi
- DAEMON=/server/vsftpd/vsftpd
- NAME=vsftpd
- test -x $DAEMON || exit 0
- case "$1" in
- start)
- echo -n "Starting FTP server: $NAME"
- start-stop-daemon --start --background -m --pidfile /tmp/vsftpd.pid --exec $DAEMON
- echo "."
- ;;
- stop)
- echo -n "Stopping FTP server: $NAME"
- start-stop-daemon --stop --pidfile /tmp/vsftpd.pid --oknodo --exec $DAEMON
- echo "."
- ;;
- restart)
- echo -n "Restarting FTP server: $NAME"
- start-stop-daemon --stop --pidfile /tmp/vsftpd.pid --oknodo --exec $DAEMON
- start-stop-daemon --start --background -m --pidfile /tmp/vsftpd.pid --exec $DAEMON
- echo "."
- ;;
- reload|force-reload)
- echo "Reloading $NAME configuration files"
- start-stop-daemon --stop --pidfile /tmp/vsftpd.pid --signal 1 --exec $DAEMON
- echo "."
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload}"
- exit 1
- ;;
- esac
- exit 0
复制代码 运行 rcconf 选中 vsftpd ,确定
重新启动,试试试不是所有的服务都启动了,呵呵...
全文完)
[ 本帖最后由 天使别哭 于 2007-10-5 17:29 编辑 ] |