MY LAMP SETUP
-
Pull Ubuntu
docker pull ubuntu:latest
-
Pull Mariadb
docker pull mariadb:latest
-
Create the shared network
docker network create --driver=bridge lampstack
-
Create MariaDB Container
docker run -itd -p 33063:3306 --name=lampmysql \ --network=lampstack \ --env MARIADB_USER=root \ --env MARIADB_PASSWORD=google \ --env MARIADB_ROOT_PASSWORD=google \ mariadb:latest
-
Create Ubuntu Container
Replace "./htdocs" with your working directory path.
docker run -itd -p 8080:80 \ --user root \ --name=lampstack \ --network=lampstack \ -v ./htdocs:/var/www/html/ \ ubuntu:22.04 /bin/bash
-
Get in to the Ubuntu Container
docker attach lampstack
-
Install all necessary Apache/PHP packages
Refer 1: Ubuntu - Install LAMP Stack
Execute the following commands one by one.
Update Ubuntu
apt-get update apt-get upgrade
Install necessary tools along with apache
apt-get install iputils-ping \ vim \ systemctl \ apache2 \ apache2-utils \
Enable apache server
systemctl enable apache2 systemctl start apache2 systemctl status apache2
Install mariadb client and PHP
apt-get install mariadb-client \ php \ libapache2-mod-php \ php-mysql \ php-curl \ php-gd \ php-mbstring \ php-xml \ php-soap \ php-intl \ php-zip
Enable rewrite and Restart apache server
a2enmod rewrite systemctl restart apache2
-
Rewrite Mode
If you want seo like links, You need to do some additional work
Refer 1: Ubuntu - Enable Mod Rewrite
Refer 2: Ubuntu - Enable Mod Rewrite
cd /etc/apache2/sites-available/ vi default.conf or vi 000-default.conf
Add following section to the one of the above mentioned file after CustomLog.
<Directory /var/www/html> Options Indexes FollowSymLinks AllowOverride all Require all granted </Directory>
Enable mod rewrite and restart apache
a2enmod rewrite systemctl apache2 restart
Additional configuration
-
Install phpMyAdmin
docker pull phpmyadmin/phpmyadmin
-
Create container for phpMyAdmin
docker run -itd -p 2599:80 --name=lampphpmyadmin \ -e PMA_ARBITRARY=1 \ --network=lampstack \ phpmyadmin/phpmyadmin
Top comments (2)
you should try to put all that stuff in a dockercomposefile :)
makes it easier and you only have to write it once!
Thanks for your reply. This is just for manual setup.
Here is my docker-compose setup
dev.to/vkuberan_88/docker-compose-...