分页: 5/28 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]
Mar 13
具体配置文件参考:
fastcgi.conf

fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

fastcgi_param PATH_INFO           $path_info;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param  REDIRECT_STATUS    200;


nginx.conf

user      nginx nginx;
worker_processes  16;

error_log  logs/nginx_error.log  crit;
pid        logs/nginx.pid;

events {
    worker_connections  65535;
}

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

    log_format  weblog  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  weblog;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  65;

    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_proxied any;
    gzip_comp_level 2;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
    include /usr/local/nginx/conf/test.conf;
}


test.conf

server
{
        listen 80;
        server_name www.test.com;
        access_log logs/test.log;
        root /home/wwwroot/ci;
        index index.php index.html index.htm;

        location / {
                if (!-e $request_filename) {
                        rewrite ^/(.*)$ /index.php/$1 last;
                }  
        }

        location ~ \.php {
                set $real_script_name $fastcgi_script_name;
                set $path_info "";
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)
                        set $real_script_name $1;
                        set $path_info $2;
                }  
                fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info;
                include fastcgi.conf;
        }
}

以上配置可以支持ThinkPHP,CI,ZF等等框架

下面是NGINX官方对于pathinfo提供的解决方法:
fastcgi_split_path_info
syntax: fastcgi_split_path_info regex
context: location
version: ≥ 0.7.31

This directive allows the setting of the SCRIPT_FILENAME (SCRIPT_NAME) and PATH_INFO variables of the CGI specification. The regex consists of two groups:

path to the script that will handle the request — corresponding to $fastcgi_script_name.
the value of the parameter to be given to the script — corresponding to the $fastcgi_path_info.

Here's an example. The script show.php receives as argument the string article/0001. The following configuration will handle path splitting properly:

location ~ ^.+\.php {
  (...)
  fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
  fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  (...)
}

Requesting /show.php/article/0001 sets SCRIPT_FILENAME to /path/to/php/show.php and PATH_INFO to /article/0001.
Mar 12
一、Apache YOURLS Rewrite规则
1、安装在根目录下:

# BEGIN YOURLS

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /yourls-loader.php [L]

# END YOURLS

2、安装在子目录下

# BEGIN YOURLS

RewriteEngine On
RewriteBase /somedir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /somedir/yourls-loader.php [L]

# END YOURLS

3、使用非带www的域名

# BEGIN WithoutWWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yourls\.org$ [NC]
RewriteRule ^(.*)$ http://yourls.org/$1 [R=301,L]
# END WithoutWWW

二、Nginx YOURLS Rewrite规则
1、安装在根目录下

location /
{
if (!-f $request_filename){
        set $rule_0 1$rule_0;
}
if (!-d $request_filename){
        set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
        rewrite ^/([0-9A-Za-z]+)/?$ /yourls-go.php?id=$1 last;
}
        rewrite ^/([0-9A-Za-z]+)\+/?$ /yourls-infos.php?id=$1 last;
        rewrite ^/([0-9A-Za-z]+)\+all/?$ /yourls-infos.php?id=$1&all=1 last;
}

2、安装在子目录下

location /dir/
{
if (!-f $request_filename){
       set $rule_0 1$rule_0;
}
if (!-d $request_filename){
       set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
    rewrite ^/dir/([0-9A-Za-z]+)/?$ /url/yourls-go.php?id=$1 last;
}
    rewrite ^/dir/([0-9A-Za-z]+)\+/?$ /url/yourls-infos.php?id=$1 last;
    rewrite ^/dir/([0-9A-Za-z]+)\+all/?$ /url/yourls-infos.php?id=$1&all=1 last;
}
Tags: , , ,
Mar 11
WordPress

location / {
  if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
  }
  if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
  }
  if (!-f $request_filename){
    rewrite (.*) /index.php;
  }
}

WordPress Mu

location /{
  server_name_in_redirect off;
  port_in_redirect off;

  rewrite ^.*/files/(.*) /wp-includes/ms-files.php?file=$1;
  rewrite ^/files/(.+) /wp-includes/ms-files.php?file=$1;

  if (!-e $request_filename) {
  rewrite ^.+?(/wp-.*) $1 last;
  rewrite ^.+?(/.*\.php)$ $1 last;
  rewrite ^ /index.php last;
  }
}

Drupal

location / {
  if (!-e $request_filename) {
    rewrite ^/(.*)$ /index.php?q=$1 last;
  }
}

Twip

location /{
  if (!-e $request_filename){
    rewrite ^/(.*)$ /index.php last;
  }
}

Typecho

location / {
  index index.html index.php;
  if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
  }
  if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
  }
  if (!-f $request_filename){
    rewrite (.*) /index.php;
  }
}

Discuz

location / {
  rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
  rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;
  rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page%3D$3&page=$2 last;
  rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;
  rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
}

Discuz X

location / {
  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 ^([^\.]*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;
  if (!-e $request_filename) {
    return 404;
  }
}

Dabr

location / {
  if (!-e $request_filename) {
    rewrite ^/(.*)$ /index.php?q=$1 last;
  }
}

SaBlog

location / {
  rewrite “^/date/([0-9]{6})/?([0-9]+)?/?$” /index.php?action=article&setdate=$1&page=$2 last;
  rewrite ^/page/([0-9]+)?/?$ /index.php?action=article&page=$1 last;
  rewrite ^/category/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&cid=$1&page=$2 last;
  rewrite ^/category/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&curl=$1&page=$2 last;
  rewrite ^/(archives|search|article|links)/?$ /index.php?action=$1 last;
  rewrite ^/(comments|tagslist|trackbacks|article)/?([0-9]+)?/?$ /index.php?action=$1&page=$2 last;
  rewrite ^/tag/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&item=$1&page=$2 last;
  rewrite ^/archives/([0-9]+)/?([0-9]+)?/?$ /index.php?action=show&id=$1&page=$2 last;
  rewrite ^/rss/([^/]+)/?$ /rss.php?url=$1 last;
  rewrite ^/user/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&user=$1&page=$2 last;
  rewrite sitemap.xml sitemap.php last;
  rewrite ^(.*)/([0-9a-zA-Z\-\_]+)/?([0-9]+)?/?$ $1/index.php?action=show&alias=$2&page=$3 last;
        }

Xnote

location / {
  if (!-e $request_filename) {
    rewrite "^/([A-Za-z0-9\-]{4,20})$" /index.php?url=$1 last;
  }
}

Status.net

location / {
  if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
  }
  if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
  }
  if (!-f $request_filename){
    rewrite (.*) /index.php;
  }
}

PHP-Wind

location / {
rewrite ^thread-htm-tid-(\d+)-(.*).html  thread.php?fid=$1 last;
rewrite ^read-htm-tid-(\d+)-(.*).html  read.php?tid=$1 last;
rewrite ^commtopics-(.*)-(.*)  thread.php?fid=$1&page=$2 last;
rewrite ^commtopics-(.*)       thread.php?fid=$1&page=$2 last;
rewrite ^article-(.*)-(.*)-(.*).html  read.php?tid=$1&page=$2&fpage=$3 last;
rewrite ^article-(.*)-(.*).html       read.php?tid=$1&page=$2&fpage=$3 last;
rewrite ^article-(.*).html            read.php?tid=$1 last;
rewrite ^read-htm-tid-(\d+)-(.*).html  read.php\?tid=$1 last;
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
rewrite ^(.*)/u/([0-9]+)$ $1/u.php?uid=$2 last;
}

Bo-Blog

location / {
   if (!-e $request_filename)
   {
      rewrite ^/post/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?entryid=$1&page=$2&part=$3 last;
      rewrite ^/page/([0-9]+)/([0-9]+)/?$ /index.php?mode=$1&page=$2 last;
      rewrite ^/starred/([0-9]+)/?([0-9]+)?/?$ /star.php?mode=$1&page=$2 last;
      rewrite ^/category/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=category_$1&mode=$2&page=$3 last;
      rewrite ^/archiver/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=archive&cm=$1&cy=$2&mode=$3&page=$4 last;
      rewrite ^/date/([0-9]+)/([0-9]+)/([0-9]+)/?([0-9]+)?/?([0-9]+)?/?$ /index.php?go=showday_$1-$2-$3&mode=$4&page=$5 last;
      rewrite ^/user/([0-9]+)/?$ /view.php?go=user_$1 last;
      rewrite ^/tags/([^/]+)/?([0-9]+)?/?([0-9]+)?/?$ /tag.php?tag=$1&mode=$2&page=$3 last;
      rewrite ^/component/id/([0-9]+)/?$ /page.php?pageid=$1 last;
      rewrite ^/component/([^/]+)/?$ /page.php?pagealias=$1 last;

      #Force redirection for old rules
      rewrite ^/read\.php/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
      rewrite ^/post/([0-9]+)\.htm$ http://$host/post/$1/ permanent;
      rewrite ^/post/([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/ permanent;
      rewrite ^/post/([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/post/$1/$2/$3/ permanent;
      rewrite ^/index\_([0-9]+)\_([0-9]+)\.htm$ http://$host/page/$1/$2/ permanent;
      rewrite ^/star\_([0-9]+)\_([0-9]+)\.htm$ http://$host/starred/$1/$2/ permanent;
      rewrite ^/category\_([0-9]+)\.htm$ http://$host/category/$1/ permanent;
      rewrite ^/category\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/category/$1/$2/$3/ permanent;
      rewrite ^/archive\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/ permanent;
      rewrite ^/archive\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/archiver/$1/$2/$3/$4/ permanent;
      rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/ permanent;
      rewrite ^/showday\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\_([0-9]+)\.htm$ http://$host/date/$1/$2/$3/$4/$5/ permanent;

      #Filename alias
      rewrite ^/([a-zA-Z0-9_-]+)/?([0-9]+)?/?([0-9]+)?/?$ /read.php?blogalias=$1&page=$2&part=$3 last;
   }
}
Tags: ,
Mar 8
OWS是免费开源的运维管理平台,今天拿一台机器安装测试了下,功能上做的不错,只是还不够成熟。感兴趣的可以安装体验下,安装OWS的前提是你已经安装编译好了PHP+MYSQL环境。
一、下载源码文件

wget http://damo.openwebsa.org/down/ows_damo_v1.0.2_3.tar.gz
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c10.tar.gz#md5=30f822f19b02c3082cb1ba1d69be35dd
wget http://cdnetworks-kr-1.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2

二、编译安装

解压OWS文件并移到/usr/local/ows目录
# tar xvf ows_damo_v1.0.2_3.tar.gz
#mv ows /usr/local/ows
#chown -R nobody:nobody /usr/local/ows
#chmod 755 -R /usr/local/ows/unctrlsh/*

安装Python
#tar xvf Python-2.7.2.tgz
#cd Python-2.7.2
#./configure --prefix=/usr/local/ows/python
#make && make install
#/usr/local/ows/python/bin/python -V
Python 2.7.2

安装setuptools
#tar xzvf setuptools-0.6c10.tar.gz
#cd setuptools-0.6c10
#/usr/local/ows/python/bin/python setup.py build
#/usr/local/ows/python/bin/python setup.py install

安装MySQL-python
#which mysql_config
#tar xvf MySQL-python-1.2.3.tar.gz
#cd MySQL-python-1.2.3
#/usr/local/ows/python/bin/python setup.py build
#/usr/local/ows/python/bin/python setup.py install


三、创建数据库和导入数据库表

mysql>create database 数据库名 default charset utf8;
mysql>grant all privileges on 数据库名.* to 数据库用户名@127.0.0.1 identified by '数据库用户密码';
mysql>flush privileges;

数据库用户的权限可以只给:create,drop,delete,insert,update,select,lock tables。
然后导入数据库
#mysql -u数据库用户名 -p数据库用户密码 数据库名 < /usr/local/ows/openwebsa.sql
数据库导入之后需要修改ows数据库配置文件,一共需要修改两处
/usr/local/ows/ctrlphp/etc/ows_config.inc.php
/usr/local/ows/ctrlpy/etc/config.py

四、配置WEB页面
不管你用的是哪种支持PHP的WEB服务器软件,指定网站的目录为/usr/local/ows/ctrlphp就可以了,下面以APACHE别名的方式为例,打开apache的httpd.conf配置文件,添加如下内容:

Alias /ows /usr/local/ows/ctrlphp
<Directory "/usr/local/ows/ctrlphp">
    Options +SymLinksIfOwnerMatch
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

保存之后,重新启动apache

五、启动相关服务
启动服务端
#cd /usr/local/ows/ctrlpy/
#chmod 755 ows_service.sh
#./ows_service.sh start
启动客户端
#cd /usr/local/ows/unctrlpy/
#chmod 755 ows_service.sh
#./ows_service.sh start
查看进程是否运行
# ps aux | grep py
查看监听端口
# netstat -tulnp | grep py
使用浏览器打开 http://ip/ows 登陆web管理平台
默认的账号:openwebsa  密码:openwebsa
进去之后别忘记修改密码,官方的演示地址是:http://damo.openwebsa.org 感兴趣的朋友可以进去看看,此管理平台目前来看还不是很完善,大家测出问题可以向官方反馈,以便程序尽快完善。
Tags: ,
Mar 5
一、下载需要的文件
wget http://labs.renren.com/apache-mirror//httpd/httpd-2.4.1.tar.gz
wget http://apache.etoak.com//apr/apr-1.4.6.tar.gz
wget http://apache.etoak.com//apr/apr-util-1.4.1.tar.gz


二、编译软件
tar xzvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install
cd ..

tar xzvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
cd ..

tar xzvf httpd-2.4.1.tar.gz
cd httpd-2.4.1/
./configure --prefix=/usr/local/webserver/apache --enable-so --enable-modules=all --enable-mods-shared=all --enable-vhost-alias --enable-deflate --enable-expires --enable-rewrite --enable-authn-dbm=shared --enable-ssl --with-ssl --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
make && make install

Apache HTTP Server项目团队称,这是最新的、也是最好的一个版本,添加了许多新的模块,扩展了现有的功能,增强了灵活性。众多的性能及功能改进,使得该版本更适合日益流行的云环境。

该版本的主要改进包括:

改善了服务器性能(减少了资源利用,增强了并发能力)
支持异步I/O
动态反向代理配置
比纯事件驱动的Web服务器的性能更好
更精准的超时和资源利用限制能力
增强了微调缓存支持,专为高流量服务器和代理服务器打造
分页: 5/28 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]