标签:poll ssh end select start djang rom 0.0.0.0 title
# wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
#tar zvxf 1.5.5.tar.gz #cd pip-1.5.5/
# python setup.py install
#pip3 install django # 我使用的是python3所以用pip3安装
# python3 # import django
[root@VM_0_3_centos /]# django-admin.py startproject project_name [root@VM_0_3_centos /]# cd ./project_name [root@VM_0_3_centos project_name]# ls manage.py project_name #
project_name/project_name目录下的文件
_init_.py是python包的目录必须的
settings.py是项目的设置
urls.py是项目的url配置文件
wsgi.py是部署服务器时用到的文件
[root@VM_0_3_centos project_name]# python3 manage.py startapp apptest [root@VM_0_3_centos project_name]# ls apptest manage.py project_name
[root@VM_0_3_centos apptest]# vim views.py [root@VM_0_3_centos apptest]# ls admin.py apps.py __init__.py migrations models.py tests.py views.py
#coding:utf-8 from django.http import HttpResponse def index(request): return HttpResponse(u"欢迎!")
[root@VM_0_3_centos project_name]# cd ./project_name/ [root@VM_0_3_centos project_name]# ls __init__.py __pycache__ settings.py urls.py wsgi.py [root@VM_0_3_centos project_name]# vim urls.py
[root@VM_0_3_centos project_name]# vim settings.py
[root@VM_0_3_centos project_name]# cd - /project_name [root@VM_0_3_centos project_name]# ls apptest manage.py project_name [root@VM_0_3_centos project_name]# python3 manage.py runserver 118.25.60.11:8000
静态小文件(1M),支持高并发,同时占用系统资源很少。3W并发,10个进程,内存150M。
配置简单,灵活,轻量。
高并发(静态小文件),静态几万的并发。
占用资源少。2W并发 开10个线程服务,内存消耗几百M。
功能种类较多(Web,cache,proxy),每一个功能都不是特别强。
支持epoll模型,使得Nginx可以支持高并发!apache(select模型)。
Nginx可以配合动态服务(FASTCGI接口)
利用nginx可以对IP限速,可以限制连接数。
1 [root@Web-lnmp02 ~]# useradd nginx -s /sbin/nologin -M ##禁止用户用于ssh登录,且不创建家目录 2 [root@Web-lnmp02 ~]# id nginx 3 uid=501(nginx) gid=501(nginx) groups=501(nginx) 4 [root@Web-lnmp02 ~]#
1 [root@Web-lnmp02 tools]# rpm -qa pcre pcre-devel 2 pcre-7.8-7.el6.x86_64 3 [root@Web-lnmp02 tools]# yum install -y pcre pcre-devel 4 Loaded plugins: fastestmirror, security 5 Setting up Install Process 6 Loading mirror speeds from cached hostfile 7 * base: mirrors.sina.cn 8 * extras: mirrors.opencas.cn 9 * updates: centos.ustc.edu.cn 10 Package pcre-7.8-7.el6.x86_64 already installed and latest version 11 Resolving Dependencies 12 --> Running transaction check 13 ---> Package pcre-devel.x86_64 0:7.8-7.el6 will be installed 14 --> Finished Dependency Resolution 15 16 Dependencies Resolved 17 18 ================================================================================ 19 Package Arch Version Repository Size 20 ================================================================================ 21 Installing: 22 pcre-devel x86_64 7.8-7.el6 base 320 k 23 24 Transaction Summary 25 ================================================================================ 26 Install 1 Package(s) 27 28 Total download size: 320 k 29 Installed size: 957 k 30 Downloading Packages: 31 pcre-devel-7.8-7.el6.x86_64.rpm | 320 kB 00:00 32 Running rpm_check_debug 33 Running Transaction Test 34 Transaction Test Succeeded 35 Running Transaction 36 Installing : pcre-devel-7.8-7.el6.x86_64 1/1 37 Verifying : pcre-devel-7.8-7.el6.x86_64 1/1 38 39 Installed: 40 pcre-devel.x86_64 0:7.8-7.el6 41 [root@Web-lnmp02 tools]# rpm -qa pcre pcre-devel 42 pcre-7.8-7.el6.x86_64 43 pcre-devel-7.8-7.el6.x86_64
1 [root@Web-lnmp02 ~]# yum install -y openssl-devel 2 [root@Web-lnmp02 ~]# rpm -qa|grep openssl 3 openssl-1.0.1e-42.el6_7.2.x86_64 4 openssl-devel-1.0.1e-42.el6_7.2.x86_64 5 openssl098e-0.9.8e-18.el6_5.2.x86_64
1 [root@Web-lnmp02 tools]# wget http://nginx.org/download/nginx-1.6.3.tar.gz 2 --2015-11-28 20:50:36-- http://nginx.org/download/nginx-1.6.3.tar.gz 3 4 [root@Web-lnmp02 tools]# ll 5 total 788 6 -rw-r--r--. 1 root root 805253 Apr 8 2015 nginx-1.6.3.tar.gz 7 [root@Web-lnmp02 tools]# tar xf nginx-1.6.3.tar.gz ##解压 8 [root@Web-lnmp02 tools]# ll 9 total 792 10 drwxr-xr-x. 8 1001 1001 4096 Apr 7 2015 nginx-1.6.3 11 -rw-r--r--. 1 root root 805253 Apr 8 2015 nginx-1.6.3.tar.gz 12 [root@Web-lnmp02 tools]#
1 [root@Web-lnmp02 tools]# cd nginx-1.6.3 2 [root@Web-lnmp02 nginx-1.6.3]# ls -lk 3 total 624 4 drwxr-xr-x. 6 1001 1001 4 Nov 28 20:52 auto 5 -rw-r--r--. 1 1001 1001 232 Apr 7 2015 CHANGES 6 -rw-r--r--. 1 1001 1001 353 Apr 7 2015 CHANGES.ru 7 drwxr-xr-x. 2 1001 1001 4 Nov 28 20:52 conf 8 -rwxr-xr-x. 1 1001 1001 3 Apr 7 2015 configure 9 drwxr-xr-x. 4 1001 1001 4 Nov 28 20:52 contrib 10 drwxr-xr-x. 2 1001 1001 4 Nov 28 20:52 html 11 -rw-r--r--. 1 1001 1001 2 Apr 7 2015 LICENSE 12 drwxr-xr-x. 2 1001 1001 4 Nov 28 20:52 man 13 -rw-r--r--. 1 1001 1001 1 Apr 7 2015 README 14 drwxr-xr-x. 8 1001 1001 4 Nov 28 20:52 src 15 [root@Web-lnmp02 nginx-1.6.3]# ./configure --prefix=/application/nginx-1.6.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module 16 [root@Web-lnmp02 nginx-1.6.3]# make && make install ##编译
参数简单说明:
--prefix=PATH 设置安装路径
--user=USER 进程用户权限
--group=GROUP 进程用户组权限
--with-http_ssl_module 激活ssl功能
--with-http_stub_status_module 激活状态信息
1 [root@Web-lnmp02 nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx 2 [root@Web-lnmp02 nginx-1.6.3]# ls -l /application/ 3 total 4 4 lrwxrwxrwx. 1 root root 25 Nov 28 21:18 nginx -> /application/nginx-1.6.3/ 5 drwxr-xr-x. 6 root root 4096 Nov 28 21:09 nginx-1.6.3 6 [root@Web-lnmp02 nginx-1.6.3]# cd nginx 7 -bash: cd: nginx: No such file or directory 8 [root@Web-lnmp02 nginx-1.6.3]# cd /application/nginx 9 [root@Web-lnmp02 nginx]# ll 10 total 16 11 drwxr-xr-x. 2 root root 4096 Nov 28 21:09 conf 12 drwxr-xr-x. 2 root root 4096 Nov 28 21:09 html 13 drwxr-xr-x. 2 root root 4096 Nov 28 21:09 logs 14 drwxr-xr-x. 2 root root 4096 Nov 28 21:09 sbin
1 [root@Web-lnmp02 nginx]# /application/nginx/sbin/nginx ##启动Nginx服务 2 [root@Web-lnmp02 nginx]# lsof -i :80 3 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 4 nginx 5027 root 6u IPv4 23623 0t0 TCP *:http (LISTEN) 5 nginx 5028 nginx 6u IPv4 23623 0t0 TCP *:http (LISTEN) 6 [root@Web-lnmp02 nginx]# netstat -lntup|grep nginx|grep -v grep 7 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5027/nginx
标签:poll ssh end select start djang rom 0.0.0.0 title
原文地址:https://www.cnblogs.com/Dream-huang/p/9501207.html