close
文章出處
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
不含病毒。www.avast.com |
全站熱搜
留言列表