Gowhich

Durban's Blog

第一步:

在main.php配置文件的component域中添加urlManager模块,并加入urlrules.

引入rule文件,代码如下

1
2
3
4
5
6
7
8
9
$urls = include(dirname(__FILE__) . '/urlrules.php');
urlManager配置修改如下

'urlManager'=>array(
'urlFormat' => 'path',
'showScriptName' => false,//隐藏index.php
'urlSuffix' => '.html',//后缀
'rules' => $urls,
),

第二步:在同级目录下写urlrules.php.如:

1
2
3
4
5
return array(
'/index.html' => 'site/index', //首页
'search' => 'search/index'

);

第三步,当然是配置服务器的rewrite模块,使得入口为index.php

1)apache下,在网站根目录下建立.htaccess如下:

1
2
3
4
5
6
7
8
9
10
Options +FollowSymLinks 

IndexIgnore */*

RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php
  1. nginx下在php配置模块和location模块添加rewrite如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
location / {
root /home/george/workspace/EclipsePHP/webroot;
index index.html index.php index.htm;
#try_files $uri $uri/ @rewrite;
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~ \.php$ {
root /home/george/workspace/EclipsePHP/webroot;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/george/workspace/EclipsePHP/webroot$fastcgi_script_name;
include fastcgi_params;
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}

完了,再看看你的网站的url 是不是漂亮了不少,同行努力!

在Ubuntu Server上,设置NTP时间同步非常简单,就如下几步:

第一,可以先进行手动更新一次时间(可选):

sudo ntpdate ntp.ubuntu.com

第二,创建一个定时执行的文件:

sudo vim /etc/cron.daily/ntpdate

然后在其中添加一行:ntpdate ntp.ubuntu.com,保存退出。

第三,修改这个定时执行文件的权限,使其变成可执行文件:

sudo chmod 755 /etc/cron.daily/ntpdate

==========================================

下面解析一下,第一句是把当前时区调整为上海就是+8区,想改其他时区也可以去看看/usr/share/zoneinfo目录;

然后第二句是利用ntpdate同步标准时间.

没有安装ntpdate的可以yum一下:

yum install -y ntpdate

加入定时计划任务,每隔10分钟同步一下时钟

crontab -e

0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP

这样,我们就可以来解决在CentOS系统中时间不准确的问题了。

如果执行命令出现一下错误

  1.提示:7 Dec 19:24:55 ntpdate[2120]: the NTP socket is in use, exiting

  这个是你linux机器上已经存在这个进程,输入:ps -ef | grep ntpd

  Kill掉ntp的进程

  2.提示:No Server suitable for synchronization found

  这个是最容易出现的问题,比较常见的是配置好服务器并启动服务器进程后,马上

  启动客户进程,那么客户进程就会报错。解决方法是,在大约3-5分钟以后启动进程就行

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

0%