web.server
apache中对域名全局禁用etag之类的东西
etag不比last-modified强。且etag容易引入问题,如果你后台有多个服务器。我只有一台服务器,但也不想用etag。因为last-modified足够了。多一个etag,等于白白消耗web server处理能力。于是我决定在apache中全局禁用etag。
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
# ExpiresDefault A360000000000
# Do not cache dynamically generated pages.
ExpiresByType text/html A1
# 在这里我让本virtualhost中默认就不使用etag
Header unset Pragma
FileETag None
Header unset ETag
# 这里是我开始只针对某些文件unset掉etag
# 现在可以不用了
缩小图像大小
for f in *.jpg; do convert -quality 40% $f small/$f;done
检查和修复mysql中的表
mysqlcheck --auto-repair -upy -p pengyou
drupal网站动态内容和静态内容分离
我现在直接使用nginx就可以做到
nginx的conf中写好了,静态文件包括boost cache直接给nginx处理。php相关的给后台的php-cgi。
lightttpd的例子,使用两个域名!
下面是挺早的一个例子了。有参考价值。现在大部分情况不需要这么搞了吧。
http://www.lullabot.com/articles/using-lighttpd-static-file-...
Simpler approach
I use a much simpler approach.
(1) Set up a fast http server on a different port or different server (I wrote my own).
(2) Redirect requests to static files (like files in the /files folder or images) via mod_rewrite to this server.
But anyway, think it's a very useful idea to have different servers here!
在bash中查看phpInfo的信息
echo "<?php phpinfo(); ?>" | php > phpinfo.txt
这个命令把phpinfo出来的信息存放到phpinfo.txt中了。这个命令还可以使用grep。比如寻找所有含有soap的行
echo "" | php |grep soap
非常好用。
快速查看各种上传大小限制:
echo "" | php |grep soap
post_max_size => 8M => 8M
realpath_cache_size => 16K => 16K
upload_max_filesize => 2M => 2M
修改 ulimint 中的最大打开文件数方法:适用debian/ubuntu 系列的 gnu/linux
参考:
$sudo gedit /etc/security/limits.conf #open the file in gedit
user soft nofile 9000
user hard nofile 65000
$ sudo gedit /etc/pam.d/common-session #open the file in gedit
Then add the line:
session required pam_limits.so
Now after rebooting you can see in the terminal with ulimit -a the change.
http://posidev.com/blog/2009/06/04/set-ulimit-parameters-on-...
如果用vim编辑服务器上的apache配置文件没有高亮显示语法,用 set: filetype=apache 来解决
我是这样找到方法的
先 :file 安tab补齐找到有filetype这个命令
然后尝试 :set filetype 来在一个高亮的配置文件中查看它的filetype设置为什么
mysql的超时让我们的模块无法正常工作
有一个程序,是导入pdf并转换成swf,运行在drupal上。production上导导就断了。testing上一开始导好几个小时都没事。
我们从模块检查,php超时检查,php错误检查,apache超时检查,怎么都不行。最后我偶然想到是Mysql超时的问题。
正解!:)
production
mysql> show global variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 60 |
因为程序牵扯到往mysql中写数据,而60秒就超时太短了。因为程序会先告诉drupal我要导入一本书,写入书的题目,此时mysql链接就打开了。然后程序会去转换pdf,转换完了,再把生成文件的地址写入node的字段。如果转换超过60秒,就超时了。就停了。就是这个原因。
testing
Variable_name | Value |
+---------------+-------+
| wait_timeout | 28800 |
+---------------+-------+
没有启动mod_expires的话,apache配置文件中也无法使用expire相关指令
sudo a2enmod expires
Enabling module expires.
Run '/etc/init.d/apache2 restart' to activate new configuration!
害的我浪费半天时间检查自己的cache设置为什么没有作用
参考: http://www.electrictoolbox.com/apache-mod-expires-browser-ca...