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