■■管理者追加
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
# adduser admin
# passwd admin
■■常用设定文件做成快捷方式,留作将来使用方便
cd /root
ln -s /etc/yum.repos.d/CentOS-Base.repo
ln -s /etc/aliases
ln -s /etc/crontab
ln -s /etc/hosts.allow
ln -s /etc/hosts.deny
ln -s /etc/httpd/conf/httpd.conf
ln -s /etc/postfix/main.cf
ln -s /etc/my.cnf
ln -s /etc/sysconfig/network
ln -s /etc/ntp.conf
ln -s /etc/ntp/step-tickers
ln -s /etc/sysctl.conf
ln -s /etc/postfix/virtual
ln -s /etc/php.ini
■■sshd设定更改。默认设定可以使用root登录,非常危险,在这里禁用。
# vi /etc/ssh/sshd_config(注:直接起作用,不用重启。原有PermitRootLogin为加#注释掉)
PermitRootLogin no ←此行有效,把yes改成no
■■SVN安装
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
yum install subversion
■■postfix(mysql对应版)安装之前~
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
■■yum安装~
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
yum -y install ntp nmap net-snmp httpd mod_ssl php php-devel php-gd php-mbstring php-mysql libjpeg libpng libpng10 libungif ImageMagick gd mysql-server mysql gcc gcc-c++ flex autoconf automake libtool libtool-libs cvs php-eaccelerator
yum clean all
yum -y update
注:我加的20080319
yum --enablerepo=centosplus -d 0 search php
yum --enablerepo=centosplus -y install php
yum --enablerepo=centosplus upgrade php*
用来升级php5
以上5行用不上
■■php.ini设定
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
# vi /etc/php.ini
{{{
memory_limit = 32M
mbstring.language = Japanese
v
■■时刻同期设定
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
cd /root
# vi ntp.conf
加入国内时间服务器
chkconfig ntpd on
/etc/init.d/ntpd start
有可能已经start了,再start会报fail.
■■lokkit FireWall设定
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
# lokkit (未设定)
打开
ssh:TCP
smtp:TCP
http:TCP
https:TCP
mysql:TCP
stmp:UDP
※其余的全部关闭
■■Apache 2 Test Page 删除
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.OLD
■■关闭不必要的服务,开启必须服务器
 ̄ ̄ ̄ ̄ ̄ ̄以下很多本身就是都off的,有几个还是没有的 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
/sbin/chkconfig autofs off
/sbin/chkconfig cups off
/sbin/chkconfig cups-lpd off
/sbin/chkconfig gpm off
/sbin/chkconfig irda off
/sbin/chkconfig isdn off
/sbin/chkconfig messagebus off
/sbin/chkconfig netfs off
/sbin/chkconfig nfslock off
/sbin/chkconfig haldaemon off
/sbin/chkconfig pcmcia off
/sbin/chkconfig portmap off
/sbin/chkconfig rpcgssd off
/sbin/chkconfig rpcidmapd off
/sbin/chkconfig xfs off
/sbin/chkconfig smartd off
/sbin/chkconfig kudzu off
/sbin/chkconfig netfs off
/sbin/chkconfig messagebus off
/sbin/chkconfig readahead off
/sbin/chkconfig pcmcia off
/sbin/chkconfig microcode_ctl off
/sbin/chkconfig irqbalance off
/sbin/chkconfig readahead_early off
/sbin/chkconfig acpid on
/sbin/chkconfig anacron on
/sbin/chkconfig atd on
/sbin/chkconfig cpuspeed on
/sbin/chkconfig crond on
/sbin/chkconfig lm_sensors on
/sbin/chkconfig mdmonitor on
/sbin/chkconfig network on
/sbin/chkconfig ntpd on
/sbin/chkconfig snmpd on
/sbin/chkconfig sshd on
/sbin/chkconfig syslog on
/sbin/chkconfig xinetd on
/sbin/chkconfig postfix on
/sbin/chkconfig mysqld on
/sbin/chkconfig httpd on
注:xinetd 在这里没有发现。
用ntsysv确认一下
# ntsysv
?确实已经关闭的服务
autofs cups cups-lpd gpm irda isdn messagebus netfs nfslock pcmcia portmap rpcgssd rpcidmapd xfs
?确实已经开启的服务
acpid anacron atd cpuspeed crond lm_sensors mdmonitor network ntpd postfix snmpd
sshd syslog xinetd
?这些服务还不明确(Guofeng注,暂时可以不做更改)
apmd haldaemon iptables irqbalance kudzu microcode_ctl rawdevices smartd
■■Apache设定
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
为了能让Apache不重新启动也能自由使用VirtualHost设定
需要设定VirtualDocumentRoot
/var/www/html/openkaku.cn/public_html
这样设置之后,访问
http://openkaku.cn 就自然能够执行VirtualHost设定了
# vi /etc/httpd/conf/httpd.conf
{{{
ServerTokens Prod
:
ServerSignature Off
:
ExtendedStatus On
:
(这里没加) 这里是php5, 在conf.d里的php相关文件里已有LoadModule php5_module modules/libphp5.so
LoadModule php4_module /usr/lib/httpd/modules/libphp4.so
AddType application/x-httpd-php .php
:
DirectoryIndex index.html index.html.var index.php
:
LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedvhost
(这里只是加上%V)
:
# CustomLog logs/access_log combined
CustomLog "|/usr/sbin/rotatelogs /etc/httpd/logs/access_log.%Y%m%d 86400 540" combinedvhost
:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
:
VirtualDocumentRoot /var/www/html/%0/public_html
<Directory "/var/www/html">
AllowOverride All
</Directory>
<DirectoryMatch "/CVS/">
Deny from All
</DirectoryMatch>
<DirectoryMatch "/.svn/">
Deny from All
</DirectoryMatch>
}}}
※CVS svn目录让其不能访问
■■VirtualDocumentRoot
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
chown admin. /var/www/html
chmod 755 /var/www/html
以下是对于CentOS5进行的配置安装.
■■HTTPD動作確認
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
# /etc/init.d/httpd start
# tail /var/log/httpd/error_log
启动mysqld提示:
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password' 这部就可以了,下一部不用作了
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/bin/mysqlbug script!