Difference between revisions of "WebServer - Basic LAMP Stack Install"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
*Proven on
{{{!}} class="wikitable" style="float: right; width: 322px;" border="2"
**Mint 19.3 ... (Seems to get MySQL 5.7)
{{!}}+ Proven on:
**Mint 20 ... (Gets MySQL 8.0)
{{!}}- <!-- Debian -->
**SparkyLinux 5.11 ... (Debian based)
{{!}} style="text-align: center; width: 60px;" {{!}} [[File:Logo Debian.png{{!}}60px{{!}}link=https://www.debian.org/{{!}}center{{!}}middle{{!}}frameless]]
**LMDE 4 ... (Debian based)
{{!}} style="text-align: center; width: 40px;" {{!}} 11 (bullseye)
**Debian minimal ... (Debian based)
{{!}}
<br>
{{!}}- <!-- LMDE -->
{{!}} style="text-align: center; width: 65.675px;" {{!}} [[File:Logo LMDE.png{{!}}60px{{!}}link=https://linuxmint.com/edition.php?id=279{{!}}center{{!}}middle{{!}}frameless]]
{{!}} 4
{{!}}
<br>
{{!}}- <!-- Linux Mint -->
{{!}} style="text-align: center; width: 67.5125px;" {{!}} [[File:Logo Mint.png{{!}}60px{{!}}link=https://linuxmint.com{{!}}center{{!}}middle{{!}}frameless]]
{{!}} 19.3 / 20.3
{{!}}
<br>
{{!}}- <!-- Ubuntu -->
{{!}} style="text-align: center; width: 65.7px;" {{!}} [[File:Logo Ubuntu.png{{!}}60px{{!}}link=https://ubuntu.com/{{!}}center{{!}}middle{{!}}frameless]]
{{!}} 20.04.3
{{!}}
<br>
{{!}}- <!-- Sparky Linux -->
{{!}} style="text-align: center; width: 65.7px;" {{!}} [[File:Logo Sparky.png{{!}}60px{{!}}link=https://sparkylinux.org/{{!}}center{{!}}middle{{!}}frameless]]
{{!}} 5.11
{{!}}
<br>
{{!}}}
 
'''As always...'''
 
Start with:
 
*<code>sudo apt update</code>
*<code>sudo apt upgrade</code>


=== Install the LAMP Stack ===
=== Install the LAMP Stack ===
* [[WebServer - Mint 19.3{{!}}If you are running Mint 19.3]]
* [[WebServer - Mint 19.3{{!}}If you are running Mint 19.3]]
* [[WebServer - Debian based Linux{{!}}If you are running a Debian based Linux]]
* If you are running a Debian based Linux
** (Debian itself, LMDE, SparkyLinux, others...)
** (Debian itself, LMDE, SparkyLinux, others...)
** You'll need to install:
*** [[MySQL]]
*** & Possibly, [[Fixing vim{{!}}vim]]


==== Install the packages ====
==== Install the packages ====
'''<span style="color: rgb(186, 55, 42);">Big change(s) incomming...</span>'''
'''<span style="color: rgb(186, 55, 42);">Likely fully replacing MySQL with MariaDB.</span>'''
<span style="color: rgb(186, 55, 42);">(Really, boils down to replacing '''mysql-server''' & '''mysql-client''' with '''mariadb-server''' & '''mariadb-client''' in the next command...)</span>


*<code>sudo apt install apache2 libapache2-mod-php php-xml php-mbstring php-apcu php-intl imagemagick inkscape php-gd php-cli php-cgi php mysql-server mysql-client php-mysql</code>
*<code>sudo apt install apache2 libapache2-mod-php php-xml php-mbstring php-apcu php-intl imagemagick inkscape php-gd php-cli php-cgi php mysql-server mysql-client php-mysql</code>
**Say Yes to Continue
* <span style="color: rgb(22, 145, 121);">If you are using a separate database server:</span>
**<code><span style="color: rgb(22, 145, 121);">sudo apt install apache2 libapache2-mod-php php-xml php-mbstring php-apcu php-intl imagemagick inkscape php-gd php-cli php-cgi php mysql-client php-mysql</span></code>
** <span style="color: rgb(22, 145, 121);" >& skip any reference to configuring mysql server</span>
*Say Yes to Continue
**<u>Configuring mysql-community-server</u> (Doesn't happen on Mint but DOES happen on LMDE)
**<u>Configuring mysql-community-server</u> (Doesn't happen on Mint but DOES happen on LMDE)
***Pick a good '''root''' password...
***Pick a good '''root''' password...
***I tend to select '''Use Legacy Authentication Method''' because '''Use Strong Password Encryption''' is annoying as hell. (Your choice here...)
***I tend to select '''Use Legacy Authentication Method''' because '''Use Strong Password Encryption''' is annoying as hell. (Your choice here...)
<span style="color: rgb(255, 0, 0);">'''[[Now Do A Backup!{{!}}Now Do A Backup!]]'''</span>


==== Configure MySQL ====
==== Configure MySQL ====
Line 23: Line 66:
*<code>sudo mysql_secure_installation</code>
*<code>sudo mysql_secure_installation</code>
**<u>Would you like to setup VALIDATE PASSWORD component?</u>
**<u>Would you like to setup VALIDATE PASSWORD component?</u>
***I select No (because I'd rather manage my own password policies, thanks...)
***I select <span style="color: rgb(22, 145, 121);">No</span> (because I'd rather manage my own password policies, thanks...)
**'''''root password'''''
**'''''root password'''''
***<u>Please set the password for root here.</u>
***<u>Please set the password for root here.</u>
****Pick a good '''root''' password...
****<span style="color: rgb(22, 145, 121);">Pick a good '''root''' password...</span>
**or... (depends on install...)
**or... (depends on install...)
***<u>Using existing password for root.</u>
***<u>Using existing password for root.</u>
****Say No
****Say <span style="color: rgb(22, 145, 121);">No</span> (Which actually means yes... The question being asked is "Change the password for root?")
**<u>Remove anonymous users?</u>
**<u>Remove anonymous users?</u>
***Duh... Yes
***Duh... <span style="color: rgb(22, 145, 121);">Yes</span>
**<u>Disallow root login remotely?</u>
**<u>Disallow root login remotely?</u>
***Your choice, but I tend to say No.
***Your choice, but I tend to say <span style="color: rgb(22, 145, 121);">No</span>.
**<u>Remove test database and access to it?</u>
**<u>Remove test database and access to it?</u>
***Duh... Yes again.
***Duh... <span style="color: rgb(22, 145, 121);">Yes</span> again.
**<u>Reload privilege tables now?</u>
**<u>Reload privilege tables now?</u>
***Yes
***<span style="color: rgb(22, 145, 121);">Yes</span>
*([[MySQL - Initial Configuration{{!}}Extra Instructions if you've never configured MySQL before]])
*([[MySQL - Initial Configuration{{!}}Extra Instructions if you've never configured MySQL before]])


Line 43: Line 86:


*<code>sudo vi /var/www/html/info.php</code>
*<code>sudo vi /var/www/html/info.php</code>
<!--?php phpinfo();
<pre><nowiki>
?-->
<?php
phpinfo();
?>
</nowiki></pre>
 
Browse to http://ServerAddress/ & you should see the default page.
Browse to http://ServerAddress/ & you should see the default page.


Line 50: Line 97:


'''Notice that those 2 addresses are HTTP, and NOT HTTPS. This is important and Chrome will mess with you.'''
'''Notice that those 2 addresses are HTTP, and NOT HTTPS. This is important and Chrome will mess with you.'''
<span style="color: rgb(255, 0, 0);">'''[[Now Do A Backup!{{!}}Now Do A Backup!]]'''</span>


==== Set up at least one user in mysql ====
==== Set up at least one user in mysql ====


*<code>sudo mysql -u root -p</code>
*<code>sudo mysql -u root -p</code>
  CREATE USER 'someone'@'localhost' IDENTIFIED BY 'password';
  CREATE USER ''''USERNAME''''@'localhost' IDENTIFIED BY ''''PASSWORD'''';
  FLUSH PRIVILEGES;
  FLUSH PRIVILEGES;
  EXIT;
  EXIT;
('''Hint:''' This'd be a good time to create yourself as that user with your non-admin password of choice...)
('''Hint:''' This'd be a good time to create yourself as that user with your non-admin password of choice...)
<span style="color: rgb(255, 0, 0);">'''[[Now Do A Backup!{{!}}Now Do A Backup!]]'''</span>
[[Category:ServerBuilding]]
[[Category:WebServers]]

Latest revision as of 23:56, 10 November 2023

Proven on:
Logo Debian.png
11 (bullseye)


Logo LMDE.png
4


Logo Mint.png
19.3 / 20.3


Logo Ubuntu.png
20.04.3


Logo Sparky.png
5.11


As always...

Start with:

  • sudo apt update
  • sudo apt upgrade

Install the LAMP Stack

Install the packages

Big change(s) incomming...

Likely fully replacing MySQL with MariaDB.

(Really, boils down to replacing mysql-server & mysql-client with mariadb-server & mariadb-client in the next command...)

  • sudo apt install apache2 libapache2-mod-php php-xml php-mbstring php-apcu php-intl imagemagick inkscape php-gd php-cli php-cgi php mysql-server mysql-client php-mysql
  • If you are using a separate database server:
    • sudo apt install apache2 libapache2-mod-php php-xml php-mbstring php-apcu php-intl imagemagick inkscape php-gd php-cli php-cgi php mysql-client php-mysql
    • & skip any reference to configuring mysql server
  • Say Yes to Continue
    • Configuring mysql-community-server (Doesn't happen on Mint but DOES happen on LMDE)
      • Pick a good root password...
      • I tend to select Use Legacy Authentication Method because Use Strong Password Encryption is annoying as hell. (Your choice here...)

Now Do A Backup!

Configure MySQL

  • sudo mysql_secure_installation
    • Would you like to setup VALIDATE PASSWORD component?
      • I select No (because I'd rather manage my own password policies, thanks...)
    • root password
      • Please set the password for root here.
        • Pick a good root password...
    • or... (depends on install...)
      • Using existing password for root.
        • Say No (Which actually means yes... The question being asked is "Change the password for root?")
    • Remove anonymous users?
      • Duh... Yes
    • Disallow root login remotely?
      • Your choice, but I tend to say No.
    • Remove test database and access to it?
      • Duh... Yes again.
    • Reload privilege tables now?
      • Yes
  • (Extra Instructions if you've never configured MySQL before)

& Test it

  • sudo vi /var/www/html/info.php
<?php
phpinfo();
?>

Browse to http://ServerAddress/ & you should see the default page.

Browse to http://ServerAddress/info.php & you should see a whole bunch of info about your PHP subsystem.

Notice that those 2 addresses are HTTP, and NOT HTTPS. This is important and Chrome will mess with you.

Now Do A Backup!

Set up at least one user in mysql

  • sudo mysql -u root -p
CREATE USER 'USERNAME'@'localhost' IDENTIFIED BY 'PASSWORD';
FLUSH PRIVILEGES;
EXIT;

(Hint: This'd be a good time to create yourself as that user with your non-admin password of choice...)

Now Do A Backup!