Installing MySQL

The most popular tool to manage MySQL is phpMyAdmin. We will install these two
and then test the installation. This can take up to 15 minutes.
sudo apt-get update
sudo apt-get install mysql-server
You will be presented with blue-background screens asking you for the root
user password. You should write these down or store them in an application
like KeePass.

The MySQL root user must never be used by web applications, especially production
ones available on the Internet. The phpMyAdmin application needs to run with root
settings so that it can fully manage MySQL. The best practice for phpMyAdmin is
to only allow local network connections. This is because it will be used to create
or delete databases, users, and passwords and apply a permission access to
those databases.
sudo apt-get install phpMyAdmin
PhpMyAdmin is a complex web application that uses many files and PHP libraries to
allow you to manage MySQL and the databases found within.

During installation, you get another blue screen asking for the web server that
should be automatically configured. Regrettably, nginx is not on the list, so click on
OK. After a short while, a final screen will ask about dbconfig-commin; click on NO.

We need to manually configure phpMyAdmin just like any other website for nginx.
PhpMyAdmin places its files in the shared location /usr/share/phpmyadmin, and
anyone with access to the system and the username and password can use this
shared site to access only their database.

In sites-available, create a new file called phpmyadmin and use the following
configuration. Don't forget to create a symbolic link in sites-enabled and
reload nginx.
server {
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;
}
}
You can now browse to http://pi/phpmyadmin/setup and follow the onscreen
instructions to get the most up-to-date and best practice information to set up
everything correctly and securely.

No comments:

Post a Comment