------------------------------------------------------- A LAMP stack is literally these 4 bits... [L]inux (could swap for BSD, macOS or Windows) [A]pache (can be swapped for nginx/lighttpd/IIS) [M]ySQL (most distros now use MariaDB instead) [P]HP (some may say this can be Perl/Python!) On a Debian-based system they're these packages... [L]inux [l]inux-image-* [A]pache [a]pache2 [M]ySQL [m]ariadb-server [P]HP [p]hp ------------------------------------------------------- Since we've already got Linux we just need the rest... $ apt install apache2 mariadb-server php Plus any PHP modules needed (like talking to MySQL)... $ apt install php-mysql Lastly Certbot (and a module for configuring the HTTP daemon) for getting Let's Encrypt certificates later... $ apt install certbot python-certbot-apache ------------------------------------------------------- You should find that it does something already!.. | http://vm1.staffslug.org.uk/ or | http://vm2.staffslug.org.uk/ or | http://vm3.staffslug.org.uk/ This is the default website that has a single HTML file kept at this location on the system... /var/www/html ------------------------------------------------------- Let's look at the config of our Apache HTTP Server... $ cd /etc/apache2 $ ls Now look inside those two sites-* directories... $ ls sites-available/ $ ls sites-enabled/ ------------------------------------------------------- Disable the default website and reload Apache... $ a2dissite ## Type in... 000-default $ systemctl reload apache2 You should find a symlink vanishes in this directory... $ ls sites-enabled/ ------------------------------------------------------- Duplicate the default site config so we can use it as a template for our own website... $ cd sites-available/ $ cp 000-default.conf whatever.com.conf Use your favourite text editor to edit the file... $ nano whatever.com.conf ## Uncomment ServerName and set it to whatever.com ## Add ServerAlias underneath set to www.whatever.com ## Change DocumentRoot to /var/www/whatever.com ------------------------------------------------------- Enable our new website... $ a2ensite ## Type in... whatever.com $ systemctl reload apache2 You should find a link to our new file appears in... $ ls sites-enabled/ ------------------------------------------------------- Take a look at where the default website is kept... $ cd /var/www/ $ ls Make another directory alongside it for our new site... $ mkdir whatever.com/ $ cd whatever.com/ ------------------------------------------------------- Create your first file that we'll host with the site. This'll just be a tiny text file which has a PHP command to show us PHP is working. Use any text editor to create this file and add the following text... $ nano index.php ## Type in... ------------------------------------------------------- Hopefully you get a page full of information about PHP and you should also find your site works both with and without the www in front of it... | http://whatever.com/ or... | http://www.whatever.com/ ------------------------------------------------------- Running certbot will grab an SSL certificate from the people at Let's Encrypt, configuring it against our Apache HTTP Server and also set up renewals every 3 months. You'll need to answer it's questions... $ certbot ## E-mail: info@staffslug.org.uk (anything valid) ## ToS: (A)gree ## EFF e-mails: (N)o (no spam, we've got ORG!) ## Names: (no input, just hit enter) ## Redirection: [2] (should turn on HTTP -> HTTPS) ------------------------------------------------------- Now you're cooking with padlocks!.. | https://whatever.com/ or... | https://www.whatever.com/ ------------------------------------------------------- Let's download and extract the files for WordPress... $ wget http://wordpress.org/wordpress-5.3.zip $ unzip wordpress-5.3.zip Move WordPress out of the sub-directory that was made on extraction and also fix permissions so WordPress can edit and create it's own files in future... $ mv wordpress/* . $ chown -R www-data:www-data . ------------------------------------------------------- Launch the MariaDB command line client... $ mariadb Use these SQL queries to make a database and database user for WordPress... > CREATE DATABASE whatever_com; > GRANT ALL PRIVILEGES ON whatever_com.* TO whatever_com@localhost IDENTIFIED BY "password"; > FLUSH PRIVILEGES; > EXIT; ------------------------------------------------------- Give WordPress that database information... | https://whatever.com ## Database Name... whatever_com ## Username... whatever_com ## Password... password ## Leave other fields alone, click Submit! ## Name your WordPress website and create an admin user ## and you're done! ------------------------------------------------------- It's a WordPress site... | https://whatever.com/ or... | https://www.whatever.com/ ------------------------------------------------------- Things to consider... - This rough guide supports multiple websites, just repeat the 'whatever.com' bits for another site name - To enable/disable Apache modules for more abilities use a2enmod / a2dismod (these work just like how you enabled sites earlier, with 2 other directories) - Earlier Certbot activated the 'rewrite' Apache module for us, allowing configuration to automatically rewrite requests, such as those from HTTP -> HTTPS ------------------------------------------------------- - Following these steps does not stop you using the same server for things like e-mail services, gaming servers, mailing lists, SFTP/FTP server and more... - Earlier we set the system user www-data to own the files of our website, because PHP runs as this user due to it being a part of Apache (at least in in this guide) and that's what Apache runs as by default - Busier servers can use PHP-FPM instead which runs as it's own process (not part of Apache) and can run as a different system user per website (for security!) ------------------------------------------------------- - You'd need to re-run Certbot whenever you add a new website so it can pick your new configuration so it can write it's own alongside that file and enable it - Obviously it's much easier to use a nice graphical interface to add new sites, that's the job of a control panel which does this work for you, like... ISPConfig, Froxlor, cPanel, DirectAdmin, Plesk, etc.. - It's still good to know how it works under the hood even with a control panel so you can diagnose issues if they come up ------------------------------------------------------- - You may get a PHP website that needs extra PHP modules that don't already come with the main PHP installation (php-mysql was one example we did) - Install any of these you need with APT, but remember if you're using PHP as part of Apache (like in this guide) then you'll need to restart Apache afterwards with... systemctl restart apache2 - I've probably forgotten lots of things... - ASK ME THINGS! -------------------------------------------------------