• 每天进步一点点!

文章分类

推荐网站

常用手册

nginx 手机端访问跳转到m站点【原创】

nginx 手机端访问跳转到m站点

     location / {
            if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
                rewrite ^/(.*)$ http://m.1weidu.com/$1 permanent;    #进行正常访问的时候判断user_agent为手机,则重写至此页面
            }
         try_files $uri /index.php?$args;
     }

 

类别:Nginx | 浏览(107) | 评论(0) | 阅读全文>>

nginx远程PHP开发环境设置【原创】

server {
    listen       80;
    server_name  ~^(?<subdomain>.+)\.dev.domain.com;

    root /data/dev/$subdomain/project;
    index index.php;
    charset utf-8;

    access_log  /var/log/nginx/domain.com-access.log;
    error_log  /var/log/nginx/domain.com-error.log;

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

    location ~ .*\.(js|css)$ {
        expires 10d;
    }

    location / {
        try_files $uri /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_index  index.php;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

 

这样在/data/dev/下新建开发者的目录,可以以开发者名字的全拼或简写命名,如:abc,然后在这个目录acb下开发对应的项目project,项目的访问地址为:abc.dev.domain.com。可以做域名解析或绑定host访问。

类别:Nginx | 浏览(76) | 评论(0) | 阅读全文>>

centos下nginx、php-fpm、mysql、redis启动脚本【原创】

  • nginx启动、重启、停止脚本
#!/bin/bash
#
# Startup script for Nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:     /usr/local/nginx/logs/nginx.pid
 
# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network
 
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
 
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
 
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
 
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
 
lockfile=/var/lock/subsys/nginx
 
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
 
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
 
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
 
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
 
force_reload() {
    restart
}
 
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
 
rh_status() {
    status $prog
}
 
rh_status_q() {
    rh_status >/dev/null 2>&1
}
 
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

 

类别:Linux | 浏览(75) | 评论(0) | 阅读全文>>

widonws上用xshell生成用户秘钥免密码登录linux服务器【原创】

widonws上用xshell生成用户秘钥免密码登录linux服务器,具体方法如下图:

 

 

 

 

注:这里给私钥起个名字,为了方便记忆可以以服务器的IP地址做文件名,点击Next

 

 

注:把公钥也就是红色框内的全部内容添加到服务器的/home/username/.ssh/authorized_keys文件中。

 

 

这里显示了用户的所有私钥,当用public key方法登录时,需要选择对应的私钥

 

 

注:非root用户需要修改一下权限

chmod 700 /home/zhangsan/.ssh
chmod 600 /home/zhangsan/.ssh/authorized_keys

 

只允许root用户之外的用户以公钥的形式登录。

 vi /etc/ssh/sshd_config  
PasswordAuthentication no #禁止使用基于口令认证的方式登陆
PubkeyAuthentication yes #允许使用基于密钥认证的方式登陆
service sshd restart

 

类别:Linux | 浏览(140) | 评论(0) | 阅读全文>>

git免密码pull和push【原创】

git免密码pull和push可以用生成秘钥和公钥的方法,也可以用下面的方法,但下面的方法有个缺陷,就是git的用户名和密码是明文的,只有在安全度要求不高的情况下使用

新建文件夹:

weijinbu

进入weijinbu文件夹,然后执行

git init

这时会在weijinbu目录下生成一个.git的文件夹,进入.git文件夹

编辑config文件

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
[remote "origin"]
        url = https://weijinbu:zhangsan@bitbucket.org/weijinbu/weijinbu.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

 

第9行中 weijinbu:zhangsan 冒号前面是用户名,后面是密码

然后执行

git pull

git fetch 

拉去仓库代码

类别:工具配置 | 浏览(81) | 评论(1) | 阅读全文>>