‘服务器及网络’ 存档

Apache服务器的二级域名支持

首先,你的拥有一个有泛域名解析的顶级域名,例如: domain.com其次,在 httpd.conf 中打开 mod_rewrite之后,在 httpd.conf 的最后,添加以下内容:

RewriteEngine on
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/usr/local/etc/apache(Unix平台最流行的WEB服务器平台)/vhost.map
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
(更多…)

Windows中回收站 Recycler和Recycled ,$Recycle.Bin区别

在“文件夹选项”“查看”“高级设置”里选中“显示所有文件和文件夹”以及去勾“隐藏受保护的操作系统文件(推荐)”项后会看到一个叫做RECYCLER的文件夹,无法删除。可能你还会看到一个Recycled的文件夹,你也许知道他们都是回收站,可是你知道它们的关系吗?

区别:Recycler是NTFS磁盘系统的回收站,Recycled是FAT32磁盘系统的回收站,Vista的回收站是$RECYCLE.BIN 。从FAT32转换成NTFS后将会导致磁盘存在两个回收站。RECYCLER下面再是以用户SID位标识的回收站文件夹。也就是说NTFS下这个用户删除的东西,另一个用户的回收站是看不到的。

其他原因:还有可能就是病毒,比如U盘病毒就喜欢生成个RECYCLER把病毒文件放里面。

解决方法:这两个文件不能删除,但可以执行剪切、合并操作,因此将所有盘的该文件合并城一个文件,剪切转移到U盘上,格式化U盘,世界清净咯。当删除后再执行与回收站有关的操作时系统会自动生成一个回收站。

SendMail Server 的各个文件(执行文件和配置)说明

Sendmail 几乎所有的设定档都安置在 /etc/mail 底下,不过,如果你是以 RPM 安装的话,那么还有所谓的 sendmail-cf 的设定档,这个就是使用 M4 在进行 sendmail.cf 设定的程序!由于 Sendmail Server 所使用到的套件并不少,这包括有 sendmail, imap 以及 m4 等等,我们针对这些套件来谈一谈每个目录与档案下的数据吧!

  • 设定档
    Sendmail 的设定档几乎全部都在 /etc/mail 底下,但是也不一定!因为还需要看当初你建立 sendmail.cf 这个主要设定档时,将各个档案放置的地点而定!这部份可以使用 RPM 的方式来反查出你的设定档案的路径。Sendmail 与相关套件的设定档与相关的说明为:

    • /etc/mail/sendmail.cf 或 /etc/sendmail.cf:这个就是 sendmail 的主要设定档,所有的参数都是他在管理的!但是,这个档案内的各个设定被号称为『天书』,所谓的天书就是『非一般人看的懂得!』,就连 sendmai 官方网站自行开发出来的设定程序也都『告诫大家不要手动编辑这个档案』, 所以这里我们也不谈这个档案的内容啦!但是既然这个是主要设定档,那么又不要让大家手动编辑,那我要怎样进行 sendmail 设定的修改呢?这个时候就需要使用到 M4 这个指令了! m4 可以将简单的一些环境设定参数,重新以内定的函式库或者函式定义来『制作』 sendmail.cf 这个设定档呢!sendmail 预设的 sendmail.cf 放置在 /etc/mail/sendmail.cf ,但是某些 Linux distributions 则将他改放在 /etc/sendmail.cf 这里~

    • /usr/share/sendmail-cf/cf/xxxx.m4 : 刚刚我们提过那个 sendmail.cf 对吧!而由于这个档案最好不要手动修改,所以需要使用到 m4 这支程序。 m4 可以将一个简单的环境设定档转成 sendmail.cf ,那个环境设定档就是 sendmail-cf 这个套件所提供的啦。在 Red Hat 7.x 的系统中,主要的环境设定档就是 /usr/share/sendmail-cf/cf/redhat.mc 这个档案喔!不过,在 Red Hat 7.3 以后的所有 Red Hat Linux 版本当中,这个档案被移动到 /etc/mail/sendmail.mc 了!至于其它的 Linux 版本则请参考你的 sendmail-cf 套件的内容!

    • /etc/mail/local-host-names :这个档案主要用来处理一个主机同时拥有多个主机名称时候的收发信件主机名称问题。这个档案的用途可大了!当你的主机拥有多个 HOSTNAME 的时候,例如我的主机拥有三、四个主机名称,那么是否每个名称都可以用来做为收受信件的主机名称 ( To: .. ) 呢?并非如此!如果你的主机名称为 test1.your.domain 以及 test2.your.domain ,而且这两个 hostname 您都希望可以用在收受电子邮件,果真如此,那么,你就必需将这两个名字都写入 local-host-names 这个档案当中,一个主机名字占用一行。注意:没有写入这个档案的『你的主机名称』,那信件将无法正确的寄达这部主机喔~ 例如:www.vbird.adsldns.org、vbird.adsldns.org这两个主机名称的 ip 都是相同的,也就是指向同一台机器上。假设这台主机名称预设为 vbird.adsldns.org,那在预设情况下,寄给 userid@vbird.adsldns.org 都是 ok 没有问题的!但是寄给 userid@www.vbird.adsldns.org 就会出现错误。其中原因是因为没有告诉 MTA 除了 vbird.adsldns.org 这个主机名称外,还有 www.vbird.adsldns.org 也是指向这台主机上。所以寄给 userid@www.vbird.adsldns.org 会出现错误,通常就是 mail loop to me,要不然就是不允许 relay 的错误情况。

    • /etc/mail/access.db :这个是『规定谁可以或不可以使用本邮件服务器的数据库』,要转成这个数据库需要藉由 makemap 以及 /etc/mail/access 档案的配合!这个档案可以说是 Sendmail 里面最重要的『使用者权限管理』的数据了!在后面我们会继续说明。

    • /etc/mail/aliases.db 或 /etc/aliases.db :这个 aliases.db 是用来设定『信箱别名』的一个咚咚!你可以藉由这个档案的设定来规范你的『群组收信』喔!不过,还需要藉由 aliases 及 newaliases 来做成这个档案才行!

    • /etc/mail/statistics :这个档案在记录 Sendmail 收发信件的相关信息喔!
  • 执行档
    Sendmail 的执行档也不少,得说一说:

    • /usr/sbin/sendmail:就是 sendmail 的主要执行档啦!他会读取 sendmail.cf 这个档案的设定内容喔。你在发送信件时,就是使用这支程序啦!启用这支程序之后,预设的启用的 port 是 25 咯。

    • /usr/sbin/ipop3d:sendmail 的功能是在处理寄信问题,而 ipop3d 就是处理 client 的收信问题啦!如果你的 Mail Server 希望提供客户端使用 Netscape 或 OutLook express 来收信,那么就需要提供这个服务才行!这个服务的设定档在 Red Hat 当中是在 /etc/xinetd.d/ipop3 ,如果是 Open Linux server 3.1.1 的话,那就会变成在 /etc/inet.d/imap 这个档案中。注意: pop3 是由 imap 套件所提供的,并没有包含在 sendmail 套件之中喔!

    • /usr/sbin/makemap:主要将 access 转成 access.db 的数据库制作的执行文件;

    • /usr/sbin/mailstats:将 /etc/mail/statistics 档案读出来的一支程序!可以查看到目前为止 Sendmail 工作共传送、接收多少邮件啰!

    • /usr/bin/newaliases:将 /etc/mail/aliases 转成 /etc/mail/aliases.db 的执行档!

    • /usr/bin/mailq:用来观察 /var/spool/mqueue 这个邮件暂存目录的数据情况的指令!

    • /usr/bin/m4:这个就是将 *.mc 档案转成 *.cf 档案的主要执行档啰!需要搭配 sendmail 原始码,或者是 sendmail-cf 这个套件才行!注意: m4 是也需要额外的安装的一个套件喔!sendmail 原本套件中并未包含 m4 这个套件!
  • 邮件相关目录
    sendmail 接收下来的邮件放置在哪里呢?

    • /var/spool/mail :这个是邮件『收受下来之后,每个使用者信件放置的目录』,一个账号会使用掉一个档案,例如你的账号为 test ,那么你的信在 Server 中时,就是 /var/spool/mail/test 这个档案了!此外,你的 POP3 的协议亦是使用这个目录中的 mailbox 做为预设的邮件取得的档案数据。
    • /var/spool/mqueue:当邮件由于对方主机的问题,或者是网络的问题,而无法送出去时,那么该封邮件将会暂时的存放在这个目录下,然后主机会每隔大约 30 ~ 60 分钟重新尝试传送一遍,通常设定在五天内该封信件还寄不出去,那就会退给原发信者了!
    • /var/spool/clientmqueue:这是新的 sendmail 8.12 版本才会出现的队列目录 (您如果想要以 tarball 安装 sendmail 的话,请务必参考本章底下的说明,这个目录的权限设定相当的重要喔!) 。

停止SendMail

service sendmail stop就搞定了。这下当前的sendmail一个都没有了,而且也不会再有了。

但是这个命令的作用其实就是“当前系统停止sendmail服务”,而不代表机器重启后也停止sendmail服务。因此还需要找到彻底关闭sendmail的办法。一下子找到了两个相关命令。

ntsysv工具为激活或停运服务提供了简单的界面。可惜在我们机器上运行的界面实在不敢恭维,也没时间找原因了,放弃之。

chkconfig 命令也可以用来激活和停运服务。

执行命令:chkconfig –list sendmail

sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off

表明sendmail在level在2.3.4.5时是自动开启的。而一般系统设置为中间level(3),因此每次机器重启,sendmail会自动重启。

chkconfig –level 2345 sendmail off

这样以来,sendmail在2、3、4、5级别也关闭了。这样,机器重启之后,sendmail也不会重启了。

Linux cron 设置

#cd /etc //进入相应目录

#vim crontab //使用VIM进行编辑

…….操作

#crontab crontab //重启服务

#crontab -l //查看

=====参数=====

About crontab

List of files that you want to run on a regular schedule.

Syntax

crontab [-e] [-l] [-r] [filename]

-e edit a copy of the current user’s crontab file, or creates an empty file to edit if crontab does not exist. When editing is complete, the file is installed as the user’s crontab file. If a user- name is given, the specified user’s crontab file is edited, rather than the current user’s crontab file; this may only be done by a super-user. The environment variable EDITOR determines which editor is invoked with the -e option. The default editor is ed. Note that all crontab jobs should be submitted using crontab ; you should not add jobs by just editing the crontab file because cron will not be aware of changes made this way.
-l list the crontab file for the invoking user. Only a super-user can specify a username following the -r or -l options to remove or list the crontab file of the specified user.
-r remove a user’s crontab from the crontab
filename The filename that contains the commands to run.

Lines that can be in the crontab file.

minute (0-59),
hour (0-23),
day of the month (1-31),
month of the year (1-12),
day of the week (0-6 with 0=Sunday).

Examples

crontab -e = edits the crontab file to be used.

0 12 14 2 * mailx john%Happy Birthday!%Time for lunch.

Below is a table that represents what each of the above fields are for.

min hour dayofmonth monthofyear dayofweek command
0 12 14 2 * mailx john%Happy Birthday!%Time for lunch.
Options Explanation
* Is treated as a wild card. Meaning any possible value.
*/5 Is treated as ever 5 minutes, hours, days, or months. Replacing the 5 with another numerical value will change this option.
2,4,6 Treated as an OR, so if placed in the hours, this could mean at 2, 4, or 6 o-clock.
9-17 Treats for any value between 9 and 17. So if placed in day of month this would be days 9 through 17. Or if put in hours it would be between 9 and 5.

详细参考:http://www.computerhope.com/unix/ucrontab.htm

服务器配置:修改php.ini以达到 屏蔽错误信息

当PHP启动的时候,它将在Web服务器标准头信息中添加PHP版本号信息。如果希望关闭此功能,可以将expose_php设置为false。这项功能非常有用,例如,可以在Web服务器上屏蔽此信息以防范潜在的黑客攻击。

expose_php = On

不过不显示错误倒安全点,建议调试时打开,然后提供服务时关闭。

提供一点资料给你:

display_errors = On

php缺省是打开错误信息显示的,我们把它改为:

display_errors = Off

关闭错误显示后,php函数执行错误的信息将不会再显示给用户,这样能在一定程度上防止攻击者从错误信息得知脚本的物理位置,以及一些其它有用的信息,起码给攻击者的黑箱检测造成一定的障碍。这些错误信息可能对我们自己有用,可以让它写到指定文件中去,那么修改以下:

log_errors = Off

改为:

log_errors = On

以及指定文件,找到下面这行:

;error_log = filename

去掉前面的;注释,把filename改为指定文件,如/usr/local/apache/logs/php_error.log

error_log = /usr/local/apache/logs/php_error.log

这样所有的错误都会写到php_error.log文件里。

Apache 中设置目录别名网站

如果你的服务器对应IP是 192.168.1.2 或者其他,本身已经有一个站点A存在,现在另外设置站点B,站点B的目录不在站点A目录下,也不做虚拟主机,现在做目录别名设置。

在Apache 中设置如下:

Alias /dada/ “/home/dada//”
<Directory “/home/dada/”>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

用 http://192.168.1.2/dada/ 即可访问站点B

Win Apache VirtualHost虚拟主机配置

服务器配置

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *

<VirtualHost *>
ServerAdmin abc@abc.com
DocumentRoot “E:/WAMP/Apache/htdocs/”
ServerName abc.com
ServerAlias www.abc.com
DirectoryIndex index.htm
</VirtualHost>

<Directory “E:/WAMP/Apache/htdocs”>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Twitter Delicious Facebook Digg Stumbleupon Favorites 更多
如非标明[原创]的内容均来自互联网,如有侵权请来信告知以便删除。