安装
(1)在线安装
$sudo apt-get install nginx
Nginx的版本是1.2.1
ubuntu安装Nginx之后的文件结构大致为:
所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下
启动程序文件在/usr/sbin/nginx
日志放在了/var/log/nginx中,分别是access.log和error.log
并已经在/etc/init.d/下创建了启动脚本nginx
默认的虚拟主机的目录设置在了/usr/share/nginx/www
(2)源码安装也比较简单,所有文件默认放到/usr/local/nginx目录,也可以自己指定位置
启动
(1)在线安装的启动过程
$sudo /etc/init.d/nginx start #或者下面
sudo service nginx start
(2)源代码安装的启动过程
$cd /usr/local/nginx
$sbin/nginx
虚拟主机
(1)在site-ennable下面创建文件ubuntu.nobsu.net.conf文件,编辑如下:
server {
listen 80;
server_name ubuntu.nobsu.net;
index index.html index.htm index.php;
root /data/www/ubuntu_nobsu_net;
log_format ubuntu.nobsu.net '$remote_addr - $remote_user [$time_local] $request'
'$status $body_bytes_sent $http_referer '
'$http_user_agent $http_x_forwarded_for';
access_log /data/log/ubuntu.nobsu.net.log ubuntu.nobsu.net;
}
(2)创建可访问目录
/data/www/ubuntu_nobsu_net/index.html
hello nginx!!
(3)编辑测试域名:
具体过程如下:
1、修改hosts
sudo gedit /etc/hosts
2、添加解析记录( . )
完整案例:127.0.0.1 localhost.localdomain localhost
简洁记录:127.0.0.1 localhost
3、保存后重启网络
sudo /etc/init.d/networking restart
(4)访问:http://ubuntu.nobsu.net/
ok
uwsgi部署python web项目
命令启动:
uwsgi --http :9090 --wsgi-file foobar.py
ini文件方式,创建ini文件:
[uwsgi]
socket = 127.0.0.1:3031
chdir = /data/www/yiqiwanshua-py/
wsgi-file = WSGI.py
processes = 2
threads = 1
stats = 127.0.0.1:9191
前台启动:
uwsgi uwsgi.ini
后台启动:
uwsgi /app/dataservice/uwsgi.ini -d /app/dataservice/uwsgi.log
看官方文档,很简单:http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html
[参考文献]
http://www.cnblogs.com/languoliang/archive/2013/04/01/nginx.html 安装
http://www.neoease.com/nginx-virtual-host/ 虚拟主机配置
来源:oschina
链接:https://my.oschina.net/u/782574/blog/337189