@ouyang 发布的文章

CentOS7默认使用firewalld替代了iptables,所以熟悉熟悉firewalld的一些基础用法。

firewall-cmd --zone=public --add-port=80/tcp --permanent  #打开80端口, --permanent为永久有效
firewall-cmd --permanent --remove-port=8080/tcp #删除端口
firewall-cmd --query-port=8080/tcp # 查询端口是否开放
firewall-cmd --reload  #重新装载配置生效 
firewall-cmd --list-all  #查看防火墙添加的端口
firewall-cmd --list-services #查看当前的服务
firewall-cmd --state #查看firewall的状态

systemctl start firewalld.service #打开防火墙
systemctl stop firewalld.service #关闭防火墙
systemctl disable firewalld.service #禁止开机启动
systemctl enable firewalld.service #开启开机启动
systemctl restart firewalld.service #重启防火墙

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

[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

使用函式 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'])}