(In general, if you look at how to write httpd.conf at the bottom, it should be a trigger ...)
Assuming you're using the python module django, there are probably several ways to implement the real-time Web, but there aren't many when it comes to taking advantage of those prerequisites (= can be used as an extension of the python module or Django). What comes out after a light examination
Around.
At that time, it was updated more than channels, and I chose swampdragon because it has more Japanese documents (examples of use) than swampdragon (although both are few).
Currently (16/12/29) it seems that the update of the official website has already stopped, but at that time (16/07 / xx) I chose that (although the official website was closed at that time) .. As a result, I will summarize the process of deploying with difficulty.
In addition, the module installation procedure is omitted, and the story is all about what was installed and how it was set.
The development environment of the application you want to deploy is
In addition, the following was introduced as a module.
The deployment destination is CentOS 7, which is set up on AWS and has no initial settings. Since it is clean, I had to enter it from apache for the time being.
Create a foundation for running web applications on CentOS7. This time we will introduce the following.
If both are the latest, there is no problem (should). By the way, mod_wsgi is also introduced to prepare the wsgi environment.
In addition, since the version of Python that was included in CentOS 7 was 2.7, I installed Python 3.5.1 so that it can be used with commands of the form python3.5
.
Also, if you install redis without thinking about it, only 2.8 and earlier versions will be included, so I referred to here and installed it directly.
That's the main subject of deployment.
The application I wanted to deploy was placed on github, so I cloned it to the following directory and placed it.
/var/www/cgi-bin/
The location is like the default setting of apache.
After that, without thinking about anything in particular, modify httpd.conf according to Official document of different version.
However, this alone does not work.
In order to realize the real-time Web, it was necessary to route swampdragon to the server and start the redis server.
This time, the following four servers need to run on CentOS.
Of these, the former two can be started from the following commands.
systemctl start httpd
systemctl start postgresql
It runs in the background, so you won't be overwhelmed by the console.
The problem is the latter two. django itself runs on apache, but swampdragon introduced as its module needs to set up a server separately from django. And when redis also starts the server, other operations will not be possible.
Therefore, tmux was newly introduced. By simply introducing tmux and splitting the console, simultaneous startup is possible.
But the problem still remains. That's the routing from apache to the swampdragon server. I had a lot of trouble because I couldn't find any literature about this.
The contents of the final apache settings (httpd.conf) are as follows (the app path is blurred).
Listen 80
Listen 443
<VirtualHost *:443>
ProxyPass /data ws://127.0.0.1:9999/data
ProxyPassReverse /data ws://127.0.0.1:9999/data
ProxyPass /settings.js http://127.0.0.1:9999/settings.js
ProxyPassReverse /settings.js http://127.0.0.1:9999/settings.js
ProxyPreserveHost On
ProxyRequests Off
ProxyVia On
</VirtualHost>
LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so
WSGIPythonPath /var/www/cgi-bin/path/to/app:/usr/local/bin/python3.5/site-packages
DocumentRoot "/var/www/cgi-bin/path/to/documentroot"
Alias /static/ /var/www/cgi-bin/path/to/static/
<Directory /var/www/cgi-bin/path/to/app/>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
WSGIScriptAlias / /var/www/cgi-bin/path/to/wsgi.py
In addition, ~: //127.0.0.1:9999/~ is the default setting (should be) when swampdragon was introduced.
Below the Load Module in the lower half, it's almost exactly what the django official website says.
The liver is the setting of 443 ports. swampdragon has two communications to receive. /Data for websocket communication and /settings.js for http.
If you set it as a virtual host and transfer it to a separate swampdragon server, it will be thrown further to the redis server and session information will be saved.
Eventually, you should be able to launch a real-time web application with a command like this.
tmux
systemctl start postgresql
systemctl start httpd
sudo redis-server /etc/redis.conf
python3.5 server.py
When using swampdragon
The above is the story of the first manual deployment.
Recommended Posts