UBUNTU 22.04
You can find this in my GitHub
$ sudo systemctl enable apache2
$ sudo systemctl restart apache2
$ sudo apt install mariadb-server mariadb-client
$ sudo systemctl enable --now mariadb
SECURE MARIADB INSTALLATION
Enter current password for root (enter for none): Press ENTER.
Switch to unix_socket authentication? Press N, then ENTER.
Change the root password? Press Y, then ENTER.
Remove anonymous users? Press Y, then ENTER.
Disallow root login remotely? Press Y, then ENTER.
Remove test database and access to it? Press Y, then ENTER.
Reload privilege tables now? Press Y, then ENTER.
INSTALL PHP AND DOWNLOAD phpmyadmin
$ sudo systemctl enable php8.1-fpm --now
$ wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
$ tar xvf phpMyAdmin-*-all-languages.tar.gz
$ sudo mv phpMyAdmin-*/ /var/www/html/phpmyadmin
$ sudo mkdir -p /var/www/html/phpmyadmin/tmp
$ sudo cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php
KEY GENERATION FOR config.inc.php
Run the next command and the result copy and paste in the config.inc.php
$ openssl rand -base64 32$ sudo nano /var/www/html/phpmyadmin/config.inc.php
$cfg[‘blowfish_secret’] = ‘your-key‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
Also, scroll down to the end and add this line.
$cfg['TempDir'] = '/var/www/html/phpmyadmin/tmp';
After that save your file by pressing Ctrl+O, hit the Enter key, and then exit the file editor- Ctrl+X.
$ sudo chown -R www-data:www-data /var/www/html/phpmyadmin
$ sudo find /var/www/html/phpmyadmin/ -type d -exec chmod 755 {} \;
$ sudo find /var/www/html/phpmyadmin/ -type f -exec chmod 644 {} \;
Now, create Apache Vhost configuration file, phpmyadmin.conf
$ sudo vim /etc/apache2/conf-available/phpmyadmin.conf
Alias /phpmyadmin /var/www/html/phpmyadmin
<Directory /var/www/html/phpmyadmin>
Options Indexes FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php8.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IfModule>
</Directory>
# Authorize for setup
<Directory /var/www/html/phpmyadmin/setup>
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
Require valid-user
</Directory>
# Disallow web access to directories that don't need it
<Directory /var/www/html/phpmyadmin/libraries>
Order Deny,Allow
Deny from All
</Directory>
<Directory /var/www/html/phpmyadmin/setup/lib>
Order Deny,Allow
Deny from All
</Directory>
$ sudo a2enconf phpmyadmin.conf
$ sudo systemctl restart apache2
Open the browser
http://localhost/phpmyadmin
Note: If you get this notification at the footer – The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why. Or alternately go to the ‘Operations’ tab of any database to set it up there.
Then simply click on the Find out why link and click the “Create” link to automatically create phpmyadmin database.
DJANGO
$ usermod -aG sudo Gerardo
$ mkdir ~/project
$ cd ~/project
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install django
$ django-admin startproject project .
$ vim project/settings.py
ADD
ALLOWED_HOSTS = ['server_domain_or_IP','localhost', '0.0.0.0'']
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
$ ./manage.py makemigrations
$ ./manage.py collectstatic
$ ./manage.py runserver 0.0.0.0:8000
In the terminal
Ctrl + c
q
$ deactivate
$ sudo chown :www-data -R project/
$ chmod 664 ~/project/db.sqlite3
$ sudo adduser www-data $(whoami)
$ chmod 775 -R project
Create project.conf
$ sudo vim /etc/apache2/conf-available/project.conf
<VirtualHost *:80>
Alias /static /home/gerardo/project/static
<Directory /home/gerardo/project/static>
Require all granted
</Directory>
<Directory /home/gerardo/project/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess project python-home=/home/gerardo/project/venv python-path=/home/gerardo/project user=gerardo group=www-data processes=2 threads=25
WSGIProcessGroup project
WSGIScriptAlias / /home/gerardo/project/project/wsgi.py
</VirtualHost>
Add the virtual host
$ sudo a2enconf project.conf$ sudo apache2ctl configtest
$ systemctl reload apache2
Open the browser
http://localhost/