Os:ubuntu 14.04 LTC
服务器:阿里云
apache2配置( 在000-default.conf配置)
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin 794866972@qq.com
#`DocumentRoot /var/www/html/
DocumentRoot /var/www/html/Blog/
Alias /static /var/www/html/Blog/static
<Directory /var/www/html/Blog/static>
Require all granted
</Directory>
Alias /templates /var/www/html/Blog/templates
<Directory /var/www/html/Blog/templates>
Require all granted
</Directory>
<Directory /var/www/html/Blog/my_blog>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /var/www/html/Blog/my_blog/wsgi.py
<span style="white-space:pre"> </span># Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
sitename.conf
<VirtualHost *:80>
#ServerName www.yourdomain.com
#ServerAlias otherdomain.com
ServerAdmin 794866972@qq.com
#Alias /media/ /home/tu/blog/media/
#Alias /static/ /home/tu/blog/static/
<Directory /var/www/html/Blog/>
options All
Require all granted
AllowOverride All
</Directory>
# WSGIScriptAlias / /var/www/html/Blog/my_blog/wsgi.py
<Directory /var/www/html/Blog/my_blog/wsgi.py>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
django wsgi.py
"""
WSGI config for my_blog project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
import sys #添加路径
sys.path.append('/var/www/html/Blog/')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_blog.settings")
application = get_wsgi_application()
mysql 配置
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port<span style="white-space:pre"> </span>= 3306
socket<span style="white-space:pre"> </span>= /var/run/mysqld/mysqld.sock
#201601251303
default-character-set=utf8
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket<span style="white-space:pre"> </span>= /var/run/mysqld/mysqld.sock
nice<span style="white-space:pre"> </span>= 0
[mysqld]
#
# * Basic Settings
#
user<span style="white-space:pre"> </span>= mysql
pid-file<span style="white-space:pre"> </span>= /var/run/mysqld/mysqld.pid
socket<span style="white-space:pre"> </span>= /var/run/mysqld/mysqld.sock
port<span style="white-space:pre"> </span>= 3306
basedir<span style="white-space:pre"> </span>= /usr
datadir<span style="white-space:pre"> </span>= /var/lib/mysql
tmpdir<span style="white-space:pre"> </span>= /tmp
lc-messages-dir<span style="white-space:pre"> </span>= /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address<span style="white-space:pre"> </span>= 127.0.0.1
#
# * Fine Tuning
#
key_buffer<span style="white-space:pre"> </span>= 16M
max_allowed_packet<span style="white-space:pre"> </span>= 16M
thread_stack<span style="white-space:pre"> </span>= 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit<span style="white-space:pre"> </span>= 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries<span style="white-space:pre"> </span>= /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id<span style="white-space:pre"> </span>= 1
#log_bin<span style="white-space:pre"> </span>= /var/log/mysql/mysql-bin.log
expire_logs_days<span style="white-space:pre"> </span>= 10
max_binlog_size = 100M
#binlog_do_db<span style="white-space:pre"> </span>= include_database_name
#binlog_ignore_db<span style="white-space:pre"> </span>= include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
#20160125
character-set-server=utf8
init_connect='SET NAMES=utf8'
[mysqldump]
quick
quote-names
max_allowed_packet<span style="white-space:pre"> </span>= 16M
[mysql]
#no-auto-rehash<span style="white-space:pre"> </span># faster start of mysql but no tab completition
#20160125
default-character-set=utf8
[isamchk]
key_buffer<span style="white-space:pre"> </span>= 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
安装步骤(root)
1 apt-get install apache2
2 apt-get install mysql-server-5.5
3 apt-get python-dev python-pip libmysqld-dev
4 pip install MySQL-python Django==1.8
5 apt-get install libjpeg-dev
6 pip install Pillow
创建数据库
debug=False
设置allow-hosts
修改wsgi.py为上面的wsgi
修改apache2/site-available/000-default.conf 为上面的 000-default.conf
service apache2 reload