公司搬家我也要跟着搬
之前写了一个租房需求,根据当前个人的情况来
公交方便(能有到地铁)
洗衣机
做饭
宽带
安静
安全
锻炼
现在租在南理工附近,上面需要的都有,人无远虑,必有近忧,把自已的路走踏实了,以更多付出换回更多回报。想想去年自己在做什么,今年有这样的困难也是事情发展情况之中的。
还有一点要提醒自已,拥有的东西一定要保持简洁,否则搬家要麻烦死。
OK,看看明年能不能过上吃喝不用担心的程度
公司搬家我也要跟着搬
之前写了一个租房需求,根据当前个人的情况来
公交方便(能有到地铁)
洗衣机
做饭
宽带
安静
安全
锻炼
现在租在南理工附近,上面需要的都有,人无远虑,必有近忧,把自已的路走踏实了,以更多付出换回更多回报。想想去年自己在做什么,今年有这样的困难也是事情发展情况之中的。
还有一点要提醒自已,拥有的东西一定要保持简洁,否则搬家要麻烦死。
OK,看看明年能不能过上吃喝不用担心的程度
参考:
http://open.oray.com/wiki/doku.php?id=文档:花生壳:http协议说明
只能使用GET方式提交信息,这里使用curl,需提前安装好curl。
加一个判断,如果当前dns中的ip和检测的ip不一致时,就自动提交;一致则退出。
#!/bin/bash orayuser=your oray name oraypass=your oray passoword oraydomain=your domain realip=`curl http://ddns.oray.com/checkip | cut -d' ' -f 6 | cut -d'<' -f 1` theurl="http://$orayuser:[email protected]/ph/update?hostname=$oraydomain&myip=$realip" currentip=`nslookup $oraydomain | tail -2 | head -1 | cut -d' ' -f 2` if [ "$realip" = "$currentip" ]; then exit 0 else curl "$theurl" fi
在crontab中加入以下内容,每十五分钟检测一次
*/15 * * * * /bin/bash /root/pushiporay.sh
–添加于2013年3月3日开始–
后来申请了noip.com的二级域名,才发现花生壳和人家的api是如此的像。同理可更新noip里的记录
#!/bin/bash noipuser=your noip username noippass=your noip password noipdomain=your noip domain realip=`curl http://ddns.oray.com/checkip | cut -d' ' -f 6 | cut -d'<' -f 1` noipurl="http://$noipuser:[email protected]/nic/update?hostname=$noipdomain&myip=$realip" noipcurrentip=`nslookup $noipdomain | tail -2 | head -1 | cut -d' ' -f 2` if [ "$realip" = "$noipcurrentip" ]; then echo "no need to update" exit 0 else curl "$noipurl" fi
如果论坛放在/club目录时,nginx中对应server{}的discuz rewrite可使用如下规则实现伪静态。
location /club/ {
index index.php;
try_files $uri $uri/ @discuz;
}
location @discuz {
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
return 404;
}
}
需要批量创建数据库及数据库对应用户,写了一个对于mysql的执行脚本。
#!/bin/bash
#用法:将数据库名/用户名用:分隔开,每个一行,写入一个文件,执行脚本+文件名,可创建数据库,并为其分配同名用户
IFS=:
while read dbname dbpassword
do
sql_user='root'
sql_pass='root'
mysql -u $sql_user -p$sql_pass -s <<EOT
create database if not exists $dbname default charset utf8 collate utf8_general_ci;
QUIT
EOT
mysql -u $sql_user -p$sql_pass -s << EOF
insert into mysql.user (Host,User,Password) values ("localhost","$dbname",PASSWORD("$dbpassword"));
flush privileges;
grant all on $dbname.* to $dbname@localhost;
flush privileges;
QUIT
EOF
done < $1
要求:在nginx环境下,打开服务器的http://ip/phpmyadmin或http://域名/phpmyadmin都能够使用phpmyadmin,则只需在对应网站的server{}中添加如下配置即可。
#------ nginx.conf phpmyadmin ------#
location /phpmyadmin {
alias /usr/share/phpMyAdmin;
index index.php;
}
location ~ ^/phpmyadmin/.+\.php$ {
if ($fastcgi_script_name ~ /phpadmin/(.+\.php)$) {
set $valid_fastcgi_script_name $1;
}
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
}
#------ nginx.conf phpmyadmin end ------#
官方介绍:
https://fedoraproject.org/wiki/EPEL/zh-cn
在装了epel之后,要安装nginx,php,mysql,直接yum install就可以了。
EPEL 包含一个叫做’epel-release’的包,这个包包含了 EPEL 源的 gpg 密钥和软件源信息。
现在安装epel-release
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
重装
rpm -iv --replacepkgs http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
上面的地址经常变,可以打开下面网址找到epel包
http://dl.fedoraproject.org/pub/epel/6/x86_64/
导入RPM-GPG-KEY-EPEL的key
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
epel安装完之后在/etc/yum.repos.d/下生成了两个文件,epel.repo,epel-testing.repo
修改epel.repo文件(epel-testing包含最新的测试软件包,其版本很新但是安装有风险)
在[epel-debuginfo]前添加
priority=11
这样yum时会先去官方源查找,官方源没有再去epel安装
PS:还有一款不错的源,叫atomic,包含有php-fpm,安装这个源则更为方便,此脚本会自动安装对应系统的版本,更省心。
wget -q -O - http://www.atomicorp.com/installers/atomic | sh
同样rpmforge也很不错,在这里查看对应版本的安装方法
http://wiki.centos.org/zh/AdditionalResources/Repositories/RPMForge
epel centos6 源
[epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://mirrors.tuna.tsinghua.edu.cn/epel/6/$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 [epel-debuginfo] name=Extra Packages for Enterprise Linux 6 - $basearch - Debug baseurl=http://mirrors.tuna.tsinghua.edu.cn/epel/6/$basearch/debug failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 6 - $basearch - Source baseurl=http://mirrors.tuna.tsinghua.edu.cn/epel/6/SRPMS failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=1