Labels

Android (1) bash (2) boost (2) C (34) C++ (2) cheatsheet (2) CLion (6) css (3) Debian (33) DL (17) Docker (2) Dreamweaver (2) Eclipse (3) fail2ban (4) git (5) GitHub (4) Hacking (3) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (31) javascript (3) Linux (167) Mac (19) Machine Learning (1) mySQL (48) Netbeans (4) Networking (1) Nexus (1) OpenVMS (6) Oracle (1) Pandas (3) php (16) Postgresql (8) Python (9) raid (1) RedHat (14) Samba (2) Slackware (47) SQL (14) svn (1) tar (1) ThinkPad (1) Virtualbox (3) Visual Basic (1) Visual Studio (1) Windows (2)

Friday, 25 September 2020

Apache, php, mySQL and phpMyAdmin install on Debian

See also here for Slackware configuration.

To install and configure apache, MySQL and phpMyAdmin


1st, we need to install some stuff...

UPDATE: Get install scripts here [requires password]

Install Apache


sudo apt install wget 

sudo apt install apache2 

Check status;

systemctl status apache2

Install php


sudo apt install php php-cgi php-mysqli php-pear php-mbstring php-gettext libapache2-mod-php php-common php-phpseclib php-mysql -y

php-gettext is questionable (needs checking)

Check php version;

php --version

Install mysql or mariadb


sudo apt install mariadb-server mariadb-client -y

Check status;

systemctl status mariadb

Now to secure MariaDB;

sudo mysql_secure_installation

answer as follows;

 Set root password? [Y/n] – y
 Remove anonymous users? [Y/n] – y
 Disallow root login remotely? [Y/n] – y
 Remove test database and access to it? [Y/n] – y
 Reload privilege tables now? [Y/n] – y

NOTE: To enable connecting from a remote host, we must either comment out bind-address in the my.cnf file or whichever file contains the [mysqld] section.
On Debian, this was found to be /etc/mysql/mariadb.conf.g/50-server.cnf
This used to be a matter of commenting out SKIP="--skip-networking" in a similar config file or in the case of my Slackware installs, it would have resided in the start up script /etc/rc.d/rc.mysql

Create a new DB user;


Firstly, login to database;

sudo mysql -u root

If your root user has a password, do;

sudo mysql -u root -p

CREATE DATABASE 'DB_name';

SHOW DATABASES;

To add a user;

CREATE USER 'user'@localhost IDENTIFIED BY 'password';

SELECT User FROM mysql.user;

GRANT ALL PRIVILEGES ON *.* TO 'user'@localhost IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON 'DB_name'.* TO 'user'@localhost;

FLUSH PRIVILEGES;

SHOW GRANTS FOR 'user'@localhost;

To remove a user;

DROP USER 'user'@localhost;

See my post here 

and also


for information on libmysql++-dev or /usr/include/mysql++.h

Download and install phpMyAdmin


wget -P Downloads https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

keyring thing if that floats your boat and all that;

 wget -P Downloads https://files.phpmyadmin.net/phpmyadmin.keyring

 cd Downloads

 gpg --import phpmyadmin.keyring

 wget -P Downloads https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz.asc

 cd Downloads [may not be required]

 gpg --verify phpMyAdmin-latest-all-languages.tar.gz.asc

sudo mkdir /var/www/html/phpMyAdmin

cd Downloads [may not be required]

sudo tar xvf phpMyAdmin* --strip-components=1 -C /var/www/html/php*

sudo cp /var/www/html/phpMyAdmin/config.sample.inc.php /var/www/html/phpMyAdmin/config.inc.php

sudo vim /var/www/html/phpMyAdmin/config.inc.php

Find $cfg['blowfish_secret'] = ''; and edit it adding a password like;

$cfg['blowfish_secret'] = 'my_password';

It's also worth noting that if the database is running on an IP that's not 127.0.0.1 then we should also change this in the config.inc.php file
 
sudo chmod 644 /var/www/html/phpMyAdmin/config.inc.php

sudo chown -R www-data:www-data /var/www/html/php*

I also like to rename config.sample.inc.php

mv /var/www/html/phpMyAdmin/config.sample.inc.php /var/www/html/phpMyAdmin/config.sample.inc.OLD.php

There was an issue on Debian whereby I could login to phpmyadmin and see the database tables but could not actually see any of the data, even though the tables contained data. when running a query against said tables, there was an error, similar to Connection for controluser as defined in your configuration failed.
This was resolved by running;
 
 dfgk-reconfigure phpmyadmin 
 


Finally restart Apache:

sudo systemctl restart apache2



No comments:

Post a Comment

Note: only a member of this blog may post a comment.