APACHE, MYSQL, PHP, PHPMyAdmin INSTALLATION COMMANDS
Tags: ubuntu, linux, php, devops
Published: 2023-10-28 12:23:02


**INSTALL APACHE2 **

sudo apt install apache2 -y
sudo systemctl status apache2


**INSTALL MYSQL**

sudo apt update
sudo apt-get install mysql-server
systemctl is-active mysql
sudo mysql
rootuser:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '^$kydtyo)&E%sss';
FLUSH PRIVILEGES;

User: 
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'jE$!1p$ka0FuSY(&$HJ';  (passowrd must be strong)
GRANT ALL PRIVILEGES ON * . * TO 'admin'@'localhost';
FLUSH PRIVILEGES;

**INSTALL PHP**

sudo apt update
sudo apt install software-properties-common apt-transport-https -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install php7.4 php7.4-common libapache2-mod-php7.4 php7.4-cli
sudo systemctl restart apache2
sudo apt install php7.4-fpm php7.4-common libapache2-mod-fcgid php7.4-cli
sudo a2enmod proxy_fcgi setenvif && sudo a2enconf php7.4-fpm
sudo systemctl restart apache2
systemctl status php7.4-fpm




**INSTAL PHPMYADMIN ** 

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

tar xvf phpMyAdmin-latest-all-languages.tar.gz

sudo mv phpMyAdmin-*/ /usr/share/phpmyadmin

sudo mkdir -p /var/lib/phpmyadmin/tmp
sudo chown -R www-data:www-data /var/lib/phpmyadmin

sudo mkdir /etc/phpmyadmin/

sudo cp /usr/share/phpmyadmin/config.sample.inc.php  /usr/share/phpmyadmin/config.inc.php

 sudo nano /usr/share/phpmyadmin/config.inc.php

add this key 
$cfg['blowfish_secret'] = 'H2OxcGXxflSd8JwrwVlh6KW6s2rER63i';

add temp path
$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';

sudo nano /etc/apache2/conf-enabled/phpmyadmin.conf

paste belw code


```
Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php
    <IfModule mod_php5.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
        php_admin_value mbstring.func_overload 0
    </IfModule>
    <IfModule mod_php.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
        php_admin_value mbstring.func_overload 0
    </IfModule>
</Directory>
# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authz_core.c>
        <IfModule mod_authn_file.c>
            AuthType Basic
            AuthName "phpMyAdmin Setup"
            AuthUserFile /etc/phpmyadmin/htpasswd.setup
        </IfModule>
        Require valid-user
    </IfModule>
</Directory>
# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/templates>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Require all denied
</Directory>
```



sudo systemctl restart apache2

http://localhost/phpmyadmin/