在nginx配置文件增加以下代码
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
location / { # 如果请求的文件已存在,直接返回 if (-f $request_filename) { break; } set $supercache_file ''; set $supercache_uri $request_uri; set $supercache 1; set $ihttp_host ''; if ($request_method = POST) { set $supercache 0; } # 仅在访问文章永久链接时使用静态文件,请求中带参数则不使用静态缓存 set $qs 0; if ($query_string) { set $qs 1; } # 不过从 twitter, facebook, feedburner 链接点过来的,总是带参数,这些访问仍然可以使用静态文件 if ($query_string ~* "^utm_source=([^&]+)&utm_medium([^&]+)&utm_campaign=([^&]+)(&utm_content=([^&]+))?$") { set $qs 0; set $supercache_uri $document_uri; } #deactivate on high load if ($qs = 1) { set $supercache 0; } # 针对已登录用户(发表过评论),可以不静态化。在访问量高峰时可注释掉 if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $supercache 0; } # 支持移动设备,访问移动版本的网页缓存 if ($http_user_agent ~* '(iphone|ipod|aspen|incognito|webmate|android|dream|cupcake|froyo|blackberry9500|blackberry9520|blackberry9530|blackberry9550|blackberry 9800|webos|s8000|bada)') { set $ihttp_host '-mobile'; } # 指定静态缓存文件的路径 if ($supercache = 0) { set $supercache_uri ''; } if ($supercache_uri ~ ^(.+)$) { set $supercache_file /wp-content/cache/supercache/$http_host$1/index${ihttp_host}.html; } # 只有当缓存文件存在时,才进行 rewrite if (-f $document_root$supercache_file) { #rewrite ^(.*)$ $supercache_file break; rewrite ^ $supercache_file last; } # 所有其他请求,转给 wordpress 处理 if (!-e $request_filename) { rewrite . /index.php last; } |
针对已登录用户(发表过评论),可以不静态化。在访问量高峰时可注释掉
|
1 2 3 4 5 |
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $supercache 0; } } |
from:http://blog.csdn.net/wangdada111/article/details/71189332
View Details为了在前端正确地显示字体,浏览器必须使用正确的http header来接受字体文件。如果服务器没有设置要求的头信息,那么有些浏览器就会在控制台报错或者直接不能显示。 可能你的服务器已经配置好了,你无须再动任何东西。如果没有配置好,那么你需要注意下面几点: 首先,修改mime-type headers; 其次设置CORS headers-仅当你从不同域下获取字体文件或者html页面的时候。(*注意:如果你没有设置CORS headers信息,你可以直接把字体文件(路径)嵌入到CSS样式中。如果你去fontello网站下载到本地的话fontello.css中就已经这样做好了) 下面介绍两大主流服务器的字体支持配置: Apache 设置正确的mime-type来支持字体文件,将下面的设置加入到服务器配置文件中:
|
1 2 3 4 |
AddType <span class="hljs-type">application</span>/font-sfnt otf ttf AddType <span class="hljs-type">application</span>/font-woff woff AddType <span class="hljs-type">application</span>/font-woff2 woff2 AddType <span class="hljs-type">application</span>/vnd.ms-fontobject eot |
如果你不能修改配置文件,那么就在你的项目下新建一个*.htaccess文件,添加下面的设置: 设置CORS headers 信息:
|
1 2 3 |
<span class="hljs-subst"><</span>FilesMatch <span class="hljs-string">".(eot|ttf|otf|woff|woff2)"</span><span class="hljs-subst">></span> <span class="hljs-keyword">Header</span> <span class="hljs-built_in">set</span> Access<span class="hljs-attribute">-Control</span><span class="hljs-attribute">-Allow</span><span class="hljs-attribute">-Origin</span> <span class="hljs-string">"*"</span> <span class="hljs-subst"><</span>/FilesMatch<span class="hljs-subst">></span> |
Nginx Nginx服务器默认是没有支持字体的mime-type设置的,并且对.eot文件的mime-type也是不正确的。在配置文件夹下找到mime-type设置的地方。通常,在mimes.types文件下。 搜索.eot,并在下它的设置下添加下面几行:
|
1 2 3 4 |
<span class="hljs-type">application</span>/font-sfnt otf ttf; <span class="hljs-type">application</span>/font-woff woff; <span class="hljs-type">application</span>/font-woff2 woff2; <span class="hljs-type">application</span>/vnd.ms-fontobject eot; |
对于CORS headers 信息设置,添加下面的几行到你的vhost配置中:
|
1 2 3 4 |
location ~<span class="hljs-subst">*</span> <span class="hljs-subst">\</span><span class="hljs-built_in">.</span>(eot<span class="hljs-subst">|</span>otf<span class="hljs-subst">|</span>ttf<span class="hljs-subst">|</span>woff<span class="hljs-subst">|</span>woff2)$ { add_header Access<span class="hljs-attribute">-Control</span><span class="hljs-attribute">-Allow</span><span class="hljs-attribute">-Origin</span> <span class="hljs-subst">*</span>; } |
from:http://blog.csdn.net/yypsober/article/details/52012577
View Details想把PHP卸载干净,直接用yum的remove命令是不行的,需要查看有多少rpm包,然后按照依赖顺序逐一卸载。 1.首先查看机器上安装的所有php相关的rpm包 [root@localhost nginx]# rpm -qa | grep php php-cli-5.3.3-22.el6.x86_64 php-pdo-5.3.3-22.el6.x86_64 php-gd-5.3.3-22.el6.x86_64 php-fpm-5.3.3-22.el6.x86_64 php-common-5.3.3-22.el6.x86_64 php-5.3.3-22.el6.x86_64 php-xml-5.3.3-22.el6.x86_64 php-pear-1.9.4-4.el6.noarch 2.按依赖顺序进行删除 rpm -e php-fpm-5.3.3-22.el6.x86_64 rpm-e php-pdo-5.3.3-22.el6.x86_64 rpm -e php-pear-1.9.4-4.el6.noarch rpm-e php-cli-5.3.3-22.el6.x86_64 rpm -e php-5.3.3-22.el6.x86_64 rpm-e php-xml-5.3.3-22.el6.x86_64 rpm -e php-gd-5.3.3-22.el6.x86_64 rpm-e php-common-5.3.3-22.el6.x86_64 from:http://blog.csdn.net/dc_726/article/details/9519293
View Details简介 PHP(超文本预处理器)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域。PHP 独特的语法混合了C、Java、Perl以及PHP自创的语法。 用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;PHP还可以执行编译后代码,编译可以达到加密和优化代码运行,使代码运行更快。 安装 1.检查当前是否有安装php
|
1 |
rpm -qa|grep php |
如果有安装PHP,那么请先删除这些安装包:
|
1 |
yum remove php* |
2.安装php源 Centos 5 安装php源:
|
1 |
rpm -ivh http://mirror.webtatic.com/yum/el5/latest.rpm |
CentOs 6 安装php源:
|
1 |
rpm -ivh http://mirror.webtatic.com/yum/el6/latest.rpm |
CentOs 7 安装php源和epel扩展源:
|
1 |
rpm -ivh https://mirror.webtatic.com/yum/el7/epel-release.rpmrpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm |
3.现在开始安装php 安装php5.5的基本安装包:
|
1 |
yum install php55w php55w-gd php55w-mbstring php55w-mysql php55w-fpm |
安装php5.6的基本安装包:
|
1 |
yum install php56w php55w-gd php56w-mbstring php56w-mysql php56w-fpm |
安装php7.0的基本安装包:
|
1 |
yum install php70w php70w-gd php70w-mbstring php70w-mysql php70w-fpm |
安装完成php之后需要重启apache:
|
1 |
service restart |
4. 测试网页 我安装的php7.0,就拿php7.0写个网页测试一下
|
1 |
/var/www/html/index.php<?php phpinfo(); ?> |
from:http://www.jb51.net/article/83466.htm
View Details安装nginx yum install nginx 设置nginx开启起动 systemctl start nginx 测试 访问http://你的域名或IP/ 查看nginx安装位置 whereis nginx nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx /usr/share/man/man3/nginx.3pm.gz /usr/share/man/man8/nginx.8.gz 安装php yum install php php-mysql php-fpm 安装过程中经常会见到如下问题: 2:postfix-2.10.1-6.el7.x86_64 有缺少的需求 libmysqlclient.so.18()(64bit) 2:postfix-2.10.1-6.el7.x86_64 有缺少的需求 libmysqlclient.so.18(libmysqlclient_18)(64bit) 解决方法: 把php-mysql换成php-mysqlnd 即执行 yum install php php-mysqlnd php-fpm 配置php处理器 vim /etc/php.ini 查找cgi.fix_pathinfo 将 ;cgi.fix_pathinfo=1改为cgi.fix_pathinfo=0 配置www.conf vim /etc/php-fpm.d/www.conf 将 user = nobody group = nobody 改为 user = nginx group = nginx 前提是已经创建了nginx用户和nginx组。 起动php-fpm systemctl start php-fpm 设置php-fpm开机启动 systemctl enable php-fpm 配置nginx 打开/etc/nginx/conf.d/default.conf,如果不存在则创建 粘贴 server { listen 80; server_name server_domain_name_or_IP; note that these lines are originally from […]
View Details在centos7通过yum安装PHP7,首先在终端运行: rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 提示错误: error: Failed dependencies: epel-release >= 7 is needed by webtatic-release-7-3.noarch 需要先安装epel-release。 1.安装epel-release 通过命令: yum -y install epel-release 成功安装。 2.安装PHP7 终端再次运行如下命令: rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 成功获取PHP7的yum源,然后再执行: yum install php70w 这样就大功告成了。 3.验证安装 终端命令:PHP -v,显示当前PHP版本,信息如下: [root@moliangjun /]# php -v PHP 7.0.18 (cli) (built: Apr 15 2017 07:09:11) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies 这样就在CentOS 7下通过yum安装成功PHP7. from:http://www.thinkphp.cn/topic/48196.html
View Details1:查看环境: 1 2 [root@10-4-14-168 html]# cat /etc/redhat-release CentOS release 6.5 (Final) 2:关掉防火墙 1 [root@10-4-14-168 html]# chkconfig iptables off 3:配置CentOS 6.0 第三方yum源(CentOS默认的标准源里没有nginx软件包) 1 #wget http://www.atomicorp.com/installers/atomic 1 #sh ./atomic 1 #yum check-update 4:安装开发包和库文件 1 2 3 4 #yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel 5:卸载已安装的apache、mysql、php 1 2 3 # yum remove httpd # yum remove mysql # yum remove php 6:安装nginx 1 […]
View Details摘要 我相信很多人对这个再熟悉不过了。对已经修改的集合进行操作就会出现这个错。 解决办法 比如有下面的一段代码,我们创建一个集合,并向集合中添加10个数,然后,我们循环再将这些数移除了。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
static void Main(string[] args) { List<int> lst = new List<int>(); for (int i = 0; i < 10; i++) { lst.Add(i); } foreach (var item in lst) { lst.Remove(item); } Console.Read(); } |
出现了….. 是不是被泛型集合提供的方法坑了?我记得很久之前我也被坑过。很疑惑吧,其实也很简单,因为你如果移除了一项,集合的元素个数是变化的。这个时候元素会重排,第二个元素的索引由1变为0,后面的依次往前移动。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
static void Main(string[] args) { List<int> lst = new List<int>(); for (int i = 0; i < 10; i++) { lst.Add(i); } var result = lst; Console.WriteLine("lst的count" + lst.Count); lst.Remove(0); Console.WriteLine("lst的count" + lst.Count); for (int i = 0; i < lst.Count; i++) { Console.WriteLine("索引:{0},值:{1}", i, lst[i]); } Console.Read(); } |
上面的代码为集合添加10个元素。然后输出当前集合的count,接着将索引为0的元素移除。这个时候集合中应该没有元素0了。然后输出集合的元素个数。输出此时的集合中索引和对应的值。如图所示 可以看到,本来索引为1的1,往前移动了,此时他的索引变为了0.所以在使用foreach移除的时候,集合是变化的,是不允许的。难道就没办法操作了吗?当然有,它不是移除一个集合就少一个吗》 此时,我们可以通过for循环,从集合的队尾移除,这个时候移除队尾的元素,虽然集合的count变了,但他们的索引没有变化。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
static void Main(string[] args) { List<int> lst = new List<int>(); for (int i = 0; i < 10; i++) { lst.Add(i); } var result = lst; Console.WriteLine("lst的count" + lst.Count); lst.Remove(0); Console.WriteLine("lst的count" + lst.Count); for (int i = lst.Count - 1; i >= 0; i--) { Console.WriteLine("索引:{0},值:{1}", i, lst[i]); Console.WriteLine("移除了元素:{0}", lst[i]); lst.RemoveAt(i); } Console.Read(); } |
那么我们只移除满足条件的是否也可以通过for循环呢?当然可以,foreach你不是不让吗?又不是只有你一个可以循环。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
static void Main(string[] args) { List<int> lst = new List<int>(); for (int i = 0; i < 10; i++) { lst.Add(i); } var result = lst; Console.WriteLine("lst的count" + lst.Count); lst.Remove(0); Console.WriteLine("lst的count" + lst.Count); for (int i = 0; i < lst.Count; i++) { Console.WriteLine("索引:{0},值:{1}", i, lst[i]); if (lst[i] % 2 == 0) { Console.WriteLine("移除了元素:{0}", lst[i]); lst.RemoveAt(i); } } Console.Read(); } |
总结 前不久刚有人遇到,这里还是记录一下吧。 from:https://www.cnblogs.com/wolf-sun/p/5721457.html
View Details先修改注册表: win键+r ,输入regedit; 定位到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0 修改attributes的值为2 然后再修改【无人参与系统睡眠超时】: 右下角点击图标 【所有设置】 【电源和睡眠】 【相关设置】下的【其他电源设置】 【更改计算机睡眠时间】 【更改高级电源设置】 展开【睡眠】 【无人参与系统睡眠超时】里把【使用电池】和【接通电源】改为你想要的分钟数 最后【确定】 以上内容整理自:https://www.zhihu.com/question/39263412 博主亲测有用,也是补困扰了好久。
View Details