ubuntu下在apache部署python站点

我的是ubuntu14 32为的虚拟机,默认安装的python为3.4

环境:apache + mysql + django + python3

软件安装

#apache
sudo apt-get install apache2 #wsgi Python2
sudo apt-get install libapache2-mod-wsgi #wsgi python3
sudo apt-get install libapache2-mod-wsgi-py3 #mysql
sudo apt-get install mysql-server mysql-client #pip的安装有多种方式 #pip - 方法一
1. 官网下载 get-pip.py
2. python3 get-pip.py3 #pip - 方法二
#python2
sudo apt-get install python-pip
#python3
sudo apt-get install python3-pip #python3下使用pip3
pip3 install pymysql
pip3 install django==1.9
pip3 install virturlenv #python2
#mysql driver for python
pip install pymysql
pip install django==1.9
pip install virtualenv

辅助工具的安装

修改配置文件用到编辑器,看喜好

#vim
sudo apt-get install vim #sublime text
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

create django web project

you need to know where you have installed dhango to

as we need to use the django-admin.py to startproject

Note

mark@ubuntu:~$ pip3 install django==1.9
Requirement already satisfied (use --upgrade to upgrade): django==1.9 in /usr/local/lib/python3.4/dist-packages

start project and add new app

python3 /usr/local/lib/python3.4/dist-packages/django/bin/django-admin.py startproject mysite
cd mysite
python3 manage.py startapp demo
python3 manage.py runserver 8080 #Starting development server at http://127.0.0.1:8080/

apache网站的配置和部署

httpd.conf中配置需要监听的端口

listen 80
listen 8000

linux下多站点的配置

vhost.conf

<VirtualHost *:9090>
# ServerName www.example.com ServerAdmin webmaster@localhost
DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /static /home/ubuntu/wechat/static
<Directory /home/ubuntu/wechat/static>
Require all granted
</Directory> <Directory /home/ubuntu/wechat/wechat>
<Files wsgi.py>
Require all granted
</Files>
</Directory> WSGIDaemonProcess wechat python-path=/home/ubuntu/wechat:/home/ubuntu/wechat/env/lib/python3.4/site-packages
WSGIProcessGroup wechat
WSGIScriptAlias / /home/ubuntu/wechat/wechat/wsgi.py
</VirtualHost>

激活网站

sudo a2ensite mysite.conf

ubuntu下在apache部署python站点的更多相关文章

  1. 在ubuntu下配置apache运行python脚本

    2008-12-05    常用的简单命令 sudo apt-get remove --purge apache apache2 (彻底删除)   sudo /etc/init.d/apache2 r ...

  2. Ubuntu下配置Apache的Worker模式

    其实Apache本身的并发能力是足够强大的,但是Ubuntu默认安装的是Prefork模式下的Apache.所以导致很多人后面盲目的去 安装lighttpd或者nginx一类替代软件.但是这类软件有一 ...

  3. 转[开发环境配置]在Ubuntu下配置舒服的Python开发环境

    在Ubuntu下配置舒服的Python开发环境 Ubuntu 提供了一个良好的 Python 开发环境,但如果想使我们的开发效率最大化,还需要进行很多定制化的安装和配置.下面的是我们团队开发人员推荐的 ...

  4. Ubuntu下关闭apache和mysql的开机启动

    Ubuntu下关闭apache和mysql的开机启动 sudo apt-get install sysv-rc-conf sudo sysv-rc-conf sudo vi /etc/init/mys ...

  5. ubuntu下配置Apache

    ubuntu下配置Apache Apache的默认文档根目录是在Ubuntu上的/var/www目录 配置文件是/ etc/apache2/apache2.conf配置存储在的子目录在/etc/apa ...

  6. Ubuntu下使用crontab部署定时任务

    Ubuntu下使用crontab部署定时任务 安装cron apt-get install cron 开启crontab日志 默认情况下的日志是没有开启的,我们需要找到 /etc/rsyslog.d/ ...

  7. ubuntu 下搭建apache+python的运行环境

    ubuntu下怎么搭建apache+python运行环境,可以参考http://www.01happy.com/ubuntu-apache-mod-python/ ,这里只是简单的记录下步骤,本文主要 ...

  8. ubuntu下配置Apache+mod_wsgi+Django项目(个人测试)

    经过了一个星期的摸索,查找资料以及实验,我搭建的环境基本能用(还有就是Django后台的静态文件加载的问题) 这里面只是介绍一下我的过程,因为对应Apache还不是很熟练,特别是配置文件.只能供大家参 ...

  9. Ubuntu 下配置apache和APR

    软件环境:ubuntu14.04  虚拟机Vmware  软件:http://httpd.apache.org/  httpd-2.2.29.tar.gz  不需要单独下载APR. 1.解压apach ...

随机推荐

  1. Unity 4.x Asset Bundle 重名

    在 Unity 4.5.1f3中测试发现如下问题 两个不同文件下相同名字的资源打包成AssetBundle以后加载失败,提示错误  xxxxx can't be loaded because anot ...

  2. 42. Trapping Rain Water

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  3. js生成验证码并检验

    <html> <head> <title>验证码</title> <style type="text/css"> #co ...

  4. java.lang.RuntimeException: Method setUp in android.test.ApplicationTestCase not mocked. See http://g.co/androidstudio/not-mocked for details.

    解决: build.gradle里加入: android { testOptions { unitTests.returnDefaultValues = true } }

  5. centos/redhat安装mysql

    1.从http://dev.mysql.com/downloads/repo/ 下载对应的rpm文件,我的是版本7,所以下载:mysql-community-release-el7-5.noarch. ...

  6. quick cocos2d-x 入门---井字棋

    学习quick cocos2d-x 第二天 ,使用quick-x 做了一个井字棋游戏 . 我假设读者已经 http://wiki.quick-x.com/doku.php?id=zh_cn阅读了这个链 ...

  7. DSO动态加载PHP模块到Apache服务器

    PHP在Linux/Unix平台上经常与Apache搭配使用,在安装PHP时,有三种安装方式可供选择:静态模式.动态模式(DSO).CGI二进制模式. 由于易于维护和升级,我强烈建议以DSO方式安装P ...

  8. requirejs按需加载angularjs文件

    之前分享了一篇用ocLazyLoad实现按需加载angular js文件的博客.本来当时想会使用一种方法就行了.可最近刚好有时间,在网上查找了一下requirejs实现angular js文件按需加载 ...

  9. 基于SpringMVC的增删改查

    废话不多说,直接开始步骤! 1.创建一个Dynamic Web Project 2.在WEB-INF包下的lib文件夹中引入相关jar commons-logging-.jar jstl.jar sp ...

  10. IIS部署ASP.NET常见错误

    今天本地 IIS部署一个.NET Framework 3.5 项目,首先出现一个错误: 静态机制没有办法处理脚本 检查MIME没有问题,检查应用程序池版本,2.0, 果断改成 4.0. 运行之后新错误 ...