User Tools

Site Tools


lemp-install

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
lemp-install [2020/10/22 10:54] gwsadminlemp-install [2023/05/17 22:52] (current) – external edit 127.0.0.1
Line 15: Line 15:
  
 sudo ufw allow http https sudo ufw allow http https
 +
  
 </code> </code>
 +
   * Create a directory for your webserver files etc - but change this to your own preferences   * Create a directory for your webserver files etc - but change this to your own preferences
  
 <code bash> <code bash>
 sudo mkdir /media/webdisk/web-data sudo mkdir /media/webdisk/web-data
 +
  
 </code> </code>
 +
   * Change the permission so Nginx can use this folder:   * Change the permission so Nginx can use this folder:
  
 <code bash> <code bash>
 sudo chown www-data:www-data /media/webdisk/web-data -R sudo chown www-data:www-data /media/webdisk/web-data -R
 +
  
 </code> </code>
Line 35: Line 40:
  
 <code bash> <code bash>
-sudo apt install MariaDB-server MariaDB-client +sudo apt install mariadb-server mariadb-client 
-sudo systemctl start MariaDB +sudo systemctl start mariadb 
-sudo systemctl enable MariaDB+sudo systemctl enable mariadb 
  
 </code> </code>
 +
   * Now secure MariaDB by typing this:   * Now secure MariaDB by typing this:
  
 <code bash> <code bash>
 sudo mysql_secure_installation sudo mysql_secure_installation
 +
  
 </code> </code>
Line 65: Line 73:
  
 sudo systemctl enable php7.4-fpm sudo systemctl enable php7.4-fpm
 +
  
 </code> </code>
 +
 ==== Create your default server block ==== ==== Create your default server block ====
  
Line 73: Line 83:
 <code bash> <code bash>
 sudo rm /etc/nginx/sites-enabled/default sudo rm /etc/nginx/sites-enabled/default
 +
  
 </code> </code>
 +
   * Now create the server block,   * Now create the server block,
  
 <code bash> <code bash>
 sudo nano /etc/nginx/conf.d/default.conf sudo nano /etc/nginx/conf.d/default.conf
 +
  
 </code> </code>
 +
   * Copy/Paste all this into the new config file   * Copy/Paste all this into the new config file
  
Line 116: Line 130:
   }   }
 } }
 +
  
 </code> </code>
 +
   * Reload Nginx   * Reload Nginx
  
Line 124: Line 140:
  
 sudo systemctl reload nginx sudo systemctl reload nginx
 +
  
 </code> </code>
 +
   * Test Nginx and PHP are working by creeating an info.php in the webroot directory   * Test Nginx and PHP are working by creeating an info.php in the webroot directory
  
 <code bash> <code bash>
 sudo nano /usr/share/nginx/html/info.php sudo nano /usr/share/nginx/html/info.php
 +
  
 </code> </code>
 +
   * Paste the following into the file   * Paste the following into the file
  
 <code php> <code php>
 <?php phpinfo(); ?> <?php phpinfo(); ?>
 +
  
 </code> </code>
-  * To check it's working either go to http://127.0.0.1/info.php or http://yourserveripaddress/info.php. If it works remove this file for secuirty.+ 
 +  * To check it's working either go to [[http://127.0.0.1/info.php|http://127.0.0.1/info.php]] or [[http://yourserveripaddress/info.php|http://yourserveripaddress/info.php]]. If it works remove this file for secuirty.
  
 <code bash> <code bash>
 sudo rm /usr/share/nginx/html/info.php sudo rm /usr/share/nginx/html/info.php
 +
  
 </code> </code>
Line 147: Line 170:
 **Congratulations! You now have a working Web Server!** **Congratulations! You now have a working Web Server!**
  
-====   Install PHPmyadmin   ====+==== Install PHPmyadmin ====
  
   * Open terminal and run these:   * Open terminal and run these:
Line 155: Line 178:
  
 sudo apt install phpmyadmin sudo apt install phpmyadmin
 +
  
 </code> </code>
 +
   * Create a new server block, for best results, have PHPmyadmin run in a subdomain.   * Create a new server block, for best results, have PHPmyadmin run in a subdomain.
  
 <code bash> <code bash>
 sudo nano /etc/nginx/conf.d/phpmyadmin.conf sudo nano /etc/nginx/conf.d/phpmyadmin.conf
 +
  
 </code> </code>
 +
   * Copy/Paste all this into the new config file.   * Copy/Paste all this into the new config file.
  
Line 195: Line 222:
   }   }
 } }
 +
  
 </code> </code>
 +
   * Reload Nginx   * Reload Nginx
  
Line 203: Line 232:
  
 sudo systemctl reload nginx sudo systemctl reload nginx
 +
  
 </code> </code>
 +
 ==== Install Certbot ==== ==== Install Certbot ====
  
Line 211: Line 242:
 <code bash> <code bash>
 sudo apt install certbot python3-certbot-nginx sudo apt install certbot python3-certbot-nginx
 +
  
 </code> </code>
 +
   * Run certbot   * Run certbot
  
 <code bash> <code bash>
 sudo certbot --nginx sudo certbot --nginx
 +
  
 </code> </code>
 +
 +  * Respond to prompts from ''certbot''  to configure your HTTPS settings, which involves entering your email address and agreeing to the Let’s Encrypt terms of service.
 +
 +==== Add new SQL user ====
 +
 +As we have secured MariaDB we need to add a user for PHPmyadmin for you to log in.
 +
 +  * Run these commands:
 +
 +<code mysql>
 +sudo mariadb -u root
 +
 +create user 'phpadmin'@'localhost' identified by 'yourpassword';
 +
 +grant all privileges on *.* to 'phpadmin'@'localhost' with grant option;
 +
 +flush privileges;
 +
 +exit;
 +
 +
 +</code>
 +
 +**Login to PHPmyadmin via your domain name, and now you have a secure web server with a secure database server!**
  
  
lemp-install.1603364073.txt.gz · Last modified: 2023/05/17 22:52 (external edit)