User Tools

Site Tools


servers:bsd:nginx:joomla

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
servers:bsd:nginx:joomla [2025/05/16 23:00] – sass and cypress don't support freebsd Sean Rhoneservers:bsd:nginx:joomla [2026/02/21 22:55] (current) Sean Rhone
Line 1: Line 1:
 +====== Information ======
 +
 +  * Joomla ((https://www.joomla.org))
 +  * [[Information:Realm of Espionage]]
 +  * https://realmofespionage.xyz
 +
 +  * :!: Previously failed with Cypress and Sass, but they look like [[https://github.com/joomla/joomla-cms/blob/aa58dfce5866faadffbc97d7223b34bbcb169c26/package.json#L97|dev dependencies]] and possibly optional with ''--production'' ([[https://stackoverflow.com/questions/60065865/is-there-a-way-of-making-npm-ci-install-devdependencies-or-npm-install-not/61364681#61364681|source]])
 +
 +===== Prerequisites =====
 +
 +  * [[bsd:server:freebsd_14.2|FreeBSD 14.2]]
 +  * [[servers:bsd:mariadb|MariaDB]]
 +  * [[servers:bsd:nginx_php_php-fpm|nginx + PHP + PHP-FPM]]
 +  * [[servers:bsd:nginx:lets_encrypt|Let's Encrypt]]
 +
 +====== Dependencies ======
 +
 +  * https://docs.joomla.org/What_version_of_Joomla!_should_you_use%3F
 +  * https://docs.joomla.org/Special:MyLanguage/J5.x:Setting_Up_Your_Local_Environment
 +  * https://manual.joomla.org/docs/next/get-started/technical-requirements/
 +  * https://docs.joomla.org/J5.x:Optional_Technical_Requirements
 +
 +  su -
 +
 +  pkg install git-lite php84-mysqli php84-composer node23 npm-node23 php84-simplexml php84-dom php84-iconv php84-sodium
 +
 +====== Download Source ======
 +
 +  * https://github.com/joomla/joomla-cms/commits/6.0-dev/
 +  * https://github.com/joomla/joomla-cms/branches
 +
 +  su -
 +
 +  git clone --branch '6.0-dev' --depth '1' --recurse-submodules 'https://github.com/joomla/joomla-cms.git' '/usr/local/www/main' && chown -R 'www':'www' '/usr/local/www/main' && sync
 +
 +====== Environment ======
 +
 +  * https://docs.joomla.org/Special:MyLanguage/J5.x:Setting_Up_Your_Local_Environment
 +
 +===== Composer =====
 +
 +  su -
 +
 +  cd '/usr/local/www/main' && su -m 'www' -c "'/usr/local/bin/composer' install --ignore-platform-req='ext-ldap' --no-dev"
 +
 +===== Node.js =====
 +
 +  su -
 +
 +  cd '/usr/local/www/main' && su -m 'www' -c "'/usr/local/bin/npm' ci --verbose --cache '/tmp/main' --ignore-scripts"
 +
 +====== Databases ======
 +
 +  mariadb -u 'root' -p
 +
 +  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 =====
 +
 +  su -
 +
 +  ee '/usr/local/etc/php-fpm.d/main.conf' && service 'php_fpm' restart
 +
 +<code>
 +[main]
 +
 +; User/Group
 +user = www
 +group = www
 +
 +; Socket
 +listen = 127.0.0.1:9001
 +listen.allowed_clients = 127.0.0.1
 +
 +; Process Management
 +pm = ondemand
 +pm.max_children = 4
 +pm.process_idle_timeout = 30
 +
 +; General
 +php_value[date.timezone] = "America/New_York"
 +
 +; End</code>
 +
 +===== FastCGI =====
 +
 +  su -
 +
 +  ee '/usr/local/etc/nginx/default.d/main.conf'
 +
 +<code>
 +# PHP-FPM
 +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 127.0.0.1:9001;
 +}
 +
 +# End</code>
 +
 +===== Server Block =====
 +
 +  su -
 +
 +  ee '/usr/local/etc/nginx/vhosts.d/main.conf' && service 'nginx' reload && sync
 +
 +<code>
 +server {
 +    listen 443 ssl;
 +#    http2 on;
 +    server_name 'realmofespionage.xyz';
 +    root '/usr/local/www/main';
 +    index 'index.php';
 +
 +    include '/usr/local/etc/nginx/default.d/main.conf';
 +    include '/usr/local/etc/nginx/default.d/headers.conf';
 +
 +    client_max_body_size '30M';
 +
 +#    add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'" always;
 +
 +#    access_log  /var/log/nginx/main-access.log;
 +#    error_log  /var/log/nginx/main-error.log;
 +
 +    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;
 +    }
 + 
 +}</code>
 +
 +====== Initial Setup ======
 +
 +  * https://realmofespionage.xyz
 +  * :!: If Joomla gives a 500 error, it's likely the ''sessions'' folder not having the right permissions, see [[servers:linux:nginx_php_php-fpm#permissions|nginx - Permissions]]
 +
 +====== Settings ======
 +
 +===== Purity III Template =====
 +
 +  * [[https://www.joomlart.com/joomla/templates/purity-iii|Purity III]]
 +
 +==== Install ====
 +
 +  * [[https://www.joomlart.com/member/downloads/joomlart/free-templates/purity-iii|Downloads]]
 +  * Download **Purity III Template** and **T3 System Plugin** (:!: not 20 MB+ quickstarts; **not** ''Purity III for Joomla 5'')
 +
 +==== System Dashboard ====
 +
 +  * Templates -> Site Template Styles
 +  * Set ''purity_III - Default'' to Default
 +
 +==== Theme Settings ====
 +
 +  * General -> Show T3 Logo: Off
 +
 +  * Theme -> Logo Type: Text
 +  * Theme -> Site Name: ''Realm of Espionage''
 +
 +  * Navigation -> Megamenu Configuration -> Animation: Fading
 +  * Navigation -> Megamenu Configuration -> Duration: ''300''
 +
 +  * Add-ons -> Off-canvas Sidebar -> Enable: Off
 +
 +  * Assignment -> Toggle Selection
 +
 +==== Footer ====
 +
 +=== Copyright ===
 +
 +  * Last tested: 2024/02/01 on Joomla 5.1.0-dev, T3 Framework 3.2.0, and Purity III 2.1.0
 +
 +== Logo ==
 +
 +****
 +
 +  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' '/var/www/main/images/cc-by-sa-40.png' && sudo chown 'nginx':'nginx' '/var/www/main/images/cc-by-sa-40.png' && sudo restorecon -F -I -R '/var/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 '/var/www/main/templates/purity_iii/tpls/blocks/footer.php' && sudo chown 'nginx':'nginx' '/var/www/main/templates/purity_iii/tpls/blocks/footer.php'
 +
 +<code>
 +          <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></code>
 +
 +==== Custom CSS ====
 +
 +  * :!: This shrinks the footer height, and places it back at the bottom of the screen instead of floating half-way up the page when little content exists ([[https://www.joomlart.com/forums/topic/footer-on-bottom-of-screen-not-sticky/#post-898349|source 1]], [[https://www.joomlart.com/documentation/joomla-faqs/css-related-issues#footer-sticky|source 2]])
 +  * Also replaces ThemeMagic for Brand Primary Color, Footer Background, and Footer Text Color
 +
 +  * Last tested: 2024/02/01 on Joomla 5.1.0-dev, T3 Framework 3.2.0, and Purity III 2.1.0
 +
 +  sudo -e '/var/www/main/templates/purity_iii/css/custom.css' && sudo chown 'nginx':'nginx' '/var/www/main/templates/purity_iii/css/custom.css'
 +
 +<code>
 +html,
 +
 +body {
 +  height: 100%;
 +}
 +
 +a {
 +  color: #3D8BFF;
 +}
 +
 +a:hover {
 +  color: #196BE4;
 +}
 +
 +.t3-mainnav {
 +  background-color: #3D8BFF;
 +}
 +
 +.logo a {
 +  background: none;
 +}
 +
 +.logo a:hover {
 +  background: #196BE4;
 +}
 +
 +.t3-wrapper {
 +  position: relative;
 +  min-height: 100%;
 +}
 +
 +.t3-footer {
 +  position: absolute;
 +  bottom: 0;
 +  left: 0;
 +  right: 0;
 +  background-color: #484848;
 +  color: #FFFFFF;
 +}
 +
 +.t3-copyright {
 +  padding-top: 20px;
 +  padding-bottom: 0px;
 +}</code>
 +
 +===== Articles =====
 +
 +==== Home ====
 +
 +  * Toggle Editor for raw-HTML paste
 +
 +<code>
 +<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 --></code>
 +
 +=== Temp ===
 +
 +****
 +
 +<code>
 +<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 --></code>
 +
 +===== Offline Message =====
 +
 +<code>
 +This site 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></code>
 +
 +===== Menus =====
 +
 +  * Main menu headers are: System Links -> URL -> ''#'' to allow tapping as-expected on mobile
 +  * Icon sizes are 24x24
 +  * 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 ====
 +
 +****
 +
 +<code>
 +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</code>
 +
 +==== 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
 +
 +==== Menu ====
 +
 +  * Menus -> Main Menu -> Home -> Link Type -> Display in Menu: No
 +  * Menus -> Main Menu -> Home -> Page Display -> Show Page Heading: Hide
 +
 +====== Services ======
 +
 +===== Updater =====
 +
 +==== Service ====
 +
 +  * 2023/09/12: TODO: SELinux prevents various actions with ''npm''; is it needed?
 +  * ''5.3-dev'' branch
 +
 +  sudo -e '/etc/systemd/system/main-up.service'
 +
 +<code>
 +[Service]
 +User=nginx
 +Group=nginx
 +Type=oneshot
 +WorkingDirectory=/var/www/main
 +Environment="COMPOSER_CACHE_DIR=/dev/null"
 +ExecStart='/usr/bin/git' -C '/var/www/main' pull origin '5.3-dev'
 +ExecStart='/usr/bin/composer' install
 +#ExecStart='/usr/bin/npm' ci --logs-max='0'
 +#ExecStart='/usr/bin/npm' audit fix --audit-level='none' --logs-max='0'
 +ExecStartPost='/usr/bin/sync'</code>
 +
 +==== Timer ====
 +
 +  * Every day at ''02:00:00''
 +
 +  sudo -e '/etc/systemd/system/main-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'main-up.timer' --now
 +
 +<code>
 +[Unit]
 +Description=Joomla Git Updater
 +After=network-online.target
 +Wants=network-online.target
 +
 +[Timer]
 +OnCalendar=*-*-* 02:00:00
 +Persistent=true
 +
 +[Install]
 +WantedBy=timers.target</code>
 +
 +===== Maintenance =====
 +
 +==== Service ====
 +
 +  sudo -e '/etc/systemd/system/main-m.service'
 +
 +<code>
 +[Service]
 +User=nginx
 +Group=nginx
 +Type=oneshot
 +ExecStart='/usr/bin/git' -C '/var/www/main' gc --aggressive --prune='all'
 +ExecStart='/usr/bin/git' -C '/var/www/main' fsck --full --strict
 +ExecStartPost='/usr/bin/sync'</code>
 +
 +==== Timer ====
 +
 +  * ''01'' day of every month at ''02:20:00''
 +
 +  sudo -e '/etc/systemd/system/main-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'main-m.timer' --now
 +
 +<code>
 +[Unit]
 +Description=Joomla Maintenance
 +After=network-online.target
 +Wants=network-online.target
 +
 +[Timer]
 +OnCalendar=*-*-01 02:20:00
 +Persistent=true
 +
 +[Install]
 +WantedBy=timers.target</code>
 +
 +===== Backup =====
 +
 +==== Files ====
 +
 +=== Service ===
 +
 +  * The extra ''ExecStart'' is an additional backup location that expects [[servers:linux:vsftpd#fstab1|vsftpd - fstab]]
 +
 +  mkdir -p ~/'backups' && sudo -e '/etc/systemd/system/main-fb.service' && sudo sed -i 's/CHANGEME/'$USER'/g' '/etc/systemd/system/main-fb.service'
 +
 +<code>
 +[Service]
 +Type=oneshot
 +WorkingDirectory=/var/www
 +ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/joomla-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "main"'
 +#ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/var/ftp/nas1/Servers/Scheduled Backups/joomla-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "main"'
 +ExecStartPost='/usr/bin/sync'</code>
 +
 +=== Timer ===
 +
 +  * ''01'' day of every month at ''02:35:00''
 +
 +  sudo -e '/etc/systemd/system/main-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'main-fb.timer' --now && sudo systemctl start 'main-fb' && sudo systemctl status 'main-fb' -l
 +
 +<code>
 +[Unit]
 +Description=Joomla Files Backup
 +
 +[Timer]
 +OnCalendar=*-*-01 02:35:00
 +Persistent=true
 +
 +[Install]
 +WantedBy=timers.target</code>
 +
 +==== Database ====
 +
 +=== Database Auth ===
 +
 +  sudo mkdir -p '/var/lib/mysql/auth' && sudo -e '/var/lib/mysql/auth/joomla' && sudo chown -R 'mysql':'mysql' '/var/lib/mysql/auth/joomla' && sudo chmod '600' '/var/lib/mysql/auth/joomla' && sync
 +
 +<code>
 +[mariadb-dump]
 +user=joomla
 +password=x</code>
 +
 +=== Service ===
 +
 +  mkdir -p ~/'backups' && sudo mkdir -p '/var/lib/mysql/tmp' && sudo chown -R 'mysql':'mysql' '/var/lib/mysql/tmp' && sudo chmod '600' '/var/lib/mysql/tmp' && sudo -e '/etc/systemd/system/main-db.service' && sudo sed -i 's/'CHANGEME'/'$USER'/g' '/etc/systemd/system/main-db.service'
 +
 +<code>
 +[Service]
 +Type=oneshot
 +WorkingDirectory=/var/lib/mysql/tmp
 +ExecStartPre='/usr/bin/mariadb-dump' --defaults-extra-file='/var/lib/mysql/auth/joomla' --single-transaction 'joomla_db' -r '/var/lib/mysql/tmp/joomla.sql'
 +ExecStart='/usr/bin/gzip' -f '/var/lib/mysql/tmp/joomla.sql'
 +ExecStart='/usr/bin/bash' -c '"/usr/bin/mv" "/var/lib/mysql/tmp/joomla.sql.gz" "/home/CHANGEME/backups/joomla-database-auto-"$$(date +%%Y-%%m-%%d)".sql.gz"'
 +ExecStartPost='/usr/bin/sync'</code>
 +
 +=== Timer ===
 +
 +  * Every day at ''02:45:00''
 +
 +  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
 +
 +<code>
 +[Unit]
 +Description=Joomla Database Backup
 +After=mariadb.service
 +
 +[Timer]
 +OnCalendar=*-*-* 02:45:00
 +Persistent=true
 +
 +[Install]
 +WantedBy=timers.target</code>
 +
 +====== Backup ======
 +
 +  * Create backup archive on server and transfer to client computer
 +
 +===== Server =====
 +
 +==== Stop Services ====
 +
 +****
 +
 +  sudo systemctl stop nginx php-fpm
 +
 +==== Backup Folder ====
 +
 +****
 +
 +  cd '/var/www' && sudo tar -cvzf ~/'joomla-files-manual-'$(date +%Y-%m-%d)'.tar.gz' 'main' && cd ~ && sync
 +
 +==== Backup Database ====
 +
 +  * TODO: Looks redundant to use the ''auth'' file //and// ''sudo''
 +
 +  sudo mariadb-dump --defaults-extra-file='/var/lib/mysql/auth/joomla' --single-transaction 'joomla_db' -r ~/'joomla-database-manual-'$(date +%Y-%m-%d)'.sql' && sync
 +
 +==== Start Services ====
 +
 +****
 +
 +  sudo systemctl start nginx php-fpm
 +
 +===== Client =====
 +
 +==== Transfer Files To Client ====
 +
 +****
 +
 +  scp espionage724@192.168.1.152:~/'joomla-files-'*'.tar.gz' espionage724@192.168.1.152:~/'joomla-database-'*'.sql' ~/'Downloads' && sync
 +
 +====== Restore ======
 +
 +===== Client =====
 +
 +==== Uncompress Database ====
 +
 +  * This is only needed if restoring an **automated** database backup ((manual doesn't gzip))
 +
 +  gunzip ~/'Downloads/joomla-database-'*'.sql.gz'
 +
 +==== Transfer Files To Server ====
 +
 +****
 +
 +  scp ~/'Downloads/joomla-files-'*'.tar.gz' ~/'Downloads/joomla-database-'*'.sql' espionage724@192.168.1.152:~
 +
 +==== Remove Files ====
 +
 +****
 +
 +  rm -f ~/'Downloads/joomla-files-'*'.tar.gz' ~/'Downloads/joomla-database-'*'.sql' && sync
 +
 +===== Server =====
 +
 +==== Stop Services ====
 +
 +****
 +
 +  sudo systemctl stop nginx php-fpm
 +
 +==== Restore Joomla Folder ====
 +
 +****
 +
 +  cd '/var/www' && sudo tar -xvzf ~/'joomla-files-'*'.tar.gz' 'main' && sudo semanage fcontext --add --type 'httpd_sys_rw_content_t' '/var/www/main(/.*)?' && sudo restorecon -F -I -R '/var/www/main' && sudo chown -R 'nginx':'nginx' '/var/www/main' && cd ~ && sync
 +
 +==== Database ====
 +
 +  * ''x'' is path to a ''joomla_db'' ''.sql'' database dump
 +
 +  mariadb --user='root' --password --execute='DROP DATABASE joomla_db'
 +
 +  mariadb --user='root' --password --execute='CREATE DATABASE joomla_db'
 +
 +  mariadb --user='root' --password 'joomla_db' < x
 +  
 +==== Reapply Permissions ====
 +
 +  mariadb -u 'root' -p
 +
 +  GRANT ALL PRIVILEGES ON joomla_db.* to 'joomla'@'localhost';
 +
 +  FLUSH PRIVILEGES;
 +
 +  EXIT
 +
 +==== Start Services ====
 +
 +****
 +
 +  sudo systemctl start nginx php-fpm
 +
 +==== Remove Backups ====
 +
 +  * Verify that Joomla works before running
 +
 +  rm ~/'joomla-files-'*'.tar.gz' ~/'joomla-database-'*'.sql' && sync
  
/usr/local/www/wiki/data/attic/servers/bsd/nginx/joomla.1747450828.txt.gz · Last modified: by Sean Rhone