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

最新文章

  1. html 设置宽度100% 块状元素往下调解决方法
  2. DP专题训练之HDU 1864 最大报销额
  3. 多节点 devstack 部署
  4. ( 转)基于.NET平台常用的框架整理
  5. Fix Elementary Boot Screen (plymouth) After Installing Nvidia Drivers
  6. nginx使用openssl的证书-泛解析
  7. centos vsftpd 553 Could not create file解决方法
  8. abap function module中的异常处理
  9. RecyclerView 输出的和排版的不一样
  10. 02 - nginx - 反向代理、限速
  11. linux系统安装 dig和nslookup命令
  12. Linux下MySQL主从同步故障:"Slave_SQL_Running:No"的解决方法
  13. 用 PHPMailer 发送邮件
  14. 【OCP题库】最新CUUG OCP 12c 071考试题库(68题)
  15. PHP_GET后门,躲避任何安全软件
  16. Codeforces Round #406 (Div. 2)滚粗记
  17. LightOJ 1074 Extended Traffic(spfa+dfs标记负环上的点)
  18. putty自带工具plink自动登陆ssh
  19. Windows Update error 80070003
  20. 第9章 HBase操作

热门文章

  1. npm下载速度太慢
  2. 好文推荐系列---------JS模板引擎
  3. 导致人生失败的31种原因(转自csdn博客)
  4. WPF 图片显示中的保留字符问题
  5. [转]Android开发:Parallax效果的ScrollerView,改编自ParallaxListView
  6. java异常处理机制
  7. STM32的DMA
  8. Yii2中的入口文件环境配置
  9. TclError: no display name and no $DISPLAY environment variable
  10. js for 循环中的 变量问题。