A lightweight dev system (Debian + LAMP)
to make my web development work a bit smoother, I want to begin using separate virtual machines for my various projects. Each VM is going to be reserved for a specific project and should contain the complete development environment including a LAMP stack. However, I still want to keep these machines free of unnecessary "stuff". For this reason, I want to setup a baseline Debian system with UI and a LAMP stack, which can then be customized as needed.
Do bare in mind, that this installation is rather insecure and therefore not fit for production use!
The basis of the system is going to be a bare bone Debian installation. During installation unselect all software (especially the desktop environment). You may want to keep basic system utilities, I personally install them only when the need arises (which it usually doesn't).
Once you are logged in to your base system, perform the usual upgrades:
sudo apt update
sudo apt upgrade
Next, install the display server and the LXDE core system:
sudo apt install xorg lxde-core
You now have a complete desktop available at any time via
sudo startx. Also, the next time you reboot the system, you will automatically be presented the graphical login screen.
The LAMP stack
Currently, the Debian package repository does not include a newer version of PHP than 7.0. Since I want to use some newer functionality, we will add the respective repository and install PHP 7.2. (If you want to use PHP 7.3, just replace php7.2 with php7.3 in all following commands.):
sudo apt install ca-certificates apt-transport-https wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add - echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list sudo apt update sudo apt install php7.2 php7.2-mysql
You might also want to run
sudo apt upgrade, as the sury repos usually contain some other newer packages.
We can now install Apache and MariaDB:
sudo apt install apache2 libapache2-mod-php7.2 mariadb-server
Since I typically use mod_rewrite in my projects, I want to configure rewriting for apache. First, let's enable mod_rewrite:
sudo a2enmod rewrite
Next, we will have to allow rewriting for our web directory (which should be /var/www). You will find the required setting in the apache configuration
sudo nano /etc/apache2/apache2.conf
Options Indexes FollowSymLinks
Require all granted
Now, restart apache to apply the configuration.
sudo service apache2 restart
Finally, let's install phpMyAdmin to make database administration easier:
sudo apt install phpmyadmin
For my local development machines I use the MariaDB root user without password (which is obviously an absolute no-go on any production system). However, current MySQL and MariaDB releases do not allow connection via root account without at least using
sudo. So we need to change the login plugin back to the "normal" password based method:
sudo mysql -u root
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User='root'; FLUSH PRIVILEGES;
phpMyAdmin also does not like logins without password, which we will change in the configuration:
sudo nano /etc/phpmyadmin/config.inc.php
Find and uncomment the line
// $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
You now have a very lightweight development system with a LAMP stack and phpMyAdmin to play around with. Have fun!