Difference between revisions of "INSTALL PHYMYADMIN"

From rbachwiki
Jump to navigation Jump to search
(Created page with " sudo apt update sudo apt install -y phpmyadmin php-mbstring php-zip php-gd php-json php-curl")
 
Line 1: Line 1:
sudo apt update
== Installing phpMyAdmin on Ubuntu Server ==
sudo apt install -y phpmyadmin php-mbstring php-zip php-gd php-json php-curl
 
This guide assumes a working LAMP stack (Apache, MySQL, PHP) is already installed.
 
=== Prerequisites ===
* Ubuntu Server with Apache2, MySQL, and PHP installed
* A user with <code>sudo</code> privileges
 
=== Installation ===
 
==== 1. Install the packages ====
<syntaxhighlight lang="bash">
sudo apt update
sudo apt install -y phpmyadmin php-mbstring php-zip php-gd php-json php-curl
</syntaxhighlight>
 
==== 2. Answer the installer prompts ====
{| class="wikitable"
! Prompt !! Action
|-
| Web server to configure || Press '''Space''' to select '''apache2''', then Tab and Enter
|-
| Configure database with dbconfig-common || Choose '''Yes'''
|-
| Password for the phpmyadmin user || Set a password, or leave blank for a random one
|}
 
{{Note|If you skip selecting apache2, phpMyAdmin will not be wired into Apache.}}
 
==== 3. Enable mbstring and restart Apache ====
<syntaxhighlight lang="bash">
sudo phpenmod mbstring
sudo systemctl restart apache2
</syntaxhighlight>
 
phpMyAdmin is now available at <code>http://your-server-ip/phpmyadmin</code>.
 
=== Creating an admin user ===
On Ubuntu, MySQL's root account uses socket authentication, so logging in as root with a password through phpMyAdmin will fail. Create a dedicated admin user instead:
 
<syntaxhighlight lang="bash">
sudo mysql
</syntaxhighlight>
 
<syntaxhighlight lang="sql">
CREATE USER 'pmaadmin'@'localhost' IDENTIFIED BY 'a-strong-password';
GRANT ALL PRIVILEGES ON *.* TO 'pmaadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
</syntaxhighlight>
 
Log in to phpMyAdmin as <code>pmaadmin</code>.
 
=== Security hardening ===
phpMyAdmin is a frequent target for bots. If the server is reachable from the internet, apply the following.
 
==== Restrict access by IP ====
Edit <code>/etc/apache2/conf-available/phpmyadmin.conf</code> and add this inside the <code>&lt;Directory /usr/share/phpmyadmin&gt;</code> block:
 
<syntaxhighlight

Revision as of 17:00, 10 November 2026

Installing phpMyAdmin on Ubuntu Server

This guide assumes a working LAMP stack (Apache, MySQL, PHP) is already installed.

Prerequisites

  • Ubuntu Server with Apache2, MySQL, and PHP installed
  • A user with sudo privileges

Installation

1. Install the packages

<syntaxhighlight lang="bash"> sudo apt update sudo apt install -y phpmyadmin php-mbstring php-zip php-gd php-json php-curl </syntaxhighlight>

2. Answer the installer prompts

Prompt Action
Web server to configure Press Space to select apache2, then Tab and Enter
Configure database with dbconfig-common Choose Yes
Password for the phpmyadmin user Set a password, or leave blank for a random one

Template:Note

3. Enable mbstring and restart Apache

<syntaxhighlight lang="bash"> sudo phpenmod mbstring sudo systemctl restart apache2 </syntaxhighlight>

phpMyAdmin is now available at http://your-server-ip/phpmyadmin.

Creating an admin user

On Ubuntu, MySQL's root account uses socket authentication, so logging in as root with a password through phpMyAdmin will fail. Create a dedicated admin user instead:

<syntaxhighlight lang="bash"> sudo mysql </syntaxhighlight>

<syntaxhighlight lang="sql"> CREATE USER 'pmaadmin'@'localhost' IDENTIFIED BY 'a-strong-password'; GRANT ALL PRIVILEGES ON *.* TO 'pmaadmin'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; EXIT; </syntaxhighlight>

Log in to phpMyAdmin as pmaadmin.

Security hardening

phpMyAdmin is a frequent target for bots. If the server is reachable from the internet, apply the following.

Restrict access by IP

Edit /etc/apache2/conf-available/phpmyadmin.conf and add this inside the <Directory /usr/share/phpmyadmin> block:

<syntaxhighlight