安装Ubuntu非常简单,不再多述。注意几点:
1、安装之前先插上网线
2、除了OpenSSH,不装其它任何的服务器软件,Apache/Mysql/PHP都不装,后面使用源码自己编译安装

Ubuntu安装后的配置:
1、启用root用户
sudo passwd root
输入密码后:
su
即可用root用户完成后面的配置与维护。

2、配置网络
如果在安装时没有配置好网络环境,可手工配置:
vi /etc/network/interfaces
根据环境正确配置即可。重启网络:
/etc/init.d/networking restart

3、配置apt-get的更新位置
如果想使用最新版本的各种包,此步必须。
vi /etc/apt/sources.list
编辑文件,主要是禁止从cdrom安装软件,而从网上下载最新的版本。
#
# deb cdrom:[Ubuntu-Server 7.10 _Gutsy Gibbon_ – Release i386 (20071016)]/ gutsy main restricted

#deb cdrom:[Ubuntu-Server 7.10 _Gutsy Gibbon_ – Release i386 (20071016)]/ gutsy main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://ubuntu.cn99.com/ubuntu/ gutsy main restricted
deb-src http://ubuntu.cn99.com/ubuntu/ gutsy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://ubuntu.cn99.com/ubuntu/ gutsy-updates main restricted
deb-src http://ubuntu.cn99.com/ubuntu/ gutsy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://ubuntu.cn99.com/ubuntu/ gutsy universe
deb-src http://ubuntu.cn99.com/ubuntu/ gutsy universe
deb http://ubuntu.cn99.com/ubuntu/ gutsy-updates universe
deb-src http://ubuntu.cn99.com/ubuntu/ gutsy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://ubuntu.cn99.com/ubuntu/ gutsy multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ gutsy multiverse
deb http://ubuntu.cn99.com/ubuntu/ gutsy-updates multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ gutsy-updates multiverse

## Uncomment the following two lines to add software from the ‘backports’
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://ubuntu.cn99.com/ubuntu/ gutsy-backports main restricted universe multiverse
# deb-src http://ubuntu.cn99.com/ubuntu/ gutsy-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical’s
## ‘partner’ repository. This software is not part of Ubuntu, but is
## offered by Canonical and the respective vendors as a service to Ubuntu
## users.
# deb http://archive.canonical.com/ubuntu gutsy partner
# deb-src http://archive.canonical.com/ubuntu gutsy partner

deb http://security.ubuntu.com/ubuntu gutsy-security main restricted
deb-src http://security.ubuntu.com/ubuntu gutsy-security main restricted
deb http://security.ubuntu.com/ubuntu gutsy-security universe
deb-src http://security.ubuntu.com/ubuntu gutsy-security universe
deb http://security.ubuntu.com/ubuntu gutsy-security multiverse
deb-src http://security.ubuntu.com/ubuntu gutsy-security multiverse

4、更新Ubuntu:
apt-get update
apt-get upgrade
此步需要花费大概30分钟,如果出现网络错误可重新执行或加上–fix-missing参数重新执行。

5、安装各种软件包
可一次安装N个:
apt-get install binutils cpp fetchmail flex gcc libarchive-zip-perl libc6-dev libcompress-zlib-perl libdb4.3-dev libpcre3 libpopt-dev lynx m4 make ncftp nmap perl perl-modules unzip zip zlib1g-dev autoconf automake1.9 libtool bison autotools-dev g++ build-essential
上面的命令要放在一行执行。这些包基本都是后面需要使用的或者平时也经常可以用到的,可根据自己需要选择。

6、安装libncurses5-dev
很多朋友在使用源码安装软件时在make时出现错误,就是因为没有安装这个包:
checking for termcap functions library… configure: error: No curses/termcap library found
解决办法:
apt-get install libncurses5-dev

7、增加ll别名
以前用fedora core时都有ll命令,Ubuntu下没有,很不习惯,只好自己设置:
vi ~/.bashrc
此文件中其实已经有别名的配置,只是已经注释掉了,去掉注释即可,同时为vi设置别名为vim。
alias ll=’ls -l’
alias la=’ls -A’
alias l=’ls -CF’
alias vi=’vim’

正式开始安装软件,这部分主要是mysql/apache的安装。

一、安装mysql
mysql使用utf-8作为默认编码:
groupadd mysql
useradd -g mysql mysql
tar -zxvf mysql-5.0.45.tar.gz
cd mysql-5.0.45
./configure –prefix=/usr/local/mysql –with-charset=utf8 –with-collation=utf8_general_ci –with-extra-charsets=latin1
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
bin/mysql_install_db –user=mysql
chown -R root .
chown -R mysql var
chgrp -R mysql .
bin/mysqld_safe –user=mysql &

将mysql加入PATH:
vi /etc/profile
增加:
PATH=/usr/local/mysql/bin:”${PATH}”

让mysql随系统一起启动
cp support-files/mysql.server /etc/init.d/mysqld
cd /etc/init.d
update-rc.d mysqld defaults

重启服务器,验证mysql是否能随系统正常启动,启动后:
mysql
如果能直接进入则说明启动成功。
为了安全,修改root密码:
mysql>use mysql
mysql>UPDATE user SET password=PASSWORD(’new_password’) WHERE user=’root’;
mysql>FLUSH PRIVILEGES;
mysql>exit

二、安装apache
1、安装apache前,先安装openssl,因为后面要配置apache支持https协议:
tar -zxvf openssl-0.9.8e.tar.gz
cd openssl-0.9.8e
./config –prefix=/usr/local/ssl
make
make test
make install

2、安装apache,configure参数可根据需要调整。
tar -zxvf httpd-2.2.6.tar.gz
cd httpd-2.2.6
./configure –prefix=/usr/local/apache –enable-modules=all –enable-rewrite –enable-forward –enable-ssl –with-ssl=/usr/local/ssl –enable-mods-shared=all –enable-deflate –enable-proxy –enable-proxy-balancer –enable-proxy-http
make
make install
修改conf/httpd.conf的ServerName:
ServerName 127.0.0.1:80

测试apache是否正常

让apache随系统一起启动
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
cd /etc/init.d
update-rc.d httpd defaults

三、安装PHP

先安装php需要的一些包。

1、安装libxml2:
apt-get install libxml2 libxml2-dev
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure –prefix=/usr/local/zlib
make
make install

2、安装jpeg:
tar -zxvf jpegsrc.v6b.tar.gz
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

3、安装libpng:
tar -zxvf libpng-1.2.16.tar.gz
cd libpng-1.2.16
./configure –prefix=/usr/local/libpng
make
make install

4、安装freetype:
tar -zxvf freetype-2.3.3.tar.gz
cd freetype-2.3.3
./configure –prefix=/usr/local/freetype
make
make install

5、安装gd:
tar -zxvf gd-2.0.33.tar.gz
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

6、安装curl:
tar -zxvf curl-7.16.1.tar.gz
cd curl-7.16.1
mkdir -p /usr/local/curl
./configure –prefix=/usr/local/curl –with-ssl
make
make install

7、安装libiconv:
tar -zxvf libiconv-1.11.tar.gz
cd libiconv-1.11
./configure –prefix=/usr/local/iconv
make
make install

8、正式安装PHP:
参数比较多,可根据需要安装,一般情况下这些已经够了。
tar -zxvf php-5.2.5.tar.gz
cd php-5.2.5
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –with-config-file-path=/usr/local/apache/conf –enable-magic-quotes –with-openssl=/usr/local/ssl –with-zlib=/usr/local/zlib –with-zlib-dir=/usr/local/zlib –with-curl=/usr/local/curl –enable-ftp –with-openssl-dir=/usr/local/ssl –with-gd=/usr/local/gd –with-jpeg-dir=/usr/local/jpeg –with-png-dir=/usr/local/libpng –with-freetype-dir=/usr/local/freetype –enable-gd-native-ttf –enable-mbstring –with-mysql=/usr/local/mysql –with-pdo-mysql=/usr/local/mysql –enable-soap –enable-sockets –enable-zip –with-iconv –enable-zend-multibyte –with-mysql-sock=/tmp/mysql.sock –enable-sqlite-utf8
make
make test
make install
cp php.ini-dist /usr/local/apache/conf/php.ini

9、安装ZendOptimizer-3.3.0a
tar -zxvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
cd ZendOptimizer-3.3.0a-linux-glibc21-i386
./install.sh
安装过程中指定ZendOptimizer的安装目录及php.ini所在的路径即可

10、让apache支持PHP:
vi /usr/local/apache/conf/httpd.conf
在最后加上:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
将<Directory “/usr/local/apache/htdocs”>修改为:
<Directory “/home/dingl/php-web/test”>

修改DocumentRoot为”/home/dingl/php-web/test”
在此目录下新建index.php文件,内容如下:
<?php phpinfo()?>
打开
http://192.168.1.xx/index.php即可看到php的信息,说明php安装成功

重启服务器即可看到Apache与Resin同时启动了,使用http://www.dingl.com/即可正常访问!