Skip to content

Instantly share code, notes, and snippets.

@adnan360
Last active February 23, 2024 04:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adnan360/bd78d6e68dc496c35bcf3003e04ec875 to your computer and use it in GitHub Desktop.
Save adnan360/bd78d6e68dc496c35bcf3003e04ec875 to your computer and use it in GitHub Desktop.
How to Install LAMPP Stack on Debian/Ubuntu [Experimental]

How to Install LAMPP Stack on Debian/Ubuntu [Experimental]

Ubuntu is based on Debian so it should apply to Ubuntu as well. I have tested this on latest Debian Testing (on SparkyLinux). I usually use WordPress and CakePHP on my localhost so I included instructions at the end to make them work perfectly.

Warning: This config is not designed with security in mind, only for convenience of desktop users. If you are setting up for server, please refer to proper manuals.

Note: This config is experimental. There might be better way to do some aspects. But it does work for my specific needs so I made it available. Please use carefully.

Step 1: Install stuff

Install Apache and Mysql/Mariadb:

sudo apt install apache2 mariadb-server

Install PHP and other required libraries:

sudo apt install php php-intl php-mysql

Install phpMyAdmin:

sudo apt install phpmyadmin

Note: Remember to press space to select "apache2" (not lighttpd) in the screen that comes, then press tab and enter. If asks for "Configure database for phpmyadmin with dbconfig-common?" I chose no.

Now, to start the local server:

sudo systemctl start apache2 mariadb

To test, open http://localhost on a webbrowser and then test http://localhost/phpmyadmin. They should open without problems.

Step 2: Configuring

/phpmyadmin not found

If you can't access http://localhost/phpmyadmin then run:

sudo nano /etc/apache2/apache2.conf

then add at the end:

Include /etc/phpmyadmin/apache.conf

then:

sudo systemctl restart apache2

Cannot login to phpMyAdmin (root, with no password)

Windows XAMPP has root user with no password. To keep it here same:

Run:

sudo nano /etc/phpmyadmin/config.inc.php

then add these in proper place:

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = true;
$cfg['Servers'][$i]['AllowNoPassword'] = true;

Also, comment these lines:

//$cfg['Servers'][$i]['controluser'] = $dbuser;
//$cfg['Servers'][$i]['controlpass'] = $dbpass;

To clear mysql root password (to use blank password), run: sudo mysql -u root

then a mysql shell will open. Enter these on the shell:

use mysql;
update user set plugin='' where User='root';
flush privileges;
\q

source: https://superuser.com/a/1027838

Cannot login to PhpMyAdmin (root, with a password)

You can skip this if you did not set a password for phpMyAdmin. It may be that it is not possible to login to phpMyAdmin with root and with a password after install. This is normal since password is not set yet. To set a password, run:

sudo mysql_secure_installation

Go through the process and set the password. If it does not work then:

sudo systemctl stop mariadb
sudo mysqld --skip-grant-tables &
sudo mysql -u root mysql

Replace YOURNEWPASSWORD with your new password:

UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;

Now you should be able to login with the new password on root user.

source: https://askubuntu.com/a/893899

WordPress plugin cannot install - wants FTP credentials

sudo groupadd www-data # maybe not needed, it should be automatically created w/apache

sudo usermod -a -G www-data $USER # to add your user to www-data group

Run:

sudo nano /etc/apache2/envvars

then add:

export APACHE_RUN_USER=your_username

Enable mod_rewrite

sudo nano /etc/apache2/mods-available/rewrite.load

uncomment:

LoadModule rewrite_module modules/mod_rewrite.so

sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

sudo nano /etc/apache2/apache2.conf

find:

<Directory /var/www/>

under the tag make the line:

AllowOverride None

to:

AllowOverride All

Start/stop/restart server

sudo systemctl start apache2 mariadb
sudo systemctl stop apache2 mariadb
sudo systemctl restart apache2 mariadb

Get loaded php.ini file path:

php --ini | grep Loaded | awk '{ print $4 }'

Mine says /etc/php/7.2/cli/php.ini so I used it on later instructions.

CakePHP preparation:

First, install composer: sudo apt install composer

sudo nano /etc/php/7.2/cli/php.ini

extension=intl ; uncomment
extension=pdo_mysql ; uncomment
; under [intl]
; add...
intl.default_locale = en_utf8
intl.error_level = E_WARNING

extension=sockets // for websockets ; uncomment
extension=mbstring // uncomment

sudo systemctl restart apache2

source: https://stackoverflow.com/a/29405081

Step 3: Convenience

ln -s /var/www/html ~/html

sudo chown -R $USER:www-data /var/www/html/

This will create a shortcut named html on your home and allow you to modify files without root, like a normal directory.

As this is experimental config, please report any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment