博文

Linux vps修改时间改成北京时间

1.先登陆你的ssh,命令:date 看下时间是不是北京时间,如果不是我们把他改成北京时间。 2.命令: rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime   3.再用date命令看下,你的vps的时间改变了吗?大部分Linux vps的母鸡是允许每个vps修改时间的! 如果此时你的vps时间已经改成北京时间就不用看下面了,如果此时你的vps时间还没有修改好。再试下命令: ntpdate stdtime.sinica.edu.tw 使用ntpdate stdtime.sinica.edu.tw 时候如果提示这个命令,先安装 ntpdate就可以了。   centos 系统的vps用命令: yum -y install ntpdate ntp Ubuntu系统的: sudo apt-get install -y ntpdate ntp

关于apache2伪静态问题

刚把博客搬了一个新家,之前是用一键安装包配置的VPS,虽然配置完了能很正好的运行,但是有很多想地方想修改却不知道从何处下手。这次搬家,全是手动配置的APACHE2环境,其实手运配置还是蛮简单的,只要自己细心点,但是配置完成后发现怎么也无法实现伪静态,开始以为是伪静态规则出了问题,但经过很多次试验,感觉发现不是伪静态规则的问题,看了看PHPINFO信息,原来里面没有mod_rewrite模块,这下犯愁了,因为APACHE2安装是用默认安装的,难道默认安装apache2没有安装mod_rewrite模块?试着用google和百度查看一些如何重新加入mod_rewrite模块的方法,网上有大多数是垃圾文章,还好没试,不然试了又要重新配置VPS。看了一些资料,原来默认安装的apache2是有安装mod_rewrite模块,只是没有启动而已 a2enmod rewrite 启动 然后系统会提示你重新加载apache2 ,最后再用phpinfo查看,就已经有mod_rewrite模块了

Optimize Apache and MySQL for a 256MB VPS

sudo nano /etc/mysql/my.cnf   Add the following line into the section [mysqld]: skip-innodb   Next locate the line skip-external-locking and add skip-locking below that line.   Now find the section labeled “Fine Tuning”. Change/add the settings in that section to match those below:   key_buffer = 16K max_allowed_packet = 1M thread_stack = 64K thread_cache_size = 4 sort_buffer = 64K net_buffer_length = 2K   Save the file (ctrl+x) and restart MySQL: sudo /etc/init.d/mysql restart If you run MySQLtuner again you will see that the “memory” warning is gone, ignore the aother warnings for the moment (you need to run the script after a few days again to get exact test results)   Optimize Apache in prefork mode If you followed the Ubuntu tutorial we’ve mentioned in the first paragraph, your Apache setup should run in prefork mode. The default settings are much to high, open the file sudo nano /etc/apache2/apache2.conf andchange the following settings:    ...

购买VPS后简单测试

一、CPU信息及性能查看 cat /proc/cpuinfo 二、硬盘IO性能测试 root@h:~# dd if=/dev/zero of=test bs=64k count=4k oflag=dsync && rm test 4096+0 records in 4096+0 records out 268435456 bytes (268 MB) copied, 6.19022 s, 43.4 MB/s root@h:~# dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync && rm test 16384+0 records in 16384+0 records out 1073741824 bytes (1.1 GB) copied, 6.32504 s, 170 MB/s 测试结果,如果超过10M,对正常建站就无影响。超过50M,就是非常给力状态。

nginx wolf 支持伪静态文件.htaccess

if (!-e $request_filename) { rewrite ^/admin(.+)$ /admin/index.php?$1 last; rewrite ^/(.+)$ /index.php?WOLFPAGE=$1 last; }

ssh只允许指定的用户登陆

方法1:在/etc/pam.d/sshd文件第一行加入 auth required pam_listfile.so item=user sense=allow file=/etc/sshusers onerr=fail 然后在/etc下建立sshusers文件,编辑这个文件,加入你允许使用ssh服务的用户名,不用重新启动sshd服务。   方法2:pam规则也可以写成deny的 auth required pam_listfile.so item=user sense=deny file=/etc/sshusers onerr=succeed   方法3:在sshd_config中设置AllowUsers,格式如 AllowUsers a,b,c 重启sshd服务,则只有a/b/c3个用户可以登陆

linux 限制root用户SSH登录

1、修改SSHD服务的配置文件/etc/ssh/sshd_config 将#PermitRootLogin yes 改为PermitRootLogin no 2、重启sshd服务使配置生效 /etc/rc.d/init.d/sshd restart   为了增强linux的安全性,应该限制只有wheel组的用户可以使用su命令切换到root和其他用户:   1、修改su命令的认证配置文件/etc/pam.d/su   去掉以下两行前的#号注释 #auth sufficient pam_wheel.so trust use_uid (去年注释后ROOT组成员使用su切换到root不需要密码) #auth required pam_wheel.so use_uid  (去年注释后只允许ROOT组成员使用su切换到root) 2、创建一个普通用户,然后将这个用户加入到wheel组即可!以后就只有这个普通用户和root可以使用su命令了 usermod -G 组 用户   su命令使用简介:   su 直接切换到root用户,但保持原用户的环境变量; su – 切换到root用户,并使用root用户的环境变量;   su -l test 切换到test用户,并使用test的环境变量;

nginx 禁止ip访问及未绑定的域名跳转

ngixn 禁止ip访问和未绑定ip的访问   server { listen 80 default; server_name _; return 500; }       nginx 将未绑定的域名跳转   server { listen 80 default; rewrite ^(.*) http://www.kogoogle.com permanent; }

Freebsd pkg_delete删除错误安装的php

本来想升级下php52至php53,结果可能由于操作不当导致53无法正常运行,加上自己不小心删除了/usr/local/lib/php/扩展包里的一些文件,导致再重新安装的时候php也不行,进退两难,尝试过几次通过ports卸载php,然后重装,都不可以,无论是52还是53. 网上发现一个命令,尝试了下很管用: pkg_delete -f php\* rm -fr /usr/local/include/php/ 然后再重装,这样问题就解决了,哎,着急了我半天,还是命令不熟悉。