SSH安装之twip(支持ssl的twitter API)

2012年9月13日更新一个从土豆看到的视频

购买一个国外VPS,先安装nginx ,php,ssh使用这个脚本,就可以安装一个支持SSL的twitter API,我这里使用已经安装好LNMP的主机做演示。
环境:CentOS 5.5+LNMP

wget http://www.yishanhome.com/wp-content/uploads/2011/03/twip.sh;sh twip.sh

运行以上完毕之后,打开你刚刚填入的域名,记住是https。打开之后,选择O模式

直接提交认证

完成!复制出你要的twitter API路径,记住保密

?Download twip.sh
#!/bin/bash
array=(http://twip.googlecode.com/files/twip-4.1-r184.tar.gz)
length=${#array[@]}
usage()
{
clear
printf "
#This is a Shell-Based tool
# Author: yishan
# Website: http://www.yishanhome.com
"
if [ $length -gt "1" ] ; then
for ((i=0; i<$length; i++))
do
let "m = $i + 1"
echo "$m. ${array[$i]}"
done
echo ""
option=0
read -p "Please input your option:" option
let "option = $option + 0"
  if [ "$option" -eq "0" ] || [ "$option" -gt "$length" ] ; then
    usage
  fi
  else
option=1
fi
}
 
 
 
input_domain()
{
  read -p "Please input domain:" domain
  if [ "$domain" = "" ]; then
  input_domain
  fi
}
input_OAUTH_KEY()
{
  read -p "Please input Twitter API Consumer Key:" OAUTH_KEY
  if [ "$OAUTH_KEY" = "" ]; then
  input_OAUTH_KEY
  fi
}
input_OAUTH_SECRET()
{
  read -p "Please input Twitter API Consumer Secret:" OAUTH_SECRET
  if [ "$OAUTH_SECRET" = "" ]; then
  input_OAUTH_SECRET
  fi
}
 
www_dir=/home
usage
let "option = $option - 1"
down_url=${array[$option]}
down_file=$(echo $down_url | awk -F\/ '{print $NF}')
sitecode=$(echo $down_file | awk -F\. '{print $1}')
mkdir $HOME/$sitecode
mkdir $www_dir/$sitecode
mkdir /usr/local/nginx/conf/vhost
input_domain
input_OAUTH_KEY
input_OAUTH_SECRET
wget $down_url
 
if echo $down_file|grep -q .zip;then
unzip $down_file -d $HOME/$sitecode
fi
 
if echo $down_file|grep -q .tar.gz;then
tar -zxvf $down_file -C $HOME/$sitecode
fi
 
mv $HOME/$sitecode/twip/* $www_dir/$sitecode/
chmod 777 $www_dir/$sitecode -R
cat > $www_dir/$sitecode/config.php <<EOF
<?php
define('OAUTH_KEY','$OAUTH_KEY');
define('OAUTH_SECRET','$OAUTH_SECRET');
define('BASE_URL','https://$domain/');
define('API_VERSION','1');
define('DEBUG',FALSE);
define('DOLOG',FALSE);
define('COMPRESS',FALSE);
?>
EOF
cat > /usr/local/nginx/conf/vhost/$domain.conf <<EOF
server
        {
        listen       443;
        ssl on;
        ssl_certificate /usr/local/nginx/cacert.pem;
        ssl_certificate_key /usr/local/nginx/privkey.pem;
        server_name $domain;
        index index.htm index.html index.php default.html default.htm default.php;
        root  $www_dir/$sitecode;
        location /{
                if (!-e \$request_filename){
                rewrite ^/(.*)$ /index.php last;
                }
       }
                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }
 
                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }
 
                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }
 
                access_log off;
        }
EOF
openssl genrsa -out privkey.pem 2048
openssl req -new -batch -x509 -key privkey.pem -out cacert.pem -days 1095
cp privkey.pem /usr/local/nginx/
cp cacert.pem /usr/local/nginx/
/usr/local/nginx/sbin/nginx -s reload
  1. 2011年6月6日15:52

    不能创建目录 怎么回事,这里填写的域名应该是什么样的?
    #This is a Shell-Based tool
    # Author: yishan
    # Website: http://www.yishanhome.com
    mkdir: cannot create directory `/home/twip-4′: File exists
    mkdir: cannot create directory `/usr/local/nginx/conf/vhost’: File exists
    Please input domain:

    Google Chrome 11.0.696.71 Windows 7
  2. 2011年6月6日16:04

    @bigcar 这里填写你Nginx配置文件要绑定的域名,或者IP地址也可以;无法创建目录,是因为,我们的Nginx环境有所不一样。

    Firefox 4.0.1 Windows Server 2003
  3. 2011年6月6日16:59

    这是我的 nginx.conf

    user www www;

    worker_processes 1;

    error_log /home/wwwlogs/nginx_error.log crit;

    pid /usr/local/nginx/logs/nginx.pid;

    #Specifies the value for maximum file descriptors that can be opened by this process.
    worker_rlimit_nofile 51200;

    events
    {
    use epoll;
    worker_connections 51200;
    }

    http
    {
    include mime.types;
    default_type application/octet-stream;

    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 8m;

    sendfile on;
    tcp_nopush on;

    keepalive_timeout 60;

    tcp_nodelay on;

    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 256k;

    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml;
    gzip_vary on;

    #limit_zone crawler $binary_remote_addr 10m;
    resolver 8.8.8.8;

    server
    {
    listen localhost:60000;
    location /
    {
    proxy_pass http://$http_host$request_uri;
    }
    listen 80;
    server_name blog.025buyi.com;#default
    return 404;
    index index.html index.htm index.php;
    root /home/wwwroot;

    location ~ .*\.(php|php5)?$
    {
    fastcgi_pass unix:/tmp/php-cgi.sock;
    fastcgi_index index.php;
    include fcgi.conf;
    }

    location /status {
    stub_status on;
    access_log off;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
    expires 30d;
    }

    location ~ .*\.(js|css)?$
    {
    expires 12h;
    }

    log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ‘
    ‘$status $body_bytes_sent “$http_referer” ‘
    ‘”$http_user_agent” $http_x_forwarded_for’;
    access_log /home/wwwlogs/access.log access;
    }

    upstream ghs {
    ip_hash;
    server ghs.google.com;
    server 72.14.203.121;
    server 72.14.207.121;
    }

    server {
    listen 80;
    server_name ghs.eukeepfun.org tmail.eukeepfun.org;
    location / {
    proxy_set_header Host $host;
    proxy_pass http://ghs;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    }

    server
    {
    listen 80;
    server_name mail.cambricare.com;

    location / {
    proxy_pass https://mail.google.com/a/cambricare.com/;
    proxy_redirect off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For
    $proxy_add_x_forwarded_for;
    }
    }

    include vhost/*.conf;
    }

    帮忙看看,需要怎么样来修改你的脚本以适应,谢谢

    Google Chrome 11.0.696.71 Windows 7
  4. 2011年6月6日17:01

    我的主目录 是指向 /home/www/,并不是默认的/home/wwwroot ,所有的网站都在www目录下以www.xxx.com为目录名形式存在。

    Google Chrome 11.0.696.71 Windows 7
  5. 2011年6月6日17:05

    @bigcar
    mkdir: cannot create directory `/home/twip-4′: File exists 这个是指你的站点目录
    mkdir: cannot create directory `/usr/local/nginx/conf/vhost’: File exists 这个是指你Nginx配置文件路径,不是配置文件内容

    Firefox 4.0.1 Windows Server 2003
  6. 操操
    2011年10月31日22:50

    请教博主,那个ssl是啥时候加上去的?CentOS 5.5+LNMP环境中本来就有的吗?

    Google Chrome 15.0.874.106 Windows 7
  7. mashanickolk
    2012年12月19日15:17

    Всем приветики!
    Давно я здесь не была.Пароль забыла, вот пришлось заново регистрироваться
    Я продала свою старую девятку и хочу новую машинку.
    Не хватает денег только 🙁
    Нашла сайтик как думаете можно ли через интернет такое?
    Всегда ваша Маша, чмоки.

    Google Chrome 18.0.1025.162 Windows 7 x64 Edition
  8. There is certainly a lot to know about this subject. I really like all of the points you’ve made.

    Internet Explorer 6.0 Windows XP
  9. 2016年6月21日20:38

    tadalafil cialis 20 mg – overnight cialis delivery, female cialis tadalafil.

    Google Chrome 48.0.2564.116 Windows 10 x64 Edition
  10. 2016年7月20日07:05

返回顶部