Tag Archives: Linux

CentOS 添加虚拟主机VirtualHost及伪静态Rewrite

1、找到Apache的配置文件 /etc/httpd/conf/httpd.conf

2、找到配置文件中的以下代码

LoadModule vhost_alias_module modules/mod_vhost_alias.so

如果前面有#号注释,去掉#号注释,这代表是否开启虚拟主机服务

3、找到配置文件中的以下代码,一般在配置文件的最末尾部分

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier 
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#
 
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<virtualhost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</virtualhost>

需要用到的部分有[……]

继续阅读

Linux如何设置定时任务

1、基本概念

crontab命令常见于Unix和类Unix的操作系统之中,用于设置周期性被执行的指令。该命令从标准输入设备读取指令,并将其存放于“crontab”文件中,以供之后读取和执行。crontab储存的指令被守护进程激活, crond常常在后台运行,每一分钟检查是否有预定的作业需要执行。这类作业一般称为cron jobs。

2、命令格式

1
2
3
4
5
6
7
8
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

2.1、每月每天每小时的第 0 分钟执行一次 xxoo
0 * * * * xxoo

2.2、在 12 月份期间, 每天的早上 6 点到 12 点中,每隔 20 分钟执行一次 xxoo
*/20 6-12 * 12 * xxoo

2.3、周一到周五每天下午 5:00 xxoo
0 17 * * 1-5 xxoo

2.4、每月每天的午夜 0 点 20 分, 2 点 20 分, 4 点 20 分 xxoo
20 0-23/2 * * * xxoo

3、基本操作[……]

继续阅读

Linux下添加新硬盘并挂载使用

1、 查看新磁盘信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@Crayfish ~]# fdisk -l
 
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00060953
 
    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1        2611    20970496   83  Linux
 
Disk /dev/xvdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

2、硬盘分区

2.1、进入fdisk模式

1
2
3
4
5
6
7
8
9
10
11
[root@Crayfish ~]# fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc233737d.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

2.2、输入n进行分区
[……]

继续阅读