Reputation: 1
I have bought a digital ocean VPS ( image: ubuntu) with Plesk. I have connected with one domain. and now I am running a php website successfully on VPS. I want to run the flask application as well in my VPS. I can run it by console. But I want it to be done by a web request , with a domain. But I already added my PHP website with the domain.I want to know if I can run python with that same domain name ( with subdomain if possible ).
example: my website: https://example.com/index.php I want to run flask app with this endpoint:- https://example.com/python or https://python.example.com
I guess I have to change some configuration settings in apache2/sites-available.
Can I try below .conf ?
<VirtualHost *:80>
ServerName example.com/python
ServerAlias www.example.com/python
ServerAdmin [email protected]
WSGIScriptAlias / /var/www/myapp/pyapp.wsgi
<Directory /var/www/myapp/myapp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/myapp/myapp/static
<Directory /var/www/myapp/myapp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
But I am not sure at all , I am noob in .conf .
thanks you so much if you can help me. :)
Upvotes: 0
Views: 236
Reputation: 811
Hi you should be able to do this not sure about python but php and Apache can do this.
You can just create a .conf file for each site
sudo nano /etc/apache2/sites-available/example.com.conf
Then
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName example.com
ServerAlias example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Then you could create
sudo nano /etc/apache2/sites-available/python.example.com.conf
Add entry to second website
<VirtualHost *:80>
ServerName python.example.com
ServerAdmin [email protected]
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Then
sudo a2ensite example.com.conf
sudo a2ensite python.example.com.conf
This config is for port 80 so it would be on http you would need to setup SSL for https
You can checkout the links below for information how to get your setup working
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps
Upvotes: 2