作者:@ouyang
发布时间:2016年07月19日
阅读: 2,605
分类:学习笔记
网站有时候有多个域名,所以需要做跳转
有时候也需要顶级直接跳转到www上,现就记录nginx跳转实例。
server
{
listen 80;
server_name www.1.com www.22.com.cn www.333.com;
index index.html index.htm index.php;
root /home/www;
if ($host = 'www.22.com.cn' ) {
rewrite ^/(.*)$ http://www.1.com/$1 permanent;
}
if ($host = '333.com' ) {
rewrite ^/(.*)$ http://www.1.com/$1 permanent;
}
if ($host = '22.com.cn' ) {
rewrite ^/(.*)$ http://www.1.com/$1 permanent;
}
break 中止Rewirte,不在继续匹配;
redirect 为302临时重定向的HTTP状态;
permanent 为301永久重定向的HTTP状态。
作者:@ouyang
发布时间:2016年06月10日
阅读: 2,797
分类:学习笔记
在网站部署中,考虑网站的安全行问题,可以将您的网站主程序与WEB目录分离,使主程序在WEB目录之外,从而提高网站的安全性。
分离方法
1.将PHPCMS V9中程序主框架目录phpcms移动至web目录之外
如图:
2.修改web目录下程序入口文件index.php文件为
/**
* index.php PHPCMS 入口
*
* @copyright (C) 2005-2010 PHPCMS
* @license http://www.phpcms.cn/license/
* @lastmodify 2010-6-1
*/
//PHPCMS根目录
define('PHPCMS_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
include '../phpcms/base.php';
pc_base::creat_app();
3.修改web目录下接口文件文件api.php文件为
/**
* index.php API 入口
*
* @copyright (C) 2005-2010 PHPCMS
* @license http://www.phpcms.cn/license/
* @lastmodify 2010-7-26
*/
define('PHPCMS_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
include '../phpcms/base.php';
$param = pc_base::load_sys_class('param');
$op = isset($_GET['op']) && trim($_GET['op']) ? trim($_GET['op']) : exit('Operation can not be empty');
if (!preg_match('/([^a-z_]+)/i',$op) && file_exists(PHPCMS_PATH.'api/'.$op.'.php')) {
include PHPCMS_PATH.'api/'.$op.'.php';
} else {
exit('API handler does not exist');
}
这样即可以完成主程序与web目录分离
作者:@ouyang
发布时间:2016年06月05日
阅读: 3,041
分类:学习笔记
在modules/content/content.php 的public_categorys方法里1027行左右,把
if (!empty($categorys)) {
}
里面的代码改为以下的:
$tree->init($categorys);
switch ($from) {
case 'block':
$strs = "<span class='\$icon_type'>\$add_icon<a href='?m=block&c=block_admin&a=public_visualization&menuid=" . $_GET['menuid'] . "&catid=\$catid&type=list' target='right'>\$catname</a> \$vs_show</span>";
$strs2 = "<img src='" . IMG_PATH . "folder.gif'> <a href='?m=block&c=block_admin&a=public_visualization&menuid=" . $_GET['menuid'] . "&catid=\$catid&type=category' target='right'>\$catname</a>";
break;
default:
$strs = "<span class='\$icon_type'>\$add_icon<a href='?m=content&c=content&a=\$type&menuid=" . $_GET['menuid'] . "&catid=\$catid' target='right' onclick='open_list(this)'>\$catname</a></span>";
$strs2 = "<span class='folder'><a href='?m=content&c=content&a=\$type&menuid=" . $_GET['menuid'] . "&catid=\$catid' target='right' onclick='open_list(this)'>\$catname</a></span>";
break;
}
$categorys = $tree->get_treeview(0, 'category_tree', $strs, $strs2, $ajax_show);
作者:@ouyang
发布时间:2016年03月26日
阅读: 3,603
分类:学习笔记
关闭Hyper-V管理器时候,提示“关闭Hyper-V管理器前你必须关闭所有会话框”,感觉是微软的一个Bug
解决办法是:在Hyper-V管理器界面只要把输入法切换为英文,这时候关闭不会有提示了。这Bug真叫人汗颜。
作者:@ouyang
发布时间:2016年03月19日
阅读: 2,152
分类:学习笔记
PHPCMS V9由于采用了MVC的设计模式,所以它的后台访问地址是固定的,虽然可以通过修改路由配置文件来实现修改,但每次都修改路由配置文件对于我来说有点麻烦 了,而且一不小心就会出错。这里使用另外一个一劳永逸的方法,达到了方便修改访问后台入口的目的,整个修改共分两步:
第一步:
在网站根目录创建一个文件夹,以后就要通过这个文件夹进入后台登录界面的,所以文件夹名就要取一个不易被人轻易猜到的名称。这里作为演示,我就取为 houtai 好了。接着,在这个文件夹里新建一个文件index.php,内容为:
<?php
define('PHPCMS_PATH', realpath(dirname(__FILE__) . '/..') . '/');
include PHPCMS_PATH . '/phpcms/base.php';
// pc_base::creat_app();
$session_storage = 'session_' . pc_base :: load_config('system', 'session_storage');
pc_base :: load_sys_class($session_storage);
session_start();
$_SESSION['right_enter'] = 1;
unset($session_storage);
header('location:../index.php?m=admin');
?>
第二步:
在 phpcms/modules/admin/ 文件夹里新建一个文件 MY_index.php(切记MY为大写,index为小写),内容为:
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
class MY_index extends index {
public function __construct() {
if(empty($_SESSION['right_enter'])) {
header('location:./');exit;
}
parent::__construct();
}
public function public_logout() {
$_SESSION['right_enter'] = 0;
parent::public_logout();
}
}
?>
修改完成。以后就只能通过 http://域名/houtai/ 目录访问后台登录入口 了,如果直接使用 index.php?m=admin 访问的话,会直接跳转到网站首页,这样就阻止了对后台登录入口的直接访问了。当然houtai这个目录名可以随意修改的!
文章来自:周涛blog 原文地址:http://www.zhoutao.org/blog/2013/03/145.html
作者:@ouyang
发布时间:2016年02月20日
阅读: 2,633
分类:学习笔记
[root@server ~]#nginx -V //查看Nginx安装信息以及目录
nginx version: nginx/1.8.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=nginx --group=nginx --prefix=/usr --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --with-ipv6 --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-cc-opt=''-D FD_SETSIZE=32768''
下载nginx-http-concat模块以及nginx最新版本
[root@server ~]# git clone git://github.com/alibaba/nginx-http-concat.git //下载nginx-http-concat模块
[root@server ~]# mv nginx–http–concat/ /usr/local/src/nginx-http-concat //将模块移动到指定目录
[root@server ~]# wget http://nginx.org/download/nginx-1.9.11.tar.gz //下载最新nginx版本
[root@server ~]# tar zxvf nginx-1.9.11.tar.gz //解压
[root@server ~]# cd nginx-1.9.11 //进入nginx最新目录
这里需要修改一下nginx-http-concat的ngx_http_concat_module.c文件,因为nginx最新的js类别已经修改成application/javascript。所以需要将ngx_http_concat_module.c里的application/x-javascript修改成application/javascript。不然js无法合并,并会提示400错误。
[root@server nginx-1.9.11]# vi /usr/local/src/nginx-http-concat/ngx_http_concat_module.c
找到
ngx_string("application/x-javascript")
将其修改为
ngx_string("application/javascript")
:wq //保存
现在可以进行编译了,将nginx-http-concat一起与nginx编译。
[root@server nginx-1.9.11]# ./configure --user=nginx --group=nginx --prefix=/usr --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --with-ipv6 --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-cc-opt="-D FD_SETSIZE=32768" --add-module=/usr/local/src/nginx-http-concat
make
make以后进入objs
[root@server nginx-1.9.11]# cd ./objs
[root@server objs]# mv /usr/sbin/nginx /usr/sbin/nginx.old //移动1.8版本nginx为nginx.old
[root@server objs]# cp nginx /usr/sbin/nginx //将刚编译的1.9.11的nginx复制原地址。
这个时候基本就升级完成了。
[root@server objs]# nginx -V
nginx version: nginx/1.9.11
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr --user=nginx --group=nginx --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --with-ipv6 --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-cc-opt='-D FD_SETSIZE=32768' --add-module=/usr/local/src/nginx-http-concat
这时候看到nginx版本升级到指定版本,并且看到nginx-http-concat已经成功编译进去。
但还没有完成,我们还需要在nginx.conf里面进行配置。
举例:
server
{
listen 120.0.0.1:80;
server_name ouyang.wang www.ouyang.wang ;
access_log /var/log/nginx/domains/ouyang.wang.log;
access_log /var/log/nginx/domains/ouyang.wang.bytes bytes;
error_log /var/log/nginx/domains/ouyang.wang.error.log;
root /home/domains/ouyang.wang/public_html;
index index.htm index.html index.php;
include /usr/local/directadmin/data/users/news/nginx_php.conf;
location / {
concat on;
concat_max_files 20;
concat_unique off; //允许不同类型文件合并
}
include /etc/nginx/webapps.conf;
}
只需要将下列加入server里即可。
location / {
concat on;
concat_max_files 20;
concat_unique off;
}
参数说明:
# nginx_concat_module 开关
concat on;
# 最大合并文件数
# concat_max_files 10;
# 允许不同类型文件合并
# concat_unique off;
# 允许合并的文件类型,多个以逗号分隔。如:application/javascript, text/css
# concat_types application/javascript, text/css;
配置保存完成后,启动nginx即可。
systemctl reload nginx.service
作者:@ouyang
发布时间:2016年01月24日
阅读: 2,759
分类:学习笔记
使用函式 date() 实现
显示的格式: 年-月-日 小时:分钟:妙
相关时间参数:
a - "am" 或是 "pm"
A - "AM" 或是 "PM"
d - 几日,二位数字,若不足二位则前面补零; 如: "01" 至 "31"
D - 星期几,三个英文字母; 如: "Fri"
F - 月份,英文全名; 如: "January"
h - 12 小时制的小时; 如: "01" 至 "12"
H - 24 小时制的小时; 如: "00" 至 "23"
g - 12 小时制的小时,不足二位不补零; 如: "1" 至 12"
G - 24 小时制的小时,不足二位不补零; 如: "0" 至 "23"
i - 分钟; 如: "00" 至 "59"
j - 几日,二位数字,若不足二位不补零; 如: "1" 至 "31"
l - 星期几,英文全名; 如: "Friday"
m - 月份,二位数字,若不足二位则在前面补零; 如: "01" 至 "12"
n - 月份,二位数字,若不足二位则不补零; 如: "1" 至 "12"
M - 月份,三个英文字母; 如: "Jan"
s - 秒; 如: "00" 至 "59"
S - 字尾加英文序数,二个英文字母; 如: "th","nd"
t - 指定月份的天数; 如: "28" 至 "31"
U - 总秒数
w - 数字型的星期几,如: "0" (星期日) 至 "6" (星期六)
Y - 年,四位数字; 如: "1999"
y - 年,二位数字; 如: "99"
z - 一年中的第几天; 如: "0" 至 "365"
phpcms其中获取内容也时间方式为:{date('Y-m-d H:i:s', $rs['inputtime'])}
作者:@ouyang
发布时间:2016年01月12日
阅读: 2,624
分类:学习笔记
1、移动phpsso_server目录
将根目录下的phpsso_server移动到其他文件路径下。
2、给该目录绑定新的域名,一级域名或者二级域名均可。
3、修改 phpsso_server 下面的配置文件。
阅读剩余部分...
作者:@ouyang
发布时间:2016年01月02日
阅读: 2,410
分类:学习笔记
phpcms v9自带的相关文章、专题等模块不支持order排序,调用的相关文章、专题默认为升序,这样就造成了一个问题,调出来的相关文章是最早的文章,没有时效性。我们只能通过修改程序文件,只需简单修改一个文件,就能达到我们的需求。
修改相关文章排序的方法:
打开根目录下的phpcms/modules/content/classes/content_tag.class.php,找到
$r = $this->db->select($sql2, '*', $limit, '','','id');
修改为:
$r = $this->db->select($sql2, '*', $limit, $order,'','','id');
PC标签格式如下:
{pc:content action="relation" relation="$relation" id="$id" catid="$catid" num="5" order="inputtime DESC" keywords="$rs[keywords]"}
阅读剩余部分...
作者:@ouyang
发布时间:2015年06月30日
阅读: 2,942
分类:Linux摘要,学习笔记
第一:下载puttygen
第二:由于因为putty不支持pem所以,需要用puttygen进行转换,具体过程如下:
1.打开puttygen程序,然后点击load选择.pem文件(弹出默认选择是.ppk,下拉选择全部文件),也就是在pem文件。
2.选择.pem文件,点击打开,弹出一个窗口,直接确认即可。
3.保存私有密匙文件(Save private key),点击"是",选择存放路径即可保存。
第三:用刚保存的ppk文件进入服务器!
1.打开putty程序,在Host Name输入ip地址,在putty左侧,找到Connection —SSH — Auth 然后在本页找到Private key...,点击Browse…, 找到刚才使用puttygen保存的ppk文件!点击open,输入root就能连接到服务器了,密码都不用输了。
- «
- 1
- 2
- 3
- 4
- »