2008年10月26日星期日

Linux 完整的WEB服务器安装方案

关机
poweroff

是看端口命令
netstat -ant

更改服务器语言
vi/etc/sysconfig/i18n

英文

LANG="en_US.UTF-8"
#SUPPORTED="zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en"
SUPPORTED="en_US.UTF-8:en_US:en"
SYSFONT="latarcyrheb-sun16"
~


装好虚拟机后
配置
ip ---- setup

编辑
dns vi/etc/resolv.conf

查看
DNS ---- nslookup

然后重启网络
service network restart


设置开机自动启动

vi/etc/rc.local

touch /var/lock/subsys/local
/etc/rc.d/init.d/iptables start
sh /etc/rc.d/firewall-1
#/siteroot/appserver/memcached/bin/memcached -d -m 256 -u nobody -l 127.0.0.1 -p 11211
#postfix stop
/siteroot/appserver/memcached/bin/memcached -d -m 500 -l 192.168.0.86 -p 11211 -u nobody
/siteroot/appserver/memcached/bin/memcached -d -m 100 -l 192.168.0.86 -p 11212 -u nobody
/siteroot/newserver/httpd/bin/apachectl start
/siteroot/newserver/mysql/bin/mysqld_safe --user=mysql &
/siteroot/newserver/squid/sbin/squid start



#######################################################
###download.softs.sh
###以下链接不保证有效..请自行更新
###总共 18个文件
#######################################################

cd /siteroot/softs
rm -rf *

wget http://ftp.plusline.de/mysql/Downloads/MySQL-5.0/mysql-5.0.45.tar.gz
wget http://mirror.x10.com/mirror/apache/httpd/httpd-2.0.59.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.12-no-config.tar.gz
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.2.1.tar.gz
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
wget http://www.zlib.net/zlib-1.2.3.tar.gz
wget http://monkey.org/~provos/libevent-1.3b.tar.gz
wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz
wget http://xmlsoft.org/sources/libxml2-2.6.29.tar.gz

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz(最新)

wget http://cn.php.net/get/php-5.2.3.tar.gz/from/cz2.php.net/mirror
wget http://bart.eaccelerator.net/source/0.9.5.1/eaccelerator-0.9.5.1.tar.bz2
wget http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE4.tar.gz
wget http://pecl.php.net/get/memcache-2.1.0.tgz
wget ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-2.4.1.tar.gz
wget ftp://ftp.eyrie.org/pub/software/system/newsyslog-1.8.tar.gz
wget http://downloads.zend.com/optimizer/3.0.1/ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz



#######################################################
###soft.install.sh
#######################################################
#######################################################
###apache compile
#######################################################
###########1--##########

cd /siteroot/softs
tar xfvz httpd-2.0.59.tar.gz
cd httpd-2.0.59
make clean
./configure --prefix=/siteroot/appserver/httpd --enable-so --enable-track-vars --enable-moudules-most --enable-rewrite --enable-expires --enable-dav
make
make install
cd /siteroot/softs


#################
配置httpd.conf

1,指定根目录(DocumentRoot)一队...
2,加入三名话
PHPIniDir /etc/php.ini(指定php.ini文件)
AddType application/x-httpd-php .php
AddType application/x-httpd-php-soure .phps

启动apache

/siteroot/appservice/httpd/bin/apachect1 stop
/siteroot/appservice/httpd/bin/apachect1 start


#########################
今天重新编译以前的一个程序,里面用到iconv库:
gcc test.cc -liconv运行时:
a.out:error while loading shared libraries:
libiconv.so.2: cannot open shared object file:
No such file or directory以前编译运行是可以的,可能是不久前升级了iconv库影响。
在/usr/local/lib下可以找到libiconv.so.2,把/usr/local/lib加到路径中也不行。google了一下,
解决了:在/etc/ld.so.conf中加一行 /usr/local/lib,运行ldconfig

#########2--##########

cd /siteroot/softs
groupadd mysql
useradd -g mysql mysql
tar xfvz /siteroot/softs/mysql-5.0.27.tar.gz
cd mysql-5.0.27
make clean
./configure --prefix=/siteroot/appserver/mysql --with-charset=utf8 -with-mysqld-ldflags=-all-static
make
make install
rm -rf /etc/my.cnf
cp /siteroot/softs/mysql-5.0.45/support-files/my-medium.cnf /etc/my.cnf
mkdir /siteroot/appserver/mysql/var


//先初始化后在执行下面的权限

/siteroot/appserver/mysql/bin/mysql_install_db (初始化)
/siteroot/appserver/mysql/bin/mysqld_safe --user=mysql & (启动mysql)

接接数据库

/siteroot/appserver/mysql/bin/mysql -u root -p

下面是
connect 数据库名

mysql >(数据库名)
mysql >sql语句

(chmod)改变文件权限

chown -R root /siteroot/appserver/mysql/
chown -R mysql /siteroot/appserver/mysql/var
chgrp -R mysql /siteroot/appserver/mysql/
cd /siteroot/softs


备份数据

/siteroot/appserver/mysql/var/mysqldump -u root -p kevin(数据库名)->/siteroot(指定路径)/kevin.sql


一、备份数据库:(命令在DOS的mysql\bin目录下执行)

mysqldump --opt school>school.bbb
注释:将数据库school备份到school.bbb文件,school.bbb是一个文本文件,文件名任取,打开看看你会有新发现。
1.导出整个数据库
mysqldump -u 用户名 -p 数据库名 > 导出的文件名
mysqldump -u root -p aikersql> aiker.sql
2.导出一个表
mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名
mysqldump -u aiker -p aikersql users> aiker_users.sql
3.导出一个数据库结构
mysqldump -u root -p -d --add-drop-table aikersql>d:\aiker_db.sql

-d 没有数据 --add-drop-table 在每个create语句之前增加一个drop table

二.导入数据库

常用source 命令
进入mysql数据库控制台,如mysql -u root -p

mysql>use 数据库

然后使用source命令,后面参数为脚本文件(如这里用到的.sql)
mysql>source d:\aiker_db.sql

也可以用 mysql -uroot -Ddb1 < d : \ aiker_db.sql

三、将文本数据转到数据库中

1、文本数据应符合的格式:字段数据之间用tab键隔开,null值用n来代替.
例:
3 rose 深圳二中 1976-10-10
4 mike 深圳一中 1975-12-23
2、数据传入命令 load data local infile "文件名" into table 表名;

注意:你最好将文件复制到mysqlbin目录下,并且要先用use命令打表所在的库。



#######3--#######

cd /siteroot/softs
tar xfvz freetype-2.2.1.tar.gz
cd freetype-2.2.1
make clean
./configure
make
make install
cd /siteroot/softs


###########4--#########

cd /siteroot/softs
tar xfvz libpng-1.2.12-no-config.tar.gz
cd libpng-1.2.12
rm -rf makefile
cp scripts/makefile.std makefile
make clean
make install
cd /siteroot/softs

#######5--#########

cd /siteroot/softs
mkdir /usr/local/modules
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/man
mkdir /usr/local/jpeg6/man/man1

cd /siteroot/softs
tar xfvz jpegsrc.v6b.tar.gz
cd jpeg-6b
make clean
./configure --enable-shared --enable-static
make
make install
cd /siteroot/softs

###########6--############

cd /siteroot/softs
tar xfvz gd-2.0.33.tar.gz
cd gd-2.0.33
make clean
./configure
make
make install
cd /siteroot/softs

#########7--#########

cd /siteroot/softs
tar xfvz zlib-1.2.3.tar.gz
cd zlib-1.2.3
make clean
./configure
make
make install
cd /siteroot/softs

##########8--##########

cd /siteroot/softs
tar xfvz libiconv-1.11.tar.gz
cd libiconv-1.11
./configure --prefix=/usr/local/libiconv
make
make install
cd /siteroot/softs

###########9--##############

cd /siteroot/softs
tar xfvz libxml2-2.6.29.tar.gz
cd libxml2-2.6.29
make clean
./configure
make
make install
cd /siteroot/softs

###########10--##############

cd /siteroot/softs
tar xfvz php-5.2.3.tar.gz
cd /siteroot/softs/php-5.2.3
make clean
#./configure --prefix=/siteroot/appserver/php5 --with-apxs2=/siteroot/appserver/httpd/bin/apxs --disable-debug --enable-safe-mode --enable-trans-sid --with-xml --with-mysql=/siteroot/appserver/mysql --with-pdo-mysql=/siteroot/appserver/mysql --enable-short-tags --with-gd --with-zlib --with-jpeg-dir=/usr/local/jpeg6 --with-png --enable-memory-limit --disable-posix --with-iconv --enable-mbstring=cn --enable-gd-nati --enable-ftp --enable-track-vars --enable-gd-nati

不加iconv
./configure --prefix=/siteroot/appserver/php5 --with-apxs2=/siteroot/appserver/httpd/bin/apxs --disable-debug --enable-safe-mode --enable-trans-sid --with-xml --with-mysql=/siteroot/appserver/mysql --with-pdo-mysql=/siteroot/appserver/mysql --enable-short-tags --with-gd --with-zlib --with-jpeg-dir=/usr/local/jpeg6 --with-png --enable-memory-limit --disable-posix --with-iconv-dir=/usr/local --enable-mbstring=cn --enable-gd-nati --enable-ftp --enable-track-vars --enable-gd-nati

加一个iconv的路径
( --with-iconv=/usr/local/libiconv/)用于转码
./configure --prefix=/siteroot/appserver/php5 --with-apxs2=/siteroot/appserver/httpd/bin/apxs --disable-debug --enable-safe-mode --enable-trans-sid --with-xml --with-mysql=/siteroot/appserver/mysql --with-pdo-mysql=/siteroot/appserver/mysql --enable-short-tags --with-gd --with-zlib --with-jpeg-dir=/usr/local/jpeg6 --with-png --enable-memory-limit --disable-posix --with-iconv=/usr/local/libiconv --enable-mbstring=cn --enable-gd-nati --enable-ftp --enable-track-vars --enable-gd-nati


make
make install
rm -rf /etc/php.ini
cp php.ini-dist /etc/php.ini


应行到上基本上装好了,下面是一些辅助



配置php.ini
extension_dir ='/siteroot/appserver/php5/lib/php/extensions/no-debug-non-zts-20060613'
其它的基本不用配
如果要配memcache的话
加上下面这一句
extension =memcache.so

###########11--##############
###########################################################
###instal Zend ZendOptimizer....
#####tar ...xfvz......zend...

##./install
###########################################################

###########12--##############

cd /siteroot/softs
tar xfvz squid-2.6.STABLE4.tar.gz
cd squid-2.6.STABLE4
make clean
./configure --prefix=/siteroot/appserver/squid
make
make install
cd /siteroot/softs

###########13--##############

cd /siteroot/softs
tar xfvz libevent-1.3b.tar.gz
cd libevent-1.3b
make clean
./configure --prefix=/siteroot/appserver/libevent
make
make install
rm -rf /usr/lib/libevent-1.3b.so.1
cp /siteroot/appserver/libevent/lib/libevent-1.3b.so.1 /usr/lib
cd /siteroot/softs


###########14--##############

cd /siteroot/softs
tar xfvz memcached-1.2.0.tar.gz
cd memcached-1.2.0
make clean
./configure --prefix=/siteroot/appserver/memcached -with-libevent=/siteroot/appserver/libevent
make
make install
cd /siteroot/softs

配置memcache

/siteroot/appserver/memcached/bin/memcached -d -m 800 -l 192.168.1.26 -p 11211 -u nobody (-d 启动进程 -m分配给Memcache使用的内存数量 -l是监听的服务器IP地址 -p 设置端口 -u运行Memcache的用户)

例子 1
usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 -p 12000 -c 256 -P /tmp/memcached.pid
(-d 选项是启动一个守护进程,-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,-u是运行Memcache的用户,我这里是 root,-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.200,-p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口,-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,如果要结束Memcache进程,执行:
# kill `cat /tmp/memcached.pid`

也可以启动多个守护进程,不过端口不能重复。)

查看memcache设置成功没

netstat -an|more(查看里面有所设端口没)



###########15--##############

cd /siteroot/softs
bunzip2 eaccelerator-0.9.5.1.tar.bz2
tar xfv eaccelerator-0.9.5.1.tar
cd eaccelerator-0.9.5.1
make clean
export PHP_PREFIX=/siteroot/appserver/php5
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config --prefix=/siteroot/appserver/eaccelerator
make && make install
cd /siteroot/softs


###########16--##############

cd /siteroot/softs
tar xfvz memcache-2.1.0.tgz
cd memcache-2.1.0
make clean
export PHP_PREFIX=/siteroot/appserver/php5
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
make && make install
cd /siteroot/softs

###########17--##############

cd /siteroot/softs
tar xfvz newsyslog-1.8.tar.gz
cd newsyslog-1.8
make clean
./configure
make
make install
cd /siteroot/softs



###########18--##############

cd /siteroot/softs
tar xfvz postfix-2.4.1.tar.gz
cd postfix-2.4.1
useradd postfix
useradd postdrop
make
make install
cd /siteroot/softs

(敲好多回车)

#####################################################
###soft config.....
#####################################################

Crate a new file: /usr/local/etc/newsyslog.conf, paste lines below:
CODE:
set squid_logpath = /siteroot/appserver/squid/var/logs
set squid_log = /siteroot/appserver/squid/var/logs/access.log
set date_squid_log = /siteroot/appserver/squid/var/logs/access%Y%M%D.log

SQUID{
restart: run /siteroot/appserver/squid/sbin/squid -k rotate
log: SQUID squid_log squid squid 644
archive: SQUID date_squid_log 0
}

3.run newsyslog in crontab,(example: run once 23:58 daily):
CODE:
58 23 * * * /usr/local/sbin/newsyslog


LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

DAV svn
SVNParentPath /source
AuthzSVNAccessFile /source/authz.conf
AuthType Basic
AuthName "Subversion.zoneyump"
AuthUserFile /source/authfile
Require valid-user


#######################################################
#######################################################

#cd /siteroot/softs
#tar xfvz subversion-1.4.4.tar.gz
#cd subversion-1.4.4
#make clean
#./configure --with-apxs=/siteroot/appserver/httpd/bin/apxs --prefix=/siteroot/appserver/subversion --with-apr=/siteroot/appserver/httpd #--with-apr-util=/siteroot/appserver/httpd --with-ssl --with-zlib --enable-maintainer-mode
#make
#make install

没有评论:

博客归档