— 刘丰 2023/10/09 16:59 今天完成了对这一篇的迁移,费了相当大的功夫。希望能找到一个在线的,单页的 MoinMoin 到 Doku Wiki 转换的工具,不用考虑太多的依赖的,可惜依旧没有找到。
这一篇的内容是很早之前的了,有些过时,所以只能供参考。有时间我考虑写一个适用于目前的记录。前几天把 VPS 从 Linode 迁移到了腾讯云,相当于重新复习了一遍服务器的配置,正好可以把这个过程总结了一下。
# update-alternatives --config editor
# dpkg-reconfigure tzdata
http://www.mxtoolbox.com/SuperTool.aspx 综合检测(DNS、端口等)
# /etc/exim4/update-exim4.conf.conf dc_eximconfig_configtype='internet' dc_other_hostnames='liuf.net' dc_local_interfaces='' dc_readhost='' dc_relay_domains='' dc_minimaldns='false' dc_relay_nets='' dc_smarthost='' CFILEMODE='644' dc_use_split_config='false' dc_hide_mailname='' dc_mailname_in_oh='true' dc_localdelivery='maildir_home'
64 位的主机上 Exim4 会有发不出邮件的状况,主要是 /var/spool/exim4
等一些目录的权限问题,设置成 Debian-Exim
后就好了。
/etc/dovecot/dovecot.conf
文件,修改 protocols = none
为 protocols = imap imaps
。配置文件如下:
# ~/.getmail/getmailrc [retriever] type = SimpleIMAPSSLRetriever server = imap.gmail.com port = 993 username = <full email address> password = <password> mailboxes = ("[Gmail]/All Mail",) [destination] type = Maildir path = ~/Maildir/ [options] verbose = 1 message_log = ~/.getmail/getmail.log
# ~/.muttrc set mbox_type=Maildir set spoolfile="~/Maildir/" set folder="~/Maildir" set mask="!^\\.[^.]" set record="+.Sent" set postponed="+.Drafts" set charset="utf-8" set send_charset="utf-8" set include set indent_str="> " set fast_reply set edit_headers=no set pager_index_lines=4
YardVPS Xen 512M $7.95/month 购买时选得系统是 Ubuntu 10.10 32-bit
# apt-get install update-manager-core # do-release-upgrade # reboot
运行了两次,第一次升级到 11.04,第二次升级到 11.10。
用 ssh 登陆升级时会有不安全的提示,没问题。
修改 /etc/vsftpd.conf
,去掉下面几行的注释:
write_enable=YES idle_session_timeout=600 data_connection_timeout=120 ls_recurse_enable=YES
安装后 mysqld 进程占用内存 152M(VIRT) 18M(RES)
备份 /etc/mysql/my.cnf
后修改:
[client]
部分添加 default-character-set = utf8
[mysqld]
部分修改key_buffer = 16K max_allowed_packet = 1M thread_stack = 128K query_cache_size = 8M
并添加:
character-set-server = utf8 init_connect='SET NAMES utf8'
[isamchk]
部分改为:key_buffer = 8M sort_buffer_size = 8M
修改之后 mysqld 进程占内存 31872(VIRT) 6404(RES)
安装后修改 /etc/apache2/apache2.conf
文件:
<IfModule mpm_prefork_module> StartServers 1 MinSpareServers 2 MaxSpareServers 3 MaxClients 5 MaxRequestsPerChild 100 </IfModule>
单独网站的配置文件放在 /etc/apache2/sites-available/
下面,然后用 a2ensite 来把配置文件链接到 sites-enabled 目录下。a2enmod 命令可以启用 mod。
目前有三种组合方式:
据说 php-fpm 分配内存稳定,是 PHP 官方推荐的,可以平滑更新设置。目前尚待调查。
修改 php.ini 文件的设置:
memory_limit = 32M upload_max_filesize = 5M max_file_uploads = 50 session.gc_probability = 1
这是我目前(2012年1月11日 (三) 20:47 (CST))使用的设置,记录如下:
apache2-mpm-worker
包,安装的时候系统会提示删除 apache2-mpm-prefork
包)/etc/apache2/httpd.conf
中添加:AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
/etc/apache2/mods-available/fcgid.conf
中按照如下修改:<IfModule mod_fcgid.c> AddHandler fcgid-script .fcgi .php FcgidConnectTimeout 20 FcgidIPCDir /var/lib/apache2/fcgid/sock FcgidWrapper /usr/bin/php5-cgi .php </IfModule>
/etc/apache2/conf.d/phpmyadmin.conf
中把 Options FollowSymLinks
换成 Options FollowSymLinks +ExecCGI
今天(2012-04-15T14:12:59-0500)我买了 Linode 512 VPS,当中遇到过一些问题,记录在此:
给系统添加防火墙。
/etc/iptables.firewall.rules
文件,内容如下:*filter # Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0 -A INPUT -i lo -j ACCEPT -A INPUT -i lo -d 127.0.0.0/8 -j REJECT # Accept all established inbound connections -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Allow all outbound traffic - you can modify this to only allow certain traffic -A OUTPUT -j ACCEPT # Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL). -A INPUT -p tcp --dport 80 -j ACCEPT -A INPUT -p tcp --dport 443 -j ACCEPT # Allow SSH connections # # The -dport number should be the same port number you set in sshd_config # -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT # Allow ping -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT # Log iptables denied calls -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7 # Reject all other inbound - default deny unless explicitly allowed policy -A INPUT -j REJECT -A FORWARD -j REJECT COMMIT
sudo iptables-restore < /etc/iptables.firewall.rules
sudo iptables -L
lftp -u liufeng,placeholder sftp://50.116.5.28
-A INPUT -p tcp -m state --state NEW --dport 20 -j ACCEPT -A INPUT -p tcp -m state --state NEW --dport 21 -j ACCEPT
这样就可以像过去一样用了,但不知道有没有副作用
安装了 MySQL 后运行一下 sudo mysql_secure_installation
,自动清除一些不安全的设置。
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
印象里过去有在 wiki 里写过这个,但这次用找不到了,再写一遍。
mysqldump database > database.sql
mysql -u username -p dbname < dump.sql
mysql -uroot -p
use mysql;
update user set password=PASSWORD(“NEWPASSWORD”) where User='liufeng';
flush privileges;
SHOW TABLE STATUS;
的输出结果中有相关的字段
我的测试报告在这里,没有测伦敦的,其它五个城市我用 just-ping.com 测试了国内的访问速度、加拿大的访问速度,并记录了我运行 traceroute 的结果:
fremont1.linode.com Location Result min. rrt avg. rrt max. rrt IP Toronto, Canada: Okay 64.7 67.2 72.8 64.71.152.17 Vancouver, Canada: Okay 24.9 24.9 25.0 64.71.152.17 Hong Kong, China: Okay 191.7 194.8 196.5 64.71.152.17 Shanghai, China: Okay 271.6 274.5 278.0 64.71.152.17 Beijing, China: Okay 223.3 224.0 225.2 64.71.152.17 Nagano, Japan: Okay 119.2 119.2 119.3 64.71.152.17 ➜ ~ traceroute fremont1.linode.com traceroute to fremont1.linode.com (64.71.152.17), 64 hops max, 52 byte packets 1 192.168.100.254 (192.168.100.254) 0.569 ms 0.235 ms 0.203 ms 2 wnpgmb0911w-ad03-lo2.mts.net (142.161.5.200) 7.425 ms 6.851 ms 6.828 ms 3 wnpgmb0173w-dr09-v959.mts.net (142.161.5.98) 7.582 ms 7.074 ms 7.658 ms 4 10gigabitethernet4-1.core1.chi1.he.net (206.223.119.37) 25.129 ms 24.432 ms 24.123 ms 5 10gigabitethernet3-2.core1.den1.he.net (184.105.213.86) 48.464 ms 47.923 ms 48.118 ms 6 10gigabitethernet11-4.core1.sjc2.he.net (184.105.213.105) 75.116 ms 75.613 ms 74.595 ms 7 10gigabitethernet1-1.core1.fmt1.he.net (72.52.92.109) 76.061 ms 76.644 ms 75.838 ms 8 linode-llc.10gigabitethernet2-3.core1.fmt1.he.net (64.62.250.6) 75.119 ms 78.222 ms 76.243 ms 9 fremont1.linode.com (64.71.152.17) 75.233 ms 75.279 ms 74.783 ms =========================================================================== tokyo1.linode.com Location Result min. rrt avg. rrt max. rrt IP Toronto, Canada: Okay 174.6 179.0 182.8 106.187.33.12 Vancouver, Canada: Okay 131.4 131.6 132.3 106.187.33.12 Hong Kong, China: Okay 53.2 54.4 55.9 106.187.33.12 Shanghai, China: Okay 509.9 516.6 520.6 106.187.33.12 Beijing, China: Okay 159.2 171.4 179.3 106.187.33.12 Nagano, Japan: Okay 6.6 6.7 6.9 106.187.33.12 ➜ ~ traceroute tokyo1.linode.com traceroute to tokyo1.linode.com (106.187.33.12), 64 hops max, 52 byte packets 1 192.168.100.254 (192.168.100.254) 0.705 ms 0.241 ms 0.196 ms 2 wnpgmb0911w-ad03-lo2.mts.net (142.161.5.200) 7.402 ms 7.171 ms 6.674 ms 3 wnpgmb0173w-dr09-v959.mts.net (142.161.5.98) 7.452 ms 7.393 ms 7.596 ms 4 198.32.176.65 (198.32.176.65) 64.879 ms 57.448 ms 67.239 ms 5 pajbb002.kddnet.ad.jp (124.211.34.129) 57.098 ms pajbb001.kddnet.ad.jp (111.87.3.1) 57.676 ms pajbb001.kddnet.ad.jp (124.211.34.121) 57.369 ms 6 otejbb203.kddnet.ad.jp (203.181.100.209) 155.714 ms otejbb204.kddnet.ad.jp (203.181.100.205) 160.733 ms otejbb203.kddnet.ad.jp (203.181.100.5) 162.758 ms 7 cm-fcu203.kddnet.ad.jp (124.215.194.164) 166.982 ms cm-fcu203.kddnet.ad.jp (124.215.194.180) 162.467 ms 177.924 ms 8 124.215.199.122 (124.215.199.122) 164.384 ms 167.695 ms 158.575 ms 9 tokyo1.linode.com (106.187.33.12) 161.979 ms 162.831 ms 165.290 ms =========================================================================== newark1.linode.com Location Result min. rrt avg. rrt max. rrt IP Toronto, Canada: Okay 18.0 18.2 18.5 207.192.68.6 Vancouver, Canada: Okay 98.2 98.4 98.5 207.192.68.6 Hong Kong, China: Okay 224.3 227.5 229.6 207.192.68.6 Shanghai, China: Okay 522.4 529.2 534.3 207.192.68.6 Beijing, China: Packets lost (20%) 454.8 557.3 621.0 207.192.68.6 Nagano, Japan: Okay 195.2 195.9 196.5 207.192.68.6 ➜ ~ traceroute newark1.linode.com traceroute to newark1.linode.com (207.192.68.6), 64 hops max, 52 byte packets 1 192.168.100.254 (192.168.100.254) 0.691 ms 0.227 ms 0.193 ms 2 wnpgmb0911w-ad03-lo2.mts.net (142.161.5.200) 6.629 ms 6.841 ms 6.495 ms 3 wnpgmb0129w-dr05-v957.mts.net (142.161.5.65) 7.942 ms 7.257 ms 7.489 ms 4 eqix.e-2-3.tbr2.ewr.nac.net (198.32.118.157) 50.348 ms 45.375 ms 47.952 ms 5 0.e1-2.tbr2.mmu.nac.net (209.123.10.114) 45.205 ms 45.365 ms 44.700 ms 6 vlan804.esd2.mmu.nac.net (209.123.10.14) 47.232 ms vlan805.esd1.mmu.nac.net (209.123.10.34) 45.343 ms 45.450 ms 7 207.99.53.46 (207.99.53.46) 45.347 ms 207.99.53.42 (207.99.53.42) 45.189 ms 45.140 ms 8 newark1.linode.com (207.192.68.6) 45.461 ms 45.814 ms 46.035 ms =========================================================================== atlanta1.linode.com Location Result min. rrt avg. rrt max. rrt IP Toronto, Canada: Okay 29.0 29.3 29.5 63.247.71.196 Vancouver, Canada: Okay 95.2 95.4 95.7 63.247.71.196 Hong Kong, China: Okay 233.0 236.5 239.7 63.247.71.196 Shanghai, China: Packets lost (10%) 542.2 545.4 547.2 63.247.71.196 Beijing, China: Packets lost (20%) 336.2 344.9 392.7 63.247.71.196 Nagano, Japan: Okay 165.1 165.2 165.5 63.247.71.196 ➜ ~ traceroute atlanta1.linode.com traceroute to atlanta1.linode.com (63.247.71.196), 64 hops max, 52 byte packets 1 192.168.100.254 (192.168.100.254) 0.675 ms 0.199 ms 0.175 ms 2 wnpgmb0911w-ad03-lo2.mts.net (142.161.5.200) 6.672 ms 6.661 ms 6.953 ms 3 wnpgmb0129w-dr05-v957.mts.net (142.161.5.65) 7.728 ms 7.383 ms 7.279 ms 4 equinix.xe-1-3-0.cr2.ord1.us.nlayer.net (206.223.119.61) 24.165 ms 24.270 ms 24.021 ms 5 xe-3-1-0.cr1.atl1.us.nlayer.net (69.22.142.46) 38.608 ms 39.017 ms 38.886 ms 6 ae1-40g.ar1.atl1.us.nlayer.net (69.31.135.130) 40.054 ms 39.864 ms 42.576 ms 7 as3595.xe-2-0-5-103.ar1.atl1.us.nlayer.net (69.31.135.54) 53.940 ms 54.887 ms 53.855 ms 8 64.22.106.14 (64.22.106.14) 54.149 ms 54.104 ms 54.220 ms 9 atlanta1.linode.com (63.247.71.196) 53.109 ms 53.801 ms 53.258 ms =========================================================================== dallas1.linode.com Location Result min. rrt avg. rrt max. rrt IP Toronto, Canada: Okay 52.9 53.3 53.8 69.164.200.100 Vancouver, Canada: Okay 80.7 80.8 81.0 69.164.200.100 Hong Kong, China: Okay 227.3 228.1 229.1 69.164.200.100 Shanghai, China: Checkpoint temporarily not available - - - - Beijing, China: Checkpoint temporarily not available - - - - Nagano, Japan: Okay 177.7 178.6 179.1 69.164.200.100 ➜ ~ traceroute dallas1.linode.com traceroute to dallas1.linode.com (69.164.200.100), 64 hops max, 52 byte packets 1 192.168.100.254 (192.168.100.254) 0.476 ms 0.227 ms 0.181 ms 2 wnpgmb0911w-ad03-lo2.mts.net (142.161.5.200) 6.481 ms 6.547 ms 6.737 ms 3 wnpgmb0129w-dr05-v957.mts.net (142.161.5.65) 7.738 ms 7.560 ms 7.611 ms 4 xe-7-3-1.edge4.chicago2.level3.net (4.28.68.21) 22.899 ms 23.801 ms 22.661 ms 5 4.69.158.154 (4.69.158.154) 22.880 ms 4.69.158.146 (4.69.158.146) 22.905 ms 4.69.158.154 (4.69.158.154) 22.944 ms 6 ae-2-52.edge4.chicago3.level3.net (4.69.138.166) 22.658 ms 22.974 ms 22.964 ms 7 te2-5.bbr01.eq01.chi01.networklayer.com (4.53.98.26) 23.028 ms 22.915 ms 23.341 ms 8 ae7.bbr01.eq01.chi01.networklayer.com (173.192.18.170) 23.276 ms 23.251 ms 23.106 ms 9 ae20.bbr01.eq01.dal03.networklayer.com (173.192.18.136) 44.276 ms * 42.577 ms 10 po31.dsr02.dllstx3.networklayer.com (173.192.18.227) 42.343 ms 42.531 ms 48.235 ms 11 te2-4.dsr01.dllstx2.networklayer.com (70.87.255.110) 46.879 ms * 43.209 ms 12 po1.car01.dllstx2.networklayer.com (70.87.254.74) 46.536 ms 47.211 ms 46.411 ms 13 5a.7.1243.static.theplanet.com (67.18.7.90) 46.610 ms 46.976 ms 43.166 ms 14 dallas1.linode.com (69.164.200.100) 46.899 ms 46.901 ms 47.173 ms ======================================================================================== Solution From server to my home: 8 newark1.linode.com (207.192.68.6) 45.461 ms 45.814 ms 46.035 ms 14 dallas1.linode.com (69.164.200.100) 46.899 ms 46.901 ms 47.173 ms 9 atlanta1.linode.com (63.247.71.196) 53.109 ms 53.801 ms 53.258 ms 9 fremont1.linode.com (64.71.152.17) 75.233 ms 75.279 ms 74.783 ms 9 tokyo1.linode.com (106.187.33.12) 161.979 ms 162.831 ms 165.290 ms =========================================================================== From server to China: Newark: Hong Kong, China: Okay 224.3 227.5 229.6 207.192.68.6 Shanghai, China: Okay 522.4 529.2 534.3 207.192.68.6 Beijing, China: Packets lost (20%) 454.8 557.3 621.0 207.192.68.6 Dallas: Hong Kong, China: Okay 227.3 228.1 229.1 69.164.200.100 Shanghai, China: Checkpoint temporarily not available - - - - Beijing, China: Checkpoint temporarily not available - - - - Atlanta: Hong Kong, China: Okay 233.0 236.5 239.7 63.247.71.196 Shanghai, China: Packets lost (10%) 542.2 545.4 547.2 63.247.71.196 Beijing, China: Packets lost (20%) 336.2 344.9 392.7 63.247.71.196 Fremont: Hong Kong, China: Okay 191.7 194.8 196.5 64.71.152.17 Shanghai, China: Okay 271.6 274.5 278.0 64.71.152.17 Beijing, China: Okay 223.3 224.0 225.2 64.71.152.17 Tokyo: Hong Kong, China: Okay 53.2 54.4 55.9 106.187.33.12 Shanghai, China: Okay 509.9 516.6 520.6 106.187.33.12 Beijing, China: Okay 159.2 171.4 179.3 106.187.33.12
wget -O dropbox.tar.gz http://www.dropbox.com/download?plat=lnx.x86
如果是 64 位主机则为
wget -O dropbox.tar.gz http://www.dropbox.com/download?plat=lnx.x86_64
.dropbox-dist
目录,运行 ~/.dropbox-dist/dropboxd &
Dropbox
目录,把要备份的文件软链接到这个目录中就可以了。apt-get install awstats
我安装的是 7.0 版本,有更新的版本,但在 Ubuntu 的库里没有。我还是用了系统安装而不是手动安装。系统安装的确实少了一些脚本。
cp /etc/awstats/awstats.conf /etc/awstats/awstats.liuf.net.conf
编辑 /etc/awstats/awstats.liuf.net.conf
文件:
LogFile="/var/log/apache2/access.log" # 确认是否指向正确的文件 LogFormat=1 # 格式。默认的是 4,具体有什么区别我也不甚清楚 SiteDomain="liuf.net" HostAliases="localhost 127.0.0.1 liuf.net" AllowFullYearView=3 # 允许整年模式。数据库大的时候会很浩资源,所以默认关闭。不过我的小站没问题
运行
/usr/lib/cgi-bin/awstats.pl -config=liuf.net -update
这会在 /var/lib/awstats
目录生成数据库。数据库生成速度不快,我的小站的情况是一个小时到一个半小时生成一个月的数据库。
编辑 /etc/apache2/site-available/liuf.net
,添加
<VirtualHost *:80> ... Alias /awstatsclasses "/usr/share/awstats/lib/" Alias /awstats-icon/ "/usr/share/awstats/icon/" Alias /awstatscss "/usr/share/doc/awstats/examples/css/" ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ ScriptAlias /awstats/ /usr/lib/cgi-bin/ ... </VirtualHost>
安装文档中有些特殊的属性设置,我不清楚具体是什么意思,不过目前的设置可以正常工作。
运行
crontab -e
编辑 Cron 设置,添加:
0 */3 * * * /usr/lib/cgi-bin/awstats.pl -config=liuf.net -update > /dev/null
每三小时运行一次。
自动运行的运行人居然是 www-data
,这样会因为无法访问 /var/log/apache2
目录而出错。解决方法是
chmod -R 755 /var/log/apache2/
可以用
sudo -u www-data /usr/bin/perl /usr/lib/cgi-bin/awstats.pl -update -config=liuf.net
测试,看输出结果是否正常。
这一部分我参考了 http://awstats.sourceforge.net/docs/awstats_faq.html#ROTATE
Logrotate 会分离 access.log
文件,影响生成数据库。我在第一次生成的时候写了个脚本合并之前分离的记录,生成了一个 347M 的巨大的 access.log
文件,Awstats 分析了十二个多小时才完成。
为了让 Logrotate 不影响 Awstats 的分析,编辑 /etc/logrotate.d/apache2
文件,在 prerotate
后面添加一行
/usr/lib/cgi-bin/awstats.pl -config=liuf.net -update
这样每次分离日志前会先更新 Awstats 的数据库。
Awstats 会自动的在 /etc/cron.d/
里创建条目,每十分钟运行一次脚本。默认安装的权限有些问题,会导致每次运行都发送邮件报错。Crontab 里是用 www-data 用户来执行的,我给改成了 root。
脚本会遍历 /etc/awstats/awstats.*.conf
文件,这里面包含了未配置的 /etc/awstats/awstats.conf
文件,也会出错,我的办法是给文件改名,不要 awstats.*.conf
格式就行。我改成了 awstats.conf-original
后,问题解决。
有些设置需要改动,记录在此。
WordPress 需要上传更大的文件,现在手机一幅照片都能达到 10MB 多。过去设置的是 5MB,现在设置成 20MB。说这句话时我犯了个错误,PNG 图片不压缩体积就会更大,其实我根本用不到 10M 的图片。上传限制设成 5M 就足够了。
/etc/php5/cgi/php.ini
文件:
post_max_size = 8M upload_max_filesize = 5M
/etc/apache2/mods-enabled/fcgid.conf
文件:
<IfModule mod_fcgid.c> ... FcgidMaxRequestLen 5242880 </IfModule>
5242880 = 5 * 1024 * 1024