上次写了一个单用户的脚本可以修改配置文件的密码并重启服务,这次在上次脚本的基础上做了些改进,对多用户版的配置文件进行修改。
Tag Archives | debian
用BashScript脚本自动修改shadowsocks密码
最近闲着无聊,了解了一下bash命令,写了一个自动修改shadowsocks密码的脚本
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 |
#!/bin/bash #================================================================ # Script for Shadowsocks Single User Password Renewing on Ubuntu/Debian # @author minirplus # Usage: ./ss-password-renew.sh # More info: https://blog.minirplus.com/5800/ #================================================================ # get old password old_password=$(grep password /etc/shadowsocks.json) password_index=$(expr index "$old_password" :) old_password=${old_password:password_index} old_password=${old_password%%,*} old_password=${old_password// /} old_password=${old_password:1:$((${#old_password}-2))} echo "your old password is $old_password" # generate new password new_password=$RANDOM echo "your new password is $new_password" # replace old password to new password echo "replace new password $new_password to the shadowsocks config file..." sed -i 's/'"$old_password"'/'"$new_password"'/g' /etc/shadowsocks.json # restart shadowsocks service echo "Restarting shadowsocks service..." /usr/local/bin/ssserver -c /etc/shadowsocks.json -d restart # All Done! echo "All Done!" echo "You can now use new password $new_password to login shadowsocks service now!" |
运行结果如下
1 2 3 4 5 6 7 8 9 10 |
root@vps:~# /usr/local/sbin/change-shadowsocks-password your old password is 28882 your new password is 20713 replace new password 20713 to the shadowsocks config file... Restarting shadowsocks service... INFO: loading config from /etc/shadowsocks.json 2016-02-15 17:17:33 INFO loading libcrypto from libcrypto.so.1.0.0 stopped started All Done! You will now can use new password 20713 to login shadowsocks service |
shadowsocks配置文件如下
1 2 3 4 5 6 7 8 9 10 |
{ "server":"0.0.0.0", "server_port":8381, "local_address": "127.0.0.1", "local_port":1080, "password":"20713", "timeout":300, "method":"aes-256-cfb", "fast_open": false } |
Debian7.8+PHP5.4+Apache2.2安装和配置php-apc缓存组件
环境
- Debian 7.8 Wheezy 64-bit
Apache/2.2.22 (Debian)
PHP 5.4.36-0+deb7u3 (fpm-fcgi)
安装php-apc
首先执行以下命令安装php-apc
1 |
# apt-get install php-apc |
安装完成后运行 service php5-fpm restart 或者 service apache2 restart ,然后查看php信息 phpinfo() ,Ctrl+F搜索APC,检查是否已正确运行。
Debian7.8+PHP5.4+Apache2.2 配置fastcgi和php-fpm
从搬家到VPS算起已经一个月了,一直用的apache的prefork模式,但是时不时的apache就来一次崩溃,要不就是mysql崩溃,后来通过看日志发现问题所在,原来是apache在访问量突发的情况下内存溢出,遂不断的去网上找合适的prefork设置参数,不断的调整,最后终于找到了合适的参数
1 2 3 4 5 6 7 |
<IfModule mpm_prefork_module> StartServers 2 MinSpareServers 2 MaxSpareServers 13 MaxClients 14 MaxRequestsPerChild 200 </IfModule> |
在MaxClients=14的时候通过了压力测试,这时候的可用内存Cache+buffers在50M左右,CPU达到了100%,算是极限了。14个进程啊,这就到极限了啊,每个apache2进程都几乎用了100M的内存和10%的cpu啊,网上不是都说一个apache进程就5M么,算下来1G内存轻松80个进程没问题啊,骗人么这不是,而且用了这么多资源,但为什么每次打开网页还是卡得像史一样的慢啊。
Debian 7.8 Wheezy 64-bit 安装Vmware Tools
全新安装完Debian7.8之后,为了实现根据窗口自动调整分辨率和共享剪贴板,需要安装Vmware Tools。