Skip to content

Vagrant box with Debian 11 LAMP stack, MariaDB 10.6, PHP 8.2

License

Notifications You must be signed in to change notification settings

stemar/vagrant-debian-11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vagrant box Debian 11 LAMP

Make a Vagrant box with Debian 11 LAMP stack, plus configure it for development.

  • Host: Linux or Mac.

  • Guest: Debian 11, Apache 2.4, MariaDB 10.6, PHP 8.2, Python 3.9, Git 2+.

  • Leave code and version control files physically outside the VM while virtually accessing them inside the VM.

  • Use any GUI tool (IDEs, browsers, database administration applications, Git clients) outside the VM to access code and data inside the VM.


Details

Read Stemar Vagrant boxes.

Summary

VM = virtual machine

Quick installation

In host machine terminal:

mkdir -p ~/VM && cd $_
git clone --depth=1 https://github.com/stemar/vagrant-debian-11.git debian-11
cd ~/VM/debian-11
vagrant up --provision
vagrant ssh

Steps

  • Prerequisites
  • Vagrant preparation
  • Virtual machine provisioning
  • Configuration checks

Result

  • 64bit Debian 11 virtual machine with virtual 64GB HDD, 3GB RAM and updated LAMP stack from Bento.
  • Custom .bash_aliases to modify bash settings inside the virtual machine.
  • Configure LAMP settings from the host machine instead of inside the virtual machine.
  • Provisioning in bash because the commands can easily be copied/pasted inside a VM or server for troubleshooting.
  • Keep multiple Vagrant boxes in a separate location than your projects/code location.
    • .vagrant/ is created independently within each VM directory.
    • Multiple Vagrant boxes can be run concurrently from separate terminal tabs.
    • Avoid port collision by editing :forwarded_ports values in settings.yaml.
  • Copied SSH keys to use the same in and out of VM.
  • Copied Git and Subversion configurations to use the same in and out of VM.
  • Synchronized projects/code directories.
  • Apache serves any local website at http://domain.com.localhost:8000 with VirtualDocumentRoot.
  • Add more VirtualHost blocks from the host machine and re-provision the Vagrant box.
  • MariaDB and Adminer with no password for username root.
    • Avoid writing a password a zillion times through development.
  • Adminer served at http://localhost:8000/adminer.php.
  • Development-specific php.ini settings from .htaccess for all local websites.
  • Python 3.9 installed.

Prerequisites

SSH keys, Git config and Subversion config settings from host machine are copied in virtual machine.

Check if you have them on your host machine:

ll ~/.ssh
ll ~/.subversion
cat ~/.gitconfig

Vagrant preparation

Edit values in settings.yaml.

  • Edit the :machine values if necessary.
  • Add arrays to the :forwarded_ports value if necessary.
    • Ex.: Change the forwarded ports of this virtual machine to avoid port collision if you have multiple virtual machines running at the same time.
  • Change :synced_folder values to match your host machine pathname.
  • Edit the :copy_files values:
    • Ex.: Remove the Subversion array if you don't have it on your host machine.
  • Edit the :php_error_reporting value if necessary.

Edit config files if needed.

  • Edit the VirtualDocumentRoot public directory value in virtualhost.conf.
  • Add VirtualHosts in virtualhost.conf.
  • Edit php.ini.htaccess values.
  • Add/edit lines to bash_aliases.

Edit provision.sh if needed.

  • Add/edit Linux tools.
  • Add/edit PHP libraries.
  • Add anything you need.

Virtual machine provisioning

Provision the box from the host machine terminal:

cd ~/VM/debian-11
vagrant up --provision

To halt the box:

vagrant halt -f

To boot the box without provisioning:

vagrant up

If anything goes wrong:

vagrant destroy -f
vagrant box update
vagrant up --provision

Check the status of all Vagrant machines on your host machine:

vagrant global-status

Connect to the box through SSH:

vagrant ssh

Bash prompt in virtual machine is now:

vagrant@debian-11:~$

Configuration checks

Check LAMP settings

Check synchronized folders:

ll ~/Code
ll /vagrant

Check versions:

lsb_release -a
apache2 -v
mysql -V
php -v
svn --version
git --version
openssl version
curl --version

Check Apache configuration:

apachectl configtest
apachectl -V
cat /etc/hosts
cat /etc/apache2/apache2.conf
cat /etc/apache2/envvars
ll /etc/apache2/conf-available
ll /etc/apache2/conf-enabled
ll /etc/apache2/sites-available
ll /etc/apache2/sites-enabled
cat /etc/apache2/conf-available/localhost.conf
cat /etc/apache2/sites-available/virtualhost.conf
cat /etc/apache2/conf-available/adminer.conf
sudo cat /var/log/apache2/error.log

Check MariaDB databases:

mysql -u root
MariaDB [(none)]> SHOW DATABASES; quit;

Check PHP modules and variables:

php -m
php -i

Browse local websites

Check localhost

http://localhost:8000

You see the "Apache2 Debian Default Page".

Check Adminer

http://localhost:8000/adminer.php

  • Username: root
  • Password: leave empty

Check your domain(s)

Replace domain.com with your domain and your custom forwarded port number.

http://domain.com.localhost:8000


About

Vagrant box with Debian 11 LAMP stack, MariaDB 10.6, PHP 8.2

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published