configureer de firewall UFW
Uncomplicated Firwall (interface to iptables)
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-18-04
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 80
sudo ufw allow 8080
sudo ufw enable
zorg dat apache niet automatisch opstart:
sudo update-rc.d apache2 disable
sudo systemctl disable apache2
Install Nginx
zie https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04check webserver
What you're seeing is the index.html file that was installed by Apache. Do not trust solely the Index page being served as an indicator of the Web Server being used!Just because you're seeing the Apache "default" page, doesn't mean that you're actually seeing Apache running, you're just seeing the 'default page' that was installed. Neither NGINX nor Apache will overwrite the index.html file in the default web root if it was already present (in an ideal situation), so whichever was present first is actually the one that installed the index.html file - it won't change just because you installed a different webserver.
You can confirm this by doing: sudo rm /var/www/html/index.html && echo "I am testing things!" | sudo tee /var/www/html/index.html and then refreshing your browser - you'll see that it's different content at this point.
If the nginx software at install time sees an index.html file already in the default webroot /var/www/html/, it is supposed to not overwrite it. This is normal, so users who use the default docroot for their websites don't lose their data.
What we need to do is confirm what Web Server is actually in use.
Always use actual command line tools to verify the web server software in use.
Leveraging sudo netstat -tulpn | grep :80 we can get an idea of what web server is in use:
$ sudo netstat -tulpn | grep :80
tcp6 0 0 :::80 :::* LISTEN 1258/apache2
As you can see, this is an Apache2 web server listening on port 80.
Conversely, if the server is nginx you see something like this:
$ sudo netstat -tulpn | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2772/nginx: master
tcp6 0 0 :::80 :::* LISTEN 2772/nginx: master
You can also determine if it's Apache2 or NGINX running by checking the output of one of the following commands:
$ pidof apache2
$ pidof nginx
Depending on which of these provides output, you can determine which web server is actually in use.
Install Flask
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04let op foutje moet zijn :
python3 -m venv myprojectenv
Let op bij stap 5 creating a systemd unit file
in /etc/systemd/system/myproject.service is belangrijk dat je group=www-data gebruikt ander krijg je later bad gateway 502 errors
[Unit]
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=ilcapo
Group=www-data
WorkingDirectory=/home/ilcapo/myproject
Environment="PATH=/home/ilcapo/myproject/myprojectenv/bin"
ExecStart=/home/ilcapo/myproject/myprojectenv/bin/uwsgi --ini myproject.ini
[Install]
WantedBy=multi-user.target
symbolic links
ga in directory : unlink defaultmaak een link: sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/default
uwsgi installatie
let op zie speciale Post hieroverThe uWSGI install will fail unless you have a complete Python installation. In particular, you need to have the python3-dev package and the libssl-dev package installed. (See this post.)
(sam) joe@helium:~/venvs$ which -a python3
/home/joe/venvs/sam/bin/python3
/usr/local/bin/python3
/usr/bin/python3