#!/linuxSucks/Install and setup a Lamp Stack in Debian/Ubuntu server
Apr 14, 2019How to install a web server in debian based systems (Apache + PHP + MySQL + PHPmyadmin)
Install Apache
Install apache web server with the following command:
sudo apt install apache2 -y
Give rights to the apache file that you can easily manage your sites. To do this, run the following commands:
sudo chown -R pi:www-data /var/www/html/
sudo chmod -R 770 /var/www/html/
Now enable mod_rewrite for apache to understand rewrite rules:
sudo a2enmod rewrite
Then we need to restart apache:
sudo systemctl restart apache2
We need to make sure the mod_rewrite works properly without any problems, edit apache2.conf and make just a change in one line. Run the following command:
sudo nano /ect/apache2/apache2.conf
Scroll down and search for this pice of code:
Directory /var/www/
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
/Directory
Change AllowOverride None to AllowOverride All, close and save. Then restart apache.
Install PHP
Install PHP with the following command:
sudo apt install php php-mbstring php-gettext -y
This will ask you a few questions in order to configure your installation correctly.
Enable the mbstring PHP extension, run this command:
sudo phpenmod mbstring
Afterwards, restart Apache for your changes to be recognized:
sudo systemctl restart apache2
Install MySQL
Install your database with the following command:
sudo apt install mysql-server php-mysql -y
When the installation is done restart Apache:
sudo systemctl restart apache2
PHPMyAdmin
If you like to have a UI to manage your databases you can install phpmyadmin with the following command:
sudo apt install phpmyadmin -y
Follow the instruction to setup phpmyadmin