summaryrefslogtreecommitdiffstats
path: root/content/en/articles/git-setup-own-server-part2
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-28 19:19:47 +0200
committerDanilo M. <danix@danix.xyz>2026-04-28 19:19:47 +0200
commit63a000bb409f5c4fc3f304f16b05407364ca052e (patch)
tree1f4b1baa604e8ffb1683b08100f1ad6e463b45ca /content/en/articles/git-setup-own-server-part2
parentf7079a68895bd01bebebad97b3966d620904278c (diff)
downloaddanixxyz-63a000bb409f5c4fc3f304f16b05407364ca052e.tar.gz
danixxyz-63a000bb409f5c4fc3f304f16b05407364ca052e.zip
fix: convert remaining raw HTML to markdown and add acronym shortcodes
- myself-as-a-droid: drop external image figure, decode entities - poker-time: drop external image figure and orphan nbsp - le-email-queste-sconosciute: replace acronym tags with shortcodes, markdown strikethrough - xrandr-dual-head: convert pre block to fenced code - git-setup-own-server-part2: markdown blockquote + drop image figure + fenced code blocks (user will add image later)
Diffstat (limited to 'content/en/articles/git-setup-own-server-part2')
-rw-r--r--content/en/articles/git-setup-own-server-part2/index.md48
1 files changed, 32 insertions, 16 deletions
diff --git a/content/en/articles/git-setup-own-server-part2/index.md b/content/en/articles/git-setup-own-server-part2/index.md
index 42c50c4..2b10f29 100644
--- a/content/en/articles/git-setup-own-server-part2/index.md
+++ b/content/en/articles/git-setup-own-server-part2/index.md
@@ -12,32 +12,48 @@ tags = [ "git", "linux", "python", "howto", "automation", "ssh", "flask", "do it
This is a followup on [my previous article about how to setup your server][1] to handle a GIT repository and deploy to a web server like apache.
-Since I started experimenting with python and web publishing with it I wanted a way to push all the changes to my codebase directly to a web server, in a similar way as to what I already do with php and apache.<figure class="wp-block-pullquote" style="border-color:#abb8c3">
+Since I started experimenting with python and web publishing with it I wanted a way to push all the changes to my codebase directly to a web server, in a similar way as to what I already do with php and apache.
-<blockquote class="has-text-color has-very-dark-gray-color">
- <p>
- I want to do it myself, the way I like it..
- </p>
-
- <cite>danix</cite>
-</blockquote></figure>
+> I want to do it myself, the way I like it..
+>
+> — danix
-Serving python scripts is slightly different than serving html or php, here&#8217;s a scheme that shows what happens when using python (flask in this example) to serve some web content.
-
-
-<div class="wp-block-image">
- <figure class="aligncenter"><img loading="lazy" width="1024" height="393" src="https://danix.xyz/wp-content/uploads/2018/12/flask-scheme-1024x393.png" alt="" class="wp-image-3852" srcset="https://danix.xyz/wp-content/uploads/2018/12/flask-scheme-1024x393.png 1024w, https://danix.xyz/wp-content/uploads/2018/12/flask-scheme-300x115.png 300w, https://danix.xyz/wp-content/uploads/2018/12/flask-scheme-768x294.png 768w, https://danix.xyz/wp-content/uploads/2018/12/flask-scheme.png 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>a simple scheme of how python scripts are served on the web.</figcaption></figure>
-</div>
+Serving python scripts is slightly different than serving html or php, here's a scheme that shows what happens when using python (flask in this example) to serve some web content.
As you can see the web server is acting as a reverse proxy to the [WSGI][2] server Gunicorn, Apache receives a request from a client, forwards the request to Gunicorn which in turn asks the python web service, in our case our flask web app. Other than as a reverse proxy, apache is used also to serve static content which is not originated in python, like images, css or js scripts.
In order to deploy a python web app I had to install the mod_wsgi extension for apache, then I decided to use a folder in my system to install the virtual environment for python to run my web app and point to that directory in my vhost configuration file inside apache. After that I created a directory where to store all files for my web app and instructed apache to serve them using the virtualenv I created earlier. This is more or less what I did:
-<pre class="wp-block-preformatted"># create the virtual environment for python inside<br /># the folder /usr/local/virtualenvs/my-app:<br />virtualenv /usr/local/virtualenvs/my-app<br /><br /># now create the directory inside the apache root<br /># to store our web app<br />mkdir /var/www/htdocs/my-app<br /></pre>
+```bash
+# create the virtual environment for python inside
+# the folder /usr/local/virtualenvs/my-app:
+virtualenv /usr/local/virtualenvs/my-app
+
+# now create the directory inside the apache root
+# to store our web app
+mkdir /var/www/htdocs/my-app
+```
Now if we put all the py files for our flask web app we can run it inside apache, this is the configuration for the vhost I used:
-<pre class="wp-block-preformatted">&lt;VirtualHost *:80><br /><code> ServerName my-app.mysite.ext</code><br /><code> ErrorLog "/var/log/httpd/my-app.error_log"</code><br /><code> CustomLog "/var/log/httpd/my-app.access_log" common</code><br /><code> WSGIDaemonProcess my-app user=apache group=apache threads=5 python-home=/usr/local/virtualenvs/my-app</code><br /><code> WSGIScriptAlias / /var/www/htdocs/my-app/my-app.wsgi</code><br /><code> WSGIProcessGroup my-app</code><br /><code> Alias "/static/" "/var/www/htdocs/my-app/static/"</code><br /><code> &lt;Directory "/var/www/htdocs/my-app/static/"></code><br /><code> Order allow,deny</code><br /><code> Allow from all</code><br /><code> &lt;/Directory></code><br /><code> &lt;Directory "/var/www/htdocs/my-app/"></code><br /><code> Require all granted</code><br /><code> &lt;/Directory></code><br />&lt;/VirtualHost><br /><br /></pre>
+```apache
+<VirtualHost *:80>
+ ServerName my-app.mysite.ext
+ ErrorLog "/var/log/httpd/my-app.error_log"
+ CustomLog "/var/log/httpd/my-app.access_log" common
+ WSGIDaemonProcess my-app user=apache group=apache threads=5 python-home=/usr/local/virtualenvs/my-app
+ WSGIScriptAlias / /var/www/htdocs/my-app/my-app.wsgi
+ WSGIProcessGroup my-app
+ Alias "/static/" "/var/www/htdocs/my-app/static/"
+ <Directory "/var/www/htdocs/my-app/static/">
+ Order allow,deny
+ Allow from all
+ </Directory>
+ <Directory "/var/www/htdocs/my-app/">
+ Require all granted
+ </Directory>
+</VirtualHost>
+```
With this setting I can now reach my web app and test it after restarting the web server.