User Tools

Site Tools


servers:linux:nginx:joomla

This is an old revision of the document!


Information

Prerequisites

Dependencies

Download Source

sudo git clone --branch '7.0-dev' --depth '1' --recurse-submodules 'https://github.com/joomla/joomla-cms.git' '/srv/www/main' && sudo chown -R 'wwwrun':'www' '/srv/www/main' && sudo chmod -R '0705' '/srv/www/main'

Environment

Composer + Node.js

sudo su 'wwwrun' -s '/bin/bash'
cd '/tmp' && '/usr/bin/php' -c '/etc/php8/cli/main.ini' '/usr/bin/composer' --working-dir='/srv/www/main' --no-cache install --no-dev --ignore-platform-req='ext-ldap'
cd '/tmp' && '/usr/bin/node26' '/usr/lib64/node_modules/npm26/bin/npm-cli.js' --prefix '/srv/www/main' 'ci' --verbose
exit

Database

sudo mariadb
CREATE DATABASE joomla_db;
CREATE USER 'joomla'@'localhost' IDENTIFIED BY 'x';
GRANT ALL PRIVILEGES ON joomla_db.* to 'joomla'@'localhost';
FLUSH PRIVILEGES;EXIT;

nginx + PHP-FPM Configuration

PHP-FPM Socket

sudo -e '/etc/php8/fpm/php-fpm.d/main.conf' && sudo systemctl restart 'php-fpm'
[main]
user = "wwwrun"
group = "www"

listen = "/run/php-fpm/main.sock"
listen.owner = "wwwrun"
listen.group = "www"
listen.mode = "0002"

pm = "ondemand"
pm.max_children = "4"
pm.process_idle_timeout = "30"

php_value[log_errors] = "0"
php_value[error_reporting] = "~E_ALL"
php_value[display_errors] = "0"
php_value[display_startup_errors] = "0"
php_value[html_errors] = "0"

php_value[session.save_path] = "/var/lib/php8/sessions"
php_value[date.timezone] = "America/New_York"
php_value[output_buffering] = "0"

php_value[memory_limit] = "128M"
php_value[max_memory_limit] = "256M"
php_value[memory_hard_limit_percent] = "210"
php_value[post_max_size] = "1M"
php_value[upload_max_filesize] = "1M"
php_value[max_file_uploads] = "10"
php_value[max_input_time] = "10"
php_value[max_execution_time] = "10"

; Temp
php_value[session.upload_progress.enabled] = "0"

; End

CLI

sudo -e '/etc/php8/cli/main.ini'
log_errors = "0"
error_reporting = "~E_ALL"
display_errors = "0"
display_startup_errors = "0"
html_errors = "0"

session.save_path = "/var/lib/php8/sessions"
date.timezone = "America/New_York"

output_buffering = "0"

memory_limit = "128M"
max_memory_limit = "256M"
memory_hard_limit_percent = "210"
post_max_size = "1M"
upload_max_filesize = "1M"
max_file_uploads = "10"
max_input_time = "10"
max_execution_time = "10"

; Temp
session.upload_progress.enabled = "0"

; End

FastCGI

sudo -e '/etc/nginx/default.d/main.conf'
location '~' '\.(php|phar)(/.*)?$' {
 fastcgi_split_path_info '^(.+\.(?:php|phar))(/.*)$';
 fastcgi_intercept_errors 'on';
 fastcgi_index 'index.php';
 include 'fastcgi_params';
 fastcgi_param 'SCRIPT_FILENAME' '$document_root$fastcgi_script_name';
 fastcgi_param 'PATH_INFO' '$fastcgi_path_info';
 fastcgi_param 'HTTPS' 'on';
 fastcgi_pass 'unix:/run/php-fpm/main.sock';
}

# End

Server Block

sudo -e '/etc/nginx/vhosts.d/main.conf' && sudo systemctl reload 'nginx'
server {
 listen '443' 'ssl';
 http2 'on';
 server_name 'realmofespionage.xyz';
 root '/srv/www/main';
 index 'index.php';

 include '/etc/nginx/default.d/main.conf';
 include '/etc/nginx/default.d/headers.conf';

 client_max_body_size '1M';

# access_log '/var/log/nginx/main-access.log';
# error_log '/var/log/nginx/main-error.log';

# location '~' '/installation/' {
#  deny 'all';
# }

# location = '/installation/index.php' {
#  deny 'all';
# }

 location '/api/' {
  try_files '$uri' '$uri/' '/api/index.php?$args';
 }

 location '/' {
  try_files '$uri' '$uri/' '/index.php?$args';
 }

 location '~*' '/(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$' {
  return '403';
  error_page '403' '/403_error.html';
 }

 location '~*' '\.(ico|pdf|flv)$' {
  expires '1y';
 }

 location '~*' '\.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$' {
  expires '14d';
 }
}

# End

Initial Setup

  • Disable Automated Updates
  • :!: Don't remove installation folder

Installer Deny

  • Uncomment installation section
  • Do after initial setup
sudo -e '/etc/nginx/vhosts.d/main.conf' && sudo systemctl reload 'nginx'

Compat Extension Fix

sudo rm -fv '/srv/www/main/administrator/cache/autoload_psr4.php'

Settings

  • Disable Sample plugins
  • Trash Guided Tours
  • Site Template Styles → [x] Cassiopeia Extended - Default

Offline Message

This website is being built behind-the-scenes, check back later!
<br>
In the meantime, check out my wiki: <a href="https://wiki.realmofespionage.xyz/">RoE | Wiki</a>
<!--End-->

Color TODO

Custom

Header Background Colour
rgb(61, 139, 255)
3D8BFF

Header Text Colour
rgb(254, 254, 254)
FEFEFE

Body Background Colour
rgb(228, 228, 228)
E4E4E4

 Body Text Colour
 rgb(23, 23, 23)

Links Colour
rgb(254, 254, 254)
FEFEFE

Links Hover Colour
rgb(228, 228, 228)
E4E4E4

 Button Primary Background Colour
 rgb(206, 60, 55)

 Button Primary Hover Background Colour
 rgb(131, 35, 32)

Button Primary Text Colour
rgb(254, 254, 254)
FEFEFE

Button Primary Hover Text Colour
rgb(228, 228, 228)
E4E4E4

Footer Background Colour
rgb(72, 72, 72)
484848

Footer Text Colour 
rgb(254, 254, 254)
FEFEFE

Default

Header Background Colour
rgb(193, 205, 207)

Header Text Colour
rgb(23, 23, 23)

Body Background Colour
rgb(254, 254, 254)

Body Text Colour
rgb(23, 23, 23)

Links Colour
rgb(29, 121, 137)

Links Hover Colour
rgb(14, 59, 67)

Button Primary Background Colour
rgb(206, 60, 55)

Button Primary Hover Background Colour
rgb(131, 35, 32)

Button Primary Text Colour
rgb(254, 254, 254)

Button Primary Hover Text Colour
rgb(254, 254, 254)

Footer Background Colour
rgb(29, 121, 137)

Footer Text Colour 
rgb(254, 254, 254)

System Dashboard

  • Templates → Site Template Styles

Theme Settings

  • FBFAF9 for Body Background Colour
  • Last tested: 2024/02/01 on Joomla 5.1.0-dev, T3 Framework 3.2.0, and Purity III 2.1.0

****

wget -O '/tmp/cc-by-sa-40.png' 'https://licensebuttons.net/l/by-sa/4.0/80x15.png' && sudo mv '/tmp/cc-by-sa-40.png' '/srv/www/main/images/cc-by-sa-40.png' && sudo chown 'nginx':'nginx' '/srv/www/main/images/cc-by-sa-40.png' && sudo restorecon -F -I -R '/srv/www/main/images/cc-by-sa-40.png' && sync
Text
  • Place text within the <section class=“t3-copyright”> section underneath the Bootstrap by Twitter and Font Awesome mentions
  • Remove Bootstrap by Twitter and Font Awesome mentions
sudo -e '/srv/www/main/templates/purity_iii/tpls/blocks/footer.php' && sudo chown 'nginx':'nginx' '/srv/www/main/templates/purity_iii/tpls/blocks/footer.php'
          <small>
            <img src="https://realmofespionage.xyz/images/cc-by-sa-40.png" width="80" height="15" /> All content and data available on Realm of Espionage is available under the <a href="https://creativecommons.org/licenses/by-sa/4.0" target="_blank">Creative Commons Attribution-ShareAlike 4.0 International</a> license.
          </small>

Articles

Home

  • Toggle Editor for raw-HTML paste
<p><br>Welcome! Realm of Espionage is <a href="https://wiki.realmofespionage.xyz/user:espionage724" target="_blank" rel="noopener">my</a> creative space online, and the umbrella name I provide my services under. RoE is entirely self-hosted, in-house, with free and open-source software, and fully-documented in my unique notes style on <a href="https://wiki.realmofespionage.xyz/" target="_blank" rel="noopener">RoE | Wiki</a>, my encyclopedia of technical notes and no-nonsense automation.</p>
<p> </p>
<p>This domain serves as a landing page and provides links to the services I offer, some of my online profiles, and projects showcase. To view them, use the navigation bar (desktop) or the ≡ hamburger icon (mobile) at the top of the screen.</p>
<!-- End -->

Temp

****

<p> </p>
<p>(website is under construction and there aren't any links in the nav bar yet; my <a href="https://wiki.realmofespionage.xyz/">wiki</a> is far-more interesting! <a href="https://wiki.realmofespionage.xyz/user:espionage724">webmaster info</a>, <a href="https://wiki.realmofespionage.xyz/servers:linux:nginx:joomla" target="_blank" rel="noopener">dev notes</a>)</p>
<!-- End -->
  • Main menu headers are: System Links → URL → # to allow tapping as-expected on mobile
  • Icon sizes are 24×24
  • Menu entries should be named normally before saving for a proper alias, and then add a space on the title afterwards to make it look better with the icon

Global Configuration

Site Meta Description

****

Realm of Espionage is my creative space, and the umbrella name I provide my services under. RoE is self-hosted, with free and open-source software, and fully-documented in my unique notes style on "RoE | Wiki", my encyclopedia of technical notes and no-nonsense automation

Content Rights

****

Creative Commons Attribution-ShareAlike 4.0 International

Articles

  • System → Global Configuration → Articles
  • Show Title: Hide
  • Show Category: Hide
  • Show Author: Hide
  • Show Publish Date: Hide
  • Show Navigation: Hide
  • Show Hits: Hide
  • Menus → Main Menu → Home → Link Type → Display in Menu: No
  • Menus → Main Menu → Home → Page Display → Show Page Heading: Hide

Services

Updater

Service

sudo -e '/etc/systemd/system/main-up.service'
[Service]
User=wwwrun
Group=www
Type=oneshot

WorkingDirectory=/tmp
Environment="COMPOSER_CACHE_DIR=/dev/null"
Environment="COMPOSER_DISCARD_CHANGES=true"

ExecStart='/usr/bin/git' -C '/srv/www/main' reset --hard 'origin/7.0-dev'
ExecStart='/usr/bin/git' -C '/srv/www/main' pull origin '7.0-dev' --rebase

ExecStart='/usr/bin/php' -c '/etc/php8/fpm/php-fpm.d/main.conf' '/usr/bin/composer' --working-dir='/srv/www/main' --no-cache install --no-interaction --no-dev --ignore-platform-req='ext-ldap'
ExecStart='/usr/bin/npm' --prefix '/srv/www/main' ci --logs-max='0'

ExecStartPost='/usr/bin/rm' -f '/srv/www/main/administrator/cache/autoload_psr4.php'

# End

Timer

  • Daily 03:00:00 AM
sudo -e '/etc/systemd/system/main-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'main-up.timer' --now && sudo systemctl start 'main-up' && sudo systemctl status 'main-up' -l
[Unit]
Description=Joomla Git Updater
After=network-online.target
Wants=network-online.target

[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true

[Install]
WantedBy=timers.target

# End

Backup

Files

Service

mkdir -p ~/'backups' && sudo -e '/etc/systemd/system/main-fb.service' && sudo sed -i 's/CHANGEME/'$USER'/g' '/etc/systemd/system/main-fb.service'
[Service]
Type=oneshot

WorkingDirectory=/tmp

ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/mnt/NAS1/Servers/Scheduled Backups/joomla-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" -C "/srv/www" "main"'

#ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/joomla-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" -C "/srv/www" "main"'

# End

Timer

  • Monthly (4th) 03:15:00 AM
sudo -e '/etc/systemd/system/main-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'main-fb.timer' --now
[Unit]
Description=Joomla Files Backup

[Timer]
OnCalendar=*-*-04 03:15:00
Persistent=true

[Install]
WantedBy=timers.target

# End
sudo systemctl start 'main-fb' && sudo systemctl status 'main-fb' -l

Database

Database Auth

sudo mkdir -p '/srv/lib/mysql/auth' && sudo -e '/srv/lib/mysql/auth/joomla' && sudo chown 'mysql':'mysql' '/srv/lib/mysql/auth/joomla' && sudo chmod '0600' '/srv/lib/mysql/auth/joomla'
[mariadb-dump]
user=joomla
password=x

# End

Service

mkdir -p ~/'backups' && sudo mkdir -p '/srv/lib/mysql/tmp' && sudo -e '/etc/systemd/system/main-db.service' && sudo sed -i 's/'CHANGEME'/'$USER'/g' '/etc/systemd/system/main-db.service'
[Service]
Group=mysql
Type=oneshot

WorkingDirectory=/tmp

ExecStart='/usr/bin/bash' -c '"/usr/bin/mariadb-dump" --defaults-extra-file="/srv/lib/mysql/auth/joomla" --single-transaction --quick "joomla_db" -r "/mnt/NAS1/Servers/Scheduled Backups/joomla-database-auto-"$$(date +%%Y-%%m-%%d)".sql"'

#ExecStart='/usr/bin/bash' -c '"/usr/bin/mariadb-dump" --defaults-extra-file="/srv/lib/mysql/auth/joomla" --single-transaction --quick "joomla_db" -r "/home/CHANGEME/backups/joomla-database-auto-"$$(date +%%Y-%%m-%%d)".sql"'

# End

Timer

  • Monthly (4th) 03:10:00 AM
sudo -e '/etc/systemd/system/main-db.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'main-db.timer' --now && sudo systemctl start 'main-db' && sudo systemctl status 'main-db' -l
[Unit]
Description=Joomla Database Backup
After=mariadb.service

[Timer]
OnCalendar=*-*-04 03:10:00
Persistent=true

[Install]
WantedBy=timers.target

# End

Maintenance

Service

sudo -e '/etc/systemd/system/main-m.service'
[Service]
User=wwwrun
Group=www
Type=oneshot

WorkingDirectory=/tmp

ExecStart='/usr/bin/git' -C '/srv/www/main' gc --aggressive --prune='all'
ExecStart='/usr/bin/git' -C '/srv/www/main' fsck --full --strict

# End

Timer

  • Monthly (4th) 03:30:00 AM
sudo -e '/etc/systemd/system/main-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'main-m.timer' --now
[Unit]
Description=Joomla Maintenance
After=network-online.target
Wants=network-online.target

[Timer]
OnCalendar=*-*-04 03:30:00
Persistent=true

[Install]
WantedBy=timers.target

# End
sudo systemctl start 'main-m' && sudo systemctl status 'main-m' -l

Backup

Files

sudo tar -czf ~/'joomla-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/srv/www' 'main'

Database

sudo mariadb-dump --single-transaction --quick 'joomla_db' -r ~/'joomla-database-manual-'$(date +%Y-%m-%d)'.sql'

scp

scp espionage724@192.168.1.152:~/'joomla-files-'*'.tar.gz' ~/'Downloads'
scp espionage724@192.168.1.152:~/'joomla-database-'*'.sql' ~/'Downloads'

Restore

scp

scp ~/'Downloads/joomla-files-'*'.tar.gz' espionage724@192.168.1.152:~
scp ~/'Downloads/joomla'*'.sql' espionage724@192.168.1.152:~

Stop nginx

sudo systemctl stop 'nginx'

Remove Existing Files

ls ~/'joomla-files-'*'.tar.gz' && sudo rm -Rf '/srv/www/main'

Restore Files

sudo tar -xzf ~/'joomla-files-'*'.tar.gz' -C '/srv/www' 'main' && sudo chown -R 'wwwrun':'www' '/srv/www/main' && sudo chmod -R '0705' '/srv/www/main'

Git Fix

  • :!: Set user.email
sudo su 'wwwrun' -s '/bin/bash'
cd '/tmp' && rm -Rf '/srv/www/main/.git'
git -C '/srv/www/main' init --initial-branch='7.0-dev'
git -C '/srv/www/main' add '.'
git -C '/srv/www/main' config 'user.email' 'espionage724@x'
git -C '/srv/www/main' commit --message='x'
git -C '/srv/www/main' remote add 'origin' 'https://github.com/joomla/joomla-cms.git'
git -C '/srv/www/main' pull --depth '1' --recurse-submodules 'origin' '7.0-dev' --rebase
git -C '/srv/www/main' reset --hard 'origin/7.0-dev'
git -C '/srv/www/main' gc --aggressive --prune='all'
git -C '/srv/www/main' fsck --full --strict
exit

Restore Database

sudo mariadb --execute='DROP DATABASE joomla_db;'
sudo mariadb --execute='CREATE DATABASE joomla_db;'
sudo mariadb 'joomla_db' < ~/'joomla'*'.sql'

Start nginx

sudo systemctl start 'nginx'

Clean-up

rm -fv ~/'joomla-files-'*'.tar.gz' ~/'joomla'*'.sql'
/srv/www/wiki/data/attic/servers/linux/nginx/joomla.1794879669.txt.gz · Last modified: by Sean Rhone