Skip to content

Instantly share code, notes, and snippets.

@AxeemHaider
Last active October 3, 2023 09:35
Show Gist options
  • Save AxeemHaider/e28c122199ca81d1dce318cdd41a1455 to your computer and use it in GitHub Desktop.
Save AxeemHaider/e28c122199ca81d1dce318cdd41a1455 to your computer and use it in GitHub Desktop.
Install and Config Lampp on Ubuntu

Prerequisites

sudo apt update

Install Apache

Config file /etc/apache2/apache2.conf

sudo apt install apache2

Check localhost server

http://your_server_ip

Install MySQL

sudo apt install mysql-server

Check MySQL is running

sudo mysql

MySQL Users and Passwords

Getting all users

mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;

Change user password Use caching_sha2_password OR mysql_native_password depend on version

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password';

Create new user (When phpMyAdmin is not login default user)

mysql -u root -p

Create new user

mysql> CREATE USER 'sammy'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password';

Grant All privileges

mysql> GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'localhost' WITH GRANT OPTION;

If still you are not able to login then flush changes and restart apache2 server

mysql> FLUSH PRIVILEGES;

Still not restart computer

Installing PHP

sudo apt install php libapache2-mod-php php-mysql

Install Some common php extensions

sudo apt install php-cli php-fpm php-common php-mbstring php-curl php-gd php-mysqlnd php-json php-xml php-intl php-opcache

Restart Server

sudo systemctl restart apache2

Installing phpMyAdmin

Config file /etc/phpmyadmin/config.inc.php

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

For the server selection, choose apache2

sudo phpenmod mbstring

Allow login without password

$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

If phpMyAdmin is not found after installing

sudo vim /etc/apache2/apache2.conf

Add this line at the end of the file

Include /etc/phpmyadmin/apache.conf

For Error

mysqli_real_connect(): (HY000/1045): Access denied for user 'phpmyadmin'@'localhost' (using password: NO)

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma'; 
$cfg['Servers'][$i]['controlpass'] = '';

If phpMyAdmin is not login with default user then create the new one

Tip: Importing large SQL database To do this convert SQL file into zip and upload

.htaccess

If apache2 server is downloading file instead of running then remove this from .htaccess

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

Like So

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
#<IfModule mime_module>
#  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
#</IfModule>
# php -- END cPanel-generated handler, do not edit

Removing index.php from apache2

AllowOverride All Replace None with All

sudo vim /etc/apache2/apache2.conf
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

Enable mode_rewrite

sudo a2enmod rewrite

.htaccess file config

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Allow User Access

sudo chown -R $USER /var/www

Allow apache to create files and folders in /var/www

Add user to existing group

sudo usermod -a -G www-data $USER

change group ownership

sudo chown -R www-data:www-data /var/www

Allow himeself to delete or create files in /var/www/html

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

Node

Error

ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

FLUSH PRIVILEGES;

If that doesn't work, try it without @'localhost' part.

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