2010年06月29日 星期二 14:55
FreeBSD安装实在没啥说的,都是ports安装make install
#安装
vodtest# cd /usr/ports/www/nginx-devel/ && make install clean
#安装Python
vodtest# cd /usr/ports/lang/python25 && make install clean
#安装flup
vodtest# cd /usr/ports/www/py-flup && make install clean
#安装Django
vodtest# cd /usr/ports/www/py-django && make install clean
#安装PostgreSQL数据库
vodtest# cd /usr/ports/databases/postgresql84-server && make install clean
#安装PostgreSQL客户端
vodtest# cd /usr/ports/databases/postgresql84-client && make install clean
#安装PostgreSQL-Python库
vodtest# cd /usr/ports/databases/py-psycopg2/ && make install clean
2010年06月29日 星期二 14:58
配置Nginx
vodtest# /usr/local/etc/rc.d/nginx
Usage: /usr/local/etc/rc.d/nginx [fast|force|one](start|stop|restart|rcvar|reload|configtest|upgrade|gracefulstop|status|poll)
vodtest# ee /etc/rc.conf
nginx_enable="YES"
#配置文件
vodtest# ee /usr/local/etc/nginx/nginx.conf
worker_processes 5;
pid /var/run/nginx.pid;
error_log /var/log/nginx-error.log error;
events {
worker_connections 10240;
use kqueue;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
keepalive_timeout 75 20;
tcp_nodelay on;
client_max_body_size 10m;
client_body_buffer_size 256k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
client_body_temp_path /var/log/nginx/client_body_temp;
proxy_temp_path /var/log/nginx/proxy_temp;
fastcgi_temp_path /var/log/nginx/fastcgi_temp;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript text/xml text/css;
ignore_invalid_headers on;
include website.conf;
}
listen 80;
server_name vod.test.net;
access_log /var/log/nginx-vod-access.log main;
location / {
# host and port to fastcgi server
fastcgi_pass unix:/home/test/trunk/products/vod/myapp.sock;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
}
location ^~ /media/ {
alias /usr/local/lib/python2.5/site-packages/django/contrib/admin/media/;
}
#location ~* ^.+\.(gif|png|jpg|jpeg|css|swf|htm|html|asp|php|jsp|js|doc|txt)$ {
location ^~ /mymedia/ {
alias /usr/home/test/trunk/products/vod/mymedia/;
access_log off;
}
}
2010年06月29日 星期二 15:00
顶!!!!!
2010年06月29日 星期二 15:00
配置Django
#coding=utf-8
import os,sys
webapps = {
'vod':'/home/test/trunk/products/vod/',
}
def startapp(app):
#todo 检查是否已运行
appdir = webapps[app]
apppid = appdir + 'myapp.pid'
appsock = appdir + 'myapp.sock'
cmd_start = """
/usr/local/bin/python %s/manage.py runfcgi method=prefork \
socket=%s pidfile=%s minspare=5 maxspare=10 maxchildren=40
"""%(appdir,appsock,apppid)
if os.system(cmd_start) == 0:
print "%s start cmd run ok" % app
else:
print "%s start cmd run no" % app
def stopapp(app):
#todo 检查是否已运行
appdir = webapps[app]
apppid = appdir + 'myapp.pid'
appsock = appdir + 'myapp.sock'
cmd_stop = """
cat %s|xargs kill -9
"""%(apppid)
if os.system(cmd_stop) == 0:
print "%s stop cmd run ok" % app
else:
print "%s stop cmd run no" % app
def restartapp(app):
stopapp(app)
startapp(app)
def main():
try:
sys.argv[1]
sys.argv[2]
except:
print 'You need to input two opention. \n etc:[start|stop|restart] yourapp'
sys.exit()
if sys.argv[2] not in webapps.keys():
print 'Your app not in My manager'
sys.exit()
if sys.argv[1] == 'start':
startapp(sys.argv[2])
elif sys.argv[1] == 'stop':
stopapp(sys.argv[2])
elif sys.argv[1] == 'restart':
restartapp(sys.argv[2])
else:
print 'You have a bad cmd. \n etc:[start|stop|restart]'
if __name__ == "__main__":
main()
2010年06月29日 星期二 15:01
配置PostgreSQL数据库
postgresql_enable="YES"
vodtest# /usr/local/etc/rc.d/postgresql initdb
vodtest# /usr/local/etc/rc.d/postgresql
Usage: /usr/local/etc/rc.d/postgresql [fast|force|one](start|stop|restart|rcvar|reload|initdb|status|poll)
#首先创建一个超级用户
# su -l pgsql
$ createuser -P //dropuser
Enter name of role to add: alex
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) y
CREATE ROLE
vodtest# ee /usr/local/pgsql/data/postgresql.conf
# listen_addresses = '*'
vodtest# ee /usr/local/pgsql/data/pg_hba.conf
local all pgsql trust
local all all md5
host all all 127.0.0.1/32 md5
host all all 202.204.100.1 255.255.255.0 md5
host all all 202.204.101.1 255.255.255.0 md5
2010年06月29日 星期二 15:02
图片库支持
2013年01月31日 星期四 22:37
"配置Django
2013年04月09日 星期二 00:12
还真是好久不来被我看到了。。。
这个脚本放在随便目录随便名字就行,因为配置用了绝对路径
现在都用uwsgi了,搜一下那个吧
Zeuux © 2024
京ICP备05028076号