一,准备
1,安装一些软件
rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum update
yum groupinstall ‘Development Tools’
yum install wget
2,日期时间设置正确, 时区设置正确, CST
s1)安装ntp
#yum install ntp
s2)同步时钟
#ntpdate pool.ntp.org(执行此命令需要先停止ntpd服务)
s3)查看ntpd状态
#ntpstat
s4)系统时钟与硬件时钟同步(系统时钟为准)
#hwclock –systohc
s5)查看硬件时钟
#hwclock –show
安装过程
1、调整/etc/hosts,调整后的内容如下:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.0.200 server.ispcpcn.com server
::1 localhost6.localdomain6 localhost6
2,安装Quota
yum install quota
编辑/etc/fstab,添加,usrquota,grpquota 到/ partition(/dev/VolGroup00/LogVo100)后面,添加后如下:
/dev/VolGroup00/LogVol00 / ext3 defaults,usrquota,grpquota 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
然后运行如下命令启用quota:
touch /aquota.user /aquota.group
chmod 600 /aquota.*
mount -o remount /
quotacheck -avugm
quotaon -avug
注意:这种设置可能不适合VPS。
[root@iyiyun001 ~]# quotacheck -avugm
quotacheck: Cannot guess format from filename on /dev/mapper/vg_iyiyun001-lv_root. Please specify format on commandline.
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
[root@iyiyun001 ~]# quotaon -avug
quotaon: cannot find //quota.group on /dev/mapper/vg_iyiyun001-lv_root [/]
quotaon: cannot find //quota.user on /dev/mapper/vg_iyiyun001-lv_root [/]
3,安装Apache, MySQL, phpMyAdmin
yum install httpd mysql-server php php-mysql php-mbstring php-mcrypt phpmyadmin rpm-build gcc mysql-devel openssl-devel cyrus-sasl-devel pkgconfig zlib-devel pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel
4,安装Courier-IMAP, Courier-Authlib和Maildrop1)建立一个普通的用户。为编译courier-imap做准备。
#useradd -m -s /bin/bash ispcpcn
为用户设置密码:
#passwd ispcpcn
然后输入密码和确认密码,用户就建成了。
同时,我们要给其添加可运行sudo命令的许可
#visudo
找到如下内容:
root ALL=(ALL) ALL
在后面增加一行:
ispcpcn ALL=(ALL) ALL
保存退出。
su ispcpcn
mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386
echo “%_topdir $HOME/rpm” >> $HOME/.rpmmacros
cd /tmp
wget http://nchc.dl.sourceforge.net/project/courier/authlib/0.63.0/courier-authlib-0.63.0.tar.bz2
wget http://nchc.dl.sourceforge.net/project/courier/imap/4.9.3/courier-imap-4.9.3.tar.bz2
wget http://nchc.dl.sourceforge.net/project/courier/maildrop/2.5.4/maildrop-2.5.4.tar.bz2
sudo rpmbuild -ta courier-authlib-0.63.0.tar.bz2
cd $HOME/rpm/RPMS/i386
sudo rpm -ivh courier-authlib-0.63.0-1.i386.rpm courier-authlib-mysql-0.63.0-1.i386.rpm courier-authlib-devel-0.63.0-1.i386.rpm(按照实际生成的路径)
cd /tmp
rpmbuild -ta courier-imap-4.9.3.tar.bz2
cd $HOME/rpm/RPMS/i386
sudo rpm -ivh courier-imap-4.9.3-1.i386.rpm(按照实际生成的路径)
cd /tmp
sudo rpmbuild -ta maildrop-2.5.4.tar.bz2
cd $HOME/rpm/RPMS/i386
sudo rpm -ivh maildrop-2.5.4-1.i386.rpm(按照实际生成的路径)
exit
安装postfix
yum install postfix
chkconfig –levels 235 courier-authlib on
/etc/init.d/courier-authlib start
chkconfig –levels 235 sendmail off
chkconfig –levels 235 postfix on
chkconfig –levels 235 saslauthd on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd restart
配置Courier
chkconfig –levels 235 courier-imap on
/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart
cd /usr/lib/courier-imap/share/
rm -f imapd.pem
rm -f pop3d.pem
vi /usr/lib/courier-imap/etc/imapd.cnf
最后编辑结果如下:
[…]
CN=server1.example.com
[…]
vi /usr/lib/courier-imap/etc/pop3d.cnf
[…]
CN=server1.example.com
[…]
./mkimapdcert
./mkpop3dcert
/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart
安装getmail
yum install getmail
设置MySQL密码和配置phpMyAdmin
chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start
mysqladmin -u root password yourrootsqlpassword
vi /etc/httpd/conf.d/phpmyadmin.conf
#
# Web application to manage MySQL
#
#<directory “=”” usr=”” share=”” phpmyadmin”=””>
# Order Deny,Allow
# Deny from all
# Allow from 127.0.0.1
#</directory>
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin
vi /usr/share/phpmyadmin/config.inc.php
[…]
/* Authentication type */
$cfg[‘Servers’][$i][‘auth_type’] = ‘http’;
[…]
chkconfig –levels 235 httpd on
/etc/init.d/httpd start
安装Amavisd-new, SpamAssassin和ClamAV
yum install amavisd-new spamassassin clamav clamd unzip bzip2 unrar perl-DBD-mysql
chkconfig –levels 235 amavisd on
chkconfig –levels 235 clamd on
/usr/bin/freshclam
/etc/init.d/amavisd start
/etc/init.d/clamd start
mkdir /var/run/amavisd /var/spool/amavisd /var/spool/amavisd/tmp /var/spool/amavisd/db
chown amavis /var/run/amavisd /var/spool/amavisd /var/spool/amavisd/tmp /var/spool/amavisd/db
Starting amavisd: The value of variable $myhostname is “iyiyun001″, but should have been
a fully qualified domain name; perhaps uname(3) did not provide such.
You must explicitly assign a FQDN of this host to variable $myhostname
in amavisd.conf, or fix what uname(3) provides as a host’s network name!
[FAILED]
手动设置“hostname host.chinawill.cn”
安装Apache的组件mod_php, mod_fcgi/PHP5和suPHP
yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-mbstring php-mcrypt php-mhash php-mssql php-snmp php-soap php-tidy curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel mod_fcgid php-cli httpd-devel
vi /etc/php.ini
[…]
;error_reporting = E_ALL
error_reporting = E_ALL & ~E_NOTICE
[…]
cgi.fix_pathinfo = 1
cd /tmp
wget http://www.suphp.org/download/suphp-0.7.1.tar.gz
tar xvfz suphp-0.7.1.tar.gz
cd suphp-0.7.1/
./configure –prefix=/usr –sysconfdir=/etc –with-apr=/usr/bin/apr-1-config –with-apxs=/usr/sbin/apxs –with-apache-user=apache –with-setid-mode=owner –with-php=/usr/bin/php-cgi –with-logfile=/var/log/httpd/suphp_log –enable-SUPHP_USE_USERGROUP=yes
make && make install
vi /etc/httpd/conf.d/suphp.conf
[global]
;Path to logfile
logfile=/var/log/httpd/suphp.log
;Loglevel
loglevel=info
;User Apache is running as
webserver_user=apache
;Path all scripts have to be in
docroot=/
;Path to chroot() to before executing script
;chroot=/mychroot
; Security options
allow_file_group_writeable=true
allow_file_others_writeable=false
allow_directory_group_writeable=true
allow_directory_others_writeable=false
;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=true
;Send minor error messages to browser
errors_to_browser=false
;PATH environment variable
env_path=/bin:/usr/bin
;Umask to set, specify in octal notation
umask=0077
; Minimum UID
min_uid=100
; Minimum GID
min_gid=100
[handlers]
;Handler for php-scripts
x-httpd-suphp=”php:/usr/bin/php-cgi”
;Handler for CGI-scripts
x-suphp-cgi=”execute:!self”
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.32.tar.gz
tar zxvf pure-ftpd-1.0.32.tar.gz
cd pure-ftpd-1.0.32/
./configure –prefix=/opt/pureftpd –with-mysql= –with-paranoidmsg –with-shadow –with-welcomemsg –with-uploadscript –with-quotas –with-cookie –with-virtualhosts –with-diraliases –with-sysquotas –with-ratios –with-ftpwho –with-throttling –with-altlog –with-language=simplified-chinese
make && make install
mkdir /etc/pure-ftpd
cp pureftpd-mysql.conf /etc/pure-ftpd
cp configuration-file/pure-ftpd.conf /etc/pure-ftpd
cp configuration-file/pure-config.pl /etc
vi /etc/init.d/pure-ftpd
chmod 755 /etc/pure-config.pl
ln -s /opt/pureftpd/sbin/pure-ftpd /usr/sbin/
chmod 755 /etc/init.d/pure-ftpd
chkconfig –levels 235 pure-ftpd on
/etc/init.d/pure-ftpd start
# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server