1.升级服务器,打上ubuntu 12的所有安全补丁

apt-get update apt-get upgrade

 

2.安装必要软件

apt-get install git mysql-server python-mysqldb python-pip nginx supervisor

 

3.在花屏界面设置mysql的root用户密码,直接输入输两次,也可以留空直接回车两次

 

4.安装django

pip install django -i http://pypi.douban.com/simple

 

5.创建数据库

CREATE DATABASE `数据库名称` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

 

6.进入网站的manage.py文件目录进行数据库同步

python manage.py syncdb

 

----------------配置python自动启动环境(相当于执行命令python manage.py runserver)----------------

7.安装python的运行环境

gunicorn pip install gunicorn

 

8.修改gunicorn配置

vim /etc/supervisor/conf.d/gunicorn.conf

将下面内容加入gunicorn.conf,之后按Esc再按:wq保存

[program:gunicorn] command = gunicorn ehivip_website.wsgi:application directory = /var/www/网站目录 autostart = true autorestart = true

 

9.重启服务让配置生效

supervisorctl reload

 

10.启动supervisord进程管理

supervisord

 

11.查看服务状态

supervisorctl status

 

----------------配置nginx,将本地端口映射到80----------------

12.修改nginx配置

vim /etc/nginx/sites-available/default

将下面内容加入配置

server {

        root /var/www;

        server_name localhost;

        location /static {

               root /var/www/网站目录/website;

        }

        location / {

               proxy_pass http://127.0.0.1:8000;

        }

}

 

13.重启nginx

service nginx restart

 

14.如果python代码有改启则重启

supervisorctl restart all

相关文章:

  • 2022-01-12
  • 2022-12-23
  • 2021-12-29
  • 2021-03-30
  • 2021-06-07
  • 2021-09-12
  • 2022-01-21
  • 2022-12-23
猜你喜欢
  • 2021-12-20
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-12-01
相关资源
相似解决方案