Installing PHPMyAdmin on nginx ubuntu
First command to update ubuntu or Debian
-
install with 1 command
sudo apt-get update
sudo apt-get install phpmyadmin
While installation
default configuration for lighttpd and apache
press tab to leave. or
Press Esc because NGINX is not on the list provided.
Configure database for phpmyadmin with dbconfig-common?
PhpMyAdmin requires a database to work with. In this package configuration prompt, choose Yes
dbconfig-common package
│ <Yes> <No>
Enter mysql password if you chose yes for DB Config
Configuring NGINX to Serve PhpMyAdmin Site
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
optiona1 security
sudo ln -s /usr/share/phpmyadmin /var/www/html/secretword
$ sudo chmod 775 -R /usr/share/phpmyadmin/
$ sudo chown root:www-data -R /usr/share/phpmyadmin/
reload restart nginx web server
sudo systemctl restart nginx
or
nginx -s reload
Test Phpmyadmin installation
serverip/phpmyadmin
sudo phpenmod mcrypt
WARNING: Module mcrypt ini file doesn’t exist under /etc/php/7.1/mods-available
sudo apt install php7.1-mcrypt && sudo apt install php7.1-mbstring
Setting up php7.1-mcrypt (7.1.9-1+ubuntu16.04.1+deb.sury.org+1) …
Creating config file /etc/php/7.1/mods-available/mcrypt.ini with new version
php7.1-mbstring is already the newest version
sudo a2enmod mcrypt
ERROR: Module mcrypt does not exist!
sudo ln -s /etc/php/7.1/conf.d/mcrypt.ini /etc/php/7.1/mods-available/mcrypt.ini
failed to create symbolic link ‘/etc/php/7.1/mods-available/mcrypt.ini’: Fil e exists
Then enable them with:
sudo a2enmod mcrypt
sudo a2enmod mbstring
sudo service php7.4-fpm restart
Secure phpmyadmin installation – step 2.1
sudo ln -s /usr/share/phpmyadmin /var/www/html/secret
sudo nano /etc/nginx/snippets/phpmyadmin.conf
location /secret {
root /var/www/html;
index index.php;
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$args;
location ~ ^/secret/(doc|sql|setup)/ {
deny all;
}
location ~ /secret/(.+\.php)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
or basic step 2.1 phpmyadmin nginx configuration
sudo nano /etc/nginx/snippets/phpmyadmin.conf
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
Step 3
include snippets/phpmyadmin.conf;
include snippets/phpmyadmin.conf;
include snippets/sqlc.conf;
errors may occurs
[error] 2562720#2562720: *24086422 open() “/usr/share/phpmyadmin/sqlc” failed (2: No such file or directory), client: 103.228.33.114, server: rajugi2ne.com, request: “GET /sqlc HTTP/1.1”, host: “194.195.113.187”
2021/12/31 13:03:52 [notice] 2562770#2562770: signal process started
in default server block or any domain.
sudo apt-get install php7.4-mbstring
phpmyadmin location in ubnutu
/usr/share/phpmyadmin
Create symbolic link
sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html
or
sudo ln -s /usr/share/phpmyadmin /var/www/html/secret
Assign www user to & file permission
$ sudo chmod 775 -R /usr/share/phpmyadmin/
$ sudo chown root:www-data -R /usr/share/phpmyadmin/
cd /usr/share/nginx/html && ls -l
-rw-r–r– 1 root root 612 Jan 31 2017 index.html
lrwxrwxrwx 1 root root 21 Sep 27 06:04 phpMyAdmin -> /usr/share/phpmyadmin
part 3 nginx server block for phpmyadmin
sudo nano /etc/nginx/sites-available/default
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
save changes
service nginx restart
or nginx -s reload
Securing phpmyadmin login page
cd /usr/share/nginx/html && ls -l
-rw-r–r– 1 root root 612 Jan 31 2017 index.html
lrwxrwxrwx 1 root root 21 Sep 27 06:04 phpMyAdmin -> /usr/share/phpmyadmin
renaming phpmyadmin
sudo mv phpmyadmin Desired Name
or
sudo ln -s /usr/share/phpmyadmin /var/www/html/secret
next add root location for server block.
server block
modify
Addthis
Htaccess password in nginx using crypt()
Look at digital ocean
Youtube video tutorial
2nd & easy way to configure phpmyadmin var/www/html nginx
install phpmyadmin
symlic phpmyadmin folder to var/www/html
add server block to /var/www/html
access phpmyadmin page from browser.
filepermission & owner is optional.
install phpmyadmin apache2 Debian
sudo apt-get install phpmyadmin
two alerts
1 configure DB or not
install apache Lighttpd (select apache).
[php7:error] [pid 7626] [client 123.201.77.106:10105] PHP Fatal error: Uncaught Error: Call to undefined function __() in /usr/share/phpmyadmin/libraries/core.lib.php:235\nStack trace:\n#0 /usr/share/phpmyadmin/libraries/core.lib.php(308): PMA_fatalError(‘The [a@./url.ph…’)\n#1 /usr/share/phpmyadmin/libraries/common.inc.php(90): PMA_warnMissingExtension(‘mbstring’, true)\n#2 /usr/share/phpmyadmin/index.php(12): require_once(‘/usr/share/phpm…’)\n#3 {main}\n thrown in /usr/share/phpmyadmin/libraries/core.lib.php on line 235
500 internal server occurrs
if
then go /var/log/apache2/error.log
sudo apt-get install php-mbstring
sudo service apache2 restart
Then open your ip/phpmyadmin
if not worked then try this
sudo nano /etc/php/7.0/apache2/php.ini
Then uncomment
;extension=php_mbstring.dll or use this command sudo phpenmod mbstring
Secure or rename page
sudo nano /etc/phpmyadmin/apache.conf
Alias /phpmyadmin /usr/share/phpmyadmin to
Alias /secretword /usr/share/phpmyadmin
service apache2 reload
now your new phpmyadmin login url is ip/secretword.
troubleshooting
mysqli_real_connect(): (HY000/1045): Access denied for user ‘phpmyadmin’@’localhost’ (using password: YES)
Create a database named ‘phpmyadmin’ and setup the phpMyAdmin configuration storage there.
no db or no user.
/etc/phpmyadmin/config.inc.php
$cfg[‘Servers’][$i][‘controluser’] = $dbuser;
$cfg[‘Servers’][$i][‘controlpass’] = $dbpass;
/* Optional: Advanced phpMyAdmin features */
$cfg[‘Servers’][$i][‘pmadb’] = $dbname;
/etc/phpmyadmin/config-db.php
$dbuser=’phpmyadmin’;
$dbpass=’pass’;
$basepath=”;
$dbname=’phpmyadmin’;
$dbserver=’localhost’;
$dbport=’3306′;
$dbtype=’mysql’;
mysql> CREATE USER ‘phpmyadmin’@’%’ IDENTIFIED BY ‘pass’ ;
mysql> CREATE USER ‘p’@’%’ IDENTIFIED BY ‘MyPasswordHere!
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘phpmyadmin’@’%’ WITH GRANT OPTION;
onfiguration of pmadb… not OK
Database export & import using Phpmyadmin
There is web server limits for phpmyadmin max file upload size and max execution time. so reupload same dump it will continue further.
export database:
just select all tables,
select export and
click on Go.
Drop / deleting a database in Phpmyadmin
Select database >> goto >> Operation>>
CLick on Drop Database.
Copying database in Phpmyadmin
go to operations >> select copy database to new or existing.
Copy tables to another database using in phpmyadmin
Select database and go operations and click on copy table to another database.
CHange table charset and collation in phpmyadmin
you can do in phpmyadmin panel, select table or database change collation settings.
Configuring Password Access for the MySQL Root Account
SELECT user,authentication_string,plugin,host FROM mysql.user;
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH caching_sha2_password BY ‘password’;
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
SELECT user,authentication_string,plugin,host FROM mysql.user;
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
SELECT user,authentication_string,plugin,host FROM mysql.user;
CREATE USER ‘sammy’@’localhost’ IDENTIFIED WITH caching_sha2_password BY ‘password’;
ALTER USER ‘sammy’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
GRANT ALL PRIVILEGES ON *.* TO ‘sammy’@’localhost’ WITH GRANT OPTION;
FInd replace in mysql phpmyadmin
troubleshoot
2022/11/14 05:54:17 [error] 10407#10407: *2768 FastCGI sent in stderr: “PHP message: phpmyadmin: Failed to load /var/lib/phpmyadmin/blowfish_secret.inc.php Check group www-data has read access and open_basedir restrictions” while reading response header from upstream, client: 103.228.33.114, server: rajugi2ne.com, request: “GET /phpmyadmin/index.php?route=/recent-table&ajax_request=1&recent_table=1&no_debug=true&_nocache=1668405256620516619&token=4169763f3147544c4266475c4a22597e HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “159.65.149.73”