Apache+django++mod_wsgi (Ubuntu under Virtual machine mode deployment process)

Source: Internet
Author: User
Tags install django pip install django

A few days ago the source of the deployment of the Apache+mod_wsgi+django project, see my other blog

These days also used Apt-get way to install Apache, installed a deployment, where there is a consistent place, there are differences, and then this record

Environment Ubuntu 16.04 +apache2.4.25 +django1.8+mod_wsgi-4.5.15+python2.7

Apache and Python2.7 are installed in Apt-get install mode.

django1.8 is installed in pip install django==1.8 mode.

mod_wsgi-4.5.15 is required to download the source code to compile the installation

Apache source code and APT way to install the difference is the directory structure is not the same, the configuration file loading method is not the same, the source of the way, all things in a piece, the configuration file is mainly httpd.conf, start the program is in the bin,

Such as

[Email protected]:/usr/local/apache24$ ls
bin Cgi-bin Error icons logs manual
build conf htdocs include man modules
[Email protected]:/usr/local/apache24$
[Email protected]:/usr/local/apache24$ tree-l 1
.
├──bin------------------Program Directory
├──build
├──cgi-bin
├──conf-------------configuration file directory, mainly httpd.conf
├──error
├──htdocs
├──icons
├──include
├──logs-------------------Log directory
├──man
├──manual
└──modules------------------Module Catalog

It's all in one piece anyway!

The APT approach is distributed in various directories.

[Email protected]:/tmp# whereis apache2
Apache2:/usr/sbin/apache2/usr/lib/apache2/etc/apache2/usr/include/apache2/usr/share/apache2/usr/share/man/man8 /apache2.8.gz
/usr/sbin/apache2 and/usr/sbin/apache2ctl to execute a file

[Email protected]:/tmp# ls/usr/lib/apache2as a module directory, the subsequent wsgi.so will be generated to this
Modules
[Email protected]:/tmp# ls/etc/apache2---Home directory, the main configuration is in this
Apache2.confconf-enabledMagicmods-enabled sites-available
conf-availableEnvvarsmods-availablePorts.confsites-enabled

Ls/usr/share/apache2some of the other papers in this
Apache2-maintscript-helper Ask-for-passphraseBuild default-site Error Icons

And there's the project directory./var/www/htmlThere's a index.html in here.

The log directory is under /var/log/apache2/ , and access logs and error logs are in this

The first step, put the project on the server, I put to /var/www/below for convenience, my project is Mysit

Then change the wsgi.py file, need to add a project path, Sys.path.append ("/var/www/mysit")

Step two, change the Apache configuration file

Need to do 2 work, one is to install MOD_WSGI, source installation, installation to meet the installation conditions, need to Apache-dev, can refer to the official installation instructions

If the condition is met, the installation is ready, and the command is./coungure make makes install these 3 steps, after installation, look at the/usr/lib/apache2/modules directory has wsgi.so!

Then add config file/etc/apache2/mods-available directory to build the configuration file of the loading module

Wsgi.load

#如下一行
LoadModule wsgi_module/usr/lib/apache2/modules/mod_wsgi.so

You can then use the A2enmod command to see the Wsgi module. When the name is entered, it is enabled.

Then modify the/etc/apache2/sites-enabled/000-default.conf (I will use this default, you can also build one myself, the same format can be)

Join

Documentroot/var/www/mysit
Wsgiscriptalias//var/www/mysit/mysit/wsgi.py

Alias/static/var/www/mysit/static (if you still have audio, video, please add the relevant directory)

<Directory/mysit/>
Options Indexes followsymlinks execcgi
allowoverride None
Require all granted
<files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory/static/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
<files *.jpg>
Require all granted
</Files>
</Directory>
<Directory/static/style/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
<files pkq.gif>
Require all granted
</Files>
</Directory>

Add some directory access right here

Then use the A2ensite command to enable-。。。。。。 This site is on the line.

Then open the access rights of Port 80, then start the Apache service, access is ready!

Envvars Configuring the system environment variables related parameters

At present I have the following problems:

Admin Page Login exit and other write database operations, the system will report abnormal, online meters have found the admin post

Setting configuration Debug=false, external access not!

Apache Service log packing log compression every day 6:25:01, it happens that the Apache service will do a reboot at this time, but where to control the packaging of the log, I did not find, and I am not sure restart is not the system to do

Above questions if has the expert to know, the hope pointing out, thanks

My project has half a time, the website is http://60.205.221.253/welcome visit

Apache+django++mod_wsgi (Ubuntu under Virtual machine mode deployment process)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.