linkstation上开机显示debian的logo,感觉很有意思,查了一下可以用linux_logo这个软件来实现。
先在ubuntu下面安装linuxlogo:apt-get install linux_logo
刚刚安装后是不能显示的,还要做一些设置才行。
完成后运行下面指令:linux_logo > /etc/motd
然后复制/etc/motd中的文件替换掉/etc/motd.tail的内容,保存。
把终端机上的emlog转移到VPS上,顺利安装恢复备份,然后问题出现:文章中图片的链接地址是以前的域名,这个实在很抓狂,现在家里的终端机在运行,万一哪天终端机挂掉了那图片全都无法显示了。
去emlog的官网看了一下,有个域名更换插件,不过安装之后发现即使将备份目录的权限设置为777之后也还是无法替换现有域名,实在头痛啊,可是都已经转换了,只能将就着先把问题解决了再说吧。
无奈啊,插件不能用只好手工替换了,找了一下,发现之前的域名http://wificat.3322.org:88/
存在于博客数据库的emlog_blog表中,
写了个批量替换的指令,在phpmyadmin里面运行一下,搞定。
UPDATE emlog_blog SET
content = replace(content, ‘http://wificat.3322.org:88 ‘, ‘http://wifizoo.net ‘)
还有个字段是excerpt,也要替换,否则还有些日志的图片无法显示。
UPDATE emlog_blog SET
excerpt = replace(content, ‘http://wificat.3322.org:88 ‘, ‘http://wifizoo.net ‘)
# curl –head www.nginx.net
HTTP/1.1 302 Moved Temporarily
Server: nginx/0.8.38
Date: Fri, 04 Jun 2010 01:08:44 GMT
Content-Type: text/html
Content-Length: 161
Connection: keep-alive
Keep-Alive: timeout=15
Location: http://nginx.org/
这样一下子就给人家看到你的服务器nginx版本是0.8.38
可以不显示不?
当然可以
#vi nginx.conf
在http 加上 server_tokens off;
http {
……省略配置
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
tcp_nodelay on;
server_tokens off;
…….省略配置
}
编辑php-fpm配置文件 如fcgi.conf 、fastcgi.conf(要看你是什么配置文件名)
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
改为
fastcgi_param SERVER_SOFTWARE nginx;
nginx重新加载配置就完成了 404 501等页面都不会显示nginx版本
太棒了
#curl –head 127.0.0.1
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 13 Jan 2010 06:25:01 GMT
Content-Type: text/html
Content-Length: 793
Last-Modified: Sat, 12 Dec 2009 02:28:16 GMT
Connection: keep-alive
Accept-Ranges: bytes
再检查一下配置文件:
/usr/local/nginx/sbin/nginx -t
如果屏幕显示以下两行信息,说明配置文件正确:
the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
the configuration file /usr/local/webserver/nginx/conf/nginx.conf was tested successfully
平滑重启:
对于Nginx 0.8.x版本,现在平滑重启Nginx配置非常简单,执行以下命令即可:
/usr/local/nginx/sbin/nginx -s reload
刷新了一下nginx的配置文件,禁止在403,404等错误页面显示nginx的版本号,不过每次都要停止Nginx 再启动Nginx 感觉实在麻烦。
搜索一下资料,终于找到一个很简单的命令了,那就是 kill -HUP pid
不过首先要查看下进程的PID值 输入ps aux |grep nginx
得到下面的结果
root 2078 0.0 0.5 4520 756 ? Ss 21:07 0:00 nginx: master process /usr/local/nginx/sbin/nginx
2078这个值就是PID的值
然后输入 kill -HUP 8770 就可以了
当然就要确定新配置文件没有任何错误的 不然的话 他还是读取旧的配置文件
嗯 看了一下nginx的帮助,又发现一个更好的办法,可以reload配置文件,也等于动态加载了。
nginx version: nginx
Usage: nginx [-?hvVt] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
所以只要运行这个指令就可以啦!/usr/local/nginx/sbin/nginx -s reload
感觉访问论坛及博客响应有点迟缓,网上都说nginx相当强悍,打算把服务器的web前端由目前的lighttpd换成nginx。
打算全新安装lnmp,备份了论坛和博客数据后直接完全卸载了服务器上的lighttpd+php+mysql,以绝后患。
apt-get purge lighttpd php5-cgi php5-mysql mysql-server php5-gd
然后找了个lnmp的一键安装包,省了不少精力。这里要赞一下 http://www.lnmp.org/
,一个开源的项目,貌似是国内最早玩VPS的哥们做的,大家有钱的就捧个钱场吧,哈哈哈
安装过程需要编译比较耗时间, Intel(R) Xeon(R) CPU X3220 @ 2.40GHz Processor RAM 128MB SWAP256MB 大概用了90分钟,安装完毕发现mysql无法运行。抓狂啊,卸载了之前的版本,再重新安装问题依旧,nginx和php都OK,就是无法连接mysql数据库,彻底晕了,无奈提交ticket申请rebuild VPS。
米国公司的效率还是很高的,20分钟就帮我搞定了,这下系统环境纯净了,直接运行lnmp安装包,一个半小时,搞定收工。
搞定了lnmp,接下来重新把论坛和博客的备份数据上传,安装恢复数据库,彻底整顿完毕,差不多快六点钟了,这个下午全浪费在这上面了。
访问下论坛,感觉速度好像快了一些,不知道是不是心里因素作怪,哈哈
Apache上面配置多个虚拟主机比较方便,换了VPS,资源比较紧张,自然不能再继续用apache了。lighttpd倒是个不错的选择,可是研究一下发现大型网站没人用lighttpd,倒是nginx成为不少人的首选,罢了,就用nginx吧!
这里以配置2个站点(2个域名)为例,n 个站点可以相应增加调整,假设:
IP地址: 202.55.1.100
域名1 example1.com 放在 /www/example1
域名2 example2.com 放在 /www/example2
配置 nginx virtual hosting 的基本思路和步骤如下:
把2个站点 example1.com, example2.com 放到 nginx 可以访问的目录 /www/
给每个站点分别创建一个 nginx 配置文件 example1.com.conf,example2.com.conf, 并把配置文件放到 /etc/nginx/vhosts/
然后在 /etc/nginx.conf 里面加一句 include 把步骤2创建的配置文件全部包含进来(用 * 号)
重启 nginx
下面是具体的配置过程:
1、在 /etc/nginx 下创建 vhosts 目录
mkdir /etc/nginx/vhosts
2、在 /etc/nginx/vhosts/ 里创建一个名字为 example1.com.conf 的文件,把以下内容拷进去
server {
listen 80;
server_name example1.com www. example1.com;
access_log /www/access_ example1.log main;
location / {
root /www/example1.com;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/example1.com/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
3、在 /etc/nginx/vhosts/ 里创建一个名字为 example2.com.conf 的文件,把以下内容拷进去
server {
listen 80;
server_name example2.com www. example2.com;
access_log /www/access_ example1.log main;
location / {
root /www/example2.com;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/example2.com/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
4、打开 /etc/nginix.conf 文件,在相应位置加入 include 把以上2个文件包含进来
user nginx;
worker_processes 1;
# main server error log
error_log /var/log/nginx/error.log ;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
# main server config
http {
include mime.types;
default_type application/octet-stream;
log_format main ‘$remote_addr – $remote_user [$time_local] $request ‘
‘”$status” $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name _;
access_log /var/log/nginx/access.log main;
server_name_in_redirect off;
location / {
root /usr/share/nginx/html;
index index.html;
}
}
# 包含所有的虚拟主机的配置文件
include /usr/local/etc/nginx/vhosts/*;
}
5、重启 Nginx
/etc/init.d/nginx restart
往VPS上传大文件,用ftp上传的话需要一直开着电脑,很不方便。
想了个办法,把要传的文件丢在终端机的web文件夹下,直接从VPS上下载就可以了,关了电脑还可以照样做这件事情,很好很强大。
试了下在VPS上用wget下载终端机上的文件,速度很不稳定,700MB的文件要传几乎3个小时,而且剩余时间似乎随着网速不稳定还有继续增加的趋势。真郁闷啊
放狗狂搜,发现mytget貌似很强悍,可以命令行下多线程下载,就是它了。