User Tools

Site Tools


servers:nginx:joomla

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
servers:nginx:joomla [2019/06/28 21:46]
Sean Rhone [Database]
servers:nginx:joomla [2020/04/24 12:28] (current)
Sean Rhone Ubuntu 20.04
Line 9: Line 9:
 ===== Prerequisites ===== ===== Prerequisites =====
  
-  * [[distros:fedora_server|Fedora Server]] +  * [[distros:ubuntu_server|Ubuntu Server]] ((Last tested on 20.04)) 
-  * [[servers:mariadb | MariaDB]] +  * [[servers:mariadb|MariaDB]] 
-  * [[servers:nginx_php_php-fpm | nginx + PHP + PHP-FPM]] +  * [[servers:nginx_php_php-fpm|nginx + PHP + PHP-FPM]] 
-  * [[servers:nginx:lets_encrypt | Let's Encrypt]]+  * [[servers:nginx:lets_encrypt|Let's Encrypt]]
  
 ===== Notes ===== ===== Notes =====
Line 26: Line 26:
 **** ****
  
-  sudo git clone --branch 'staging' --depth '1' --recurse-submodules 'https://github.com/joomla/joomla-cms.git' '/var/www/main' && sudo chown -R 'nginx':'nginx' '/var/www/main' && sync +  sudo git clone --branch 'staging' --depth '1' --recurse-submodules 'https://github.com/joomla/joomla-cms.git' '/var/www/main' && sudo chown -R 'www-data':'www-data' '/var/www/main' && sync
- +
-===== SELinux ===== +
- +
-  sudo semanage fcontext --deleteall "/var/www/main(/.*)?" +
- +
-  sudo semanage fcontext --add --type 'httpd_sys_rw_content_t' "/var/www/main(/.*)?" +
- +
-  sudo restorecon -R -v '/var/www/main' && sync+
  
 ====== Database ====== ====== Database ======
  
-  mysql --user='root' --password+  sudo mysql
  
   CREATE DATABASE joomla;   CREATE DATABASE joomla;
Line 45: Line 37:
  
   FLUSH PRIVILEGES;   FLUSH PRIVILEGES;
 +
 +  EXIT
  
 ====== nginx + PHP-FPM Configuration ====== ====== nginx + PHP-FPM Configuration ======
Line 50: Line 44:
 ===== PHP-FPM Socket ===== ===== PHP-FPM Socket =====
  
-  sudo -e '/etc/php-fpm.d/main.conf' && sudo systemctl restart 'php-fpm'+  sudo -e '/etc/php/7.4/fpm/pool.d/main.conf' && sudo systemctl restart 'php7.4-fpm'
  
 <code> <code>
 [main] [main]
-user = nginx +user = www-data 
-group = nginx+group = www-data
  
-listen = /run/php-fpm/main.sock +listen = /run/php/main.sock 
-listen.owner = nginx +listen.owner = www-data 
-listen.group = nginx+listen.group = www-data
 listen.allowed_clients = 127.0.0.1 listen.allowed_clients = 127.0.0.1
  
Line 77: Line 71:
 php_value[max_file_uploads] = "100" php_value[max_file_uploads] = "100"
  
-php_value[session.save_handler] = files +php_value[session.save_handler] = "files" 
-php_value[session.save_path] = /var/lib/php/session +php_value[session.save_path] = "/var/lib/php/sessions" 
-php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache +php_value[soap.wsdl_cache_dir] = "/var/lib/php/wsdlcache" 
-php_value[opcache.file_cache] = /var/lib/php/opcache</code>+php_value[opcache.file_cache] = "/var/lib/php/opcache"</code>
  
 ===== FastCGI ===== ===== FastCGI =====
  
-  sudo -e '/etc/nginx/default.d/main.conf'+  sudo -e '/etc/nginx/snippets/main.conf'
  
 <code> <code>
Line 96: Line 90:
     fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;     fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
     fastcgi_param PATH_INFO $fastcgi_path_info;     fastcgi_param PATH_INFO $fastcgi_path_info;
-    fastcgi_pass unix:/run/php-fpm/main.sock;+    fastcgi_pass unix:/run/php/main.sock;
 }</code> }</code>
  
 ===== Server Block ===== ===== Server Block =====
  
-  sudo -e '/etc/nginx/conf.d/main.conf' && sudo systemctl reload 'nginx'+  sudo -e '/etc/nginx/sites-available/main.conf'
  
 <code> <code>
Line 110: Line 104:
     index 'index.php';     index 'index.php';
  
-    include '/etc/nginx/default.d/main.conf'; +    include '/etc/nginx/snippets/main.conf'; 
-    include '/etc/nginx/default.d/headers.conf';+    include '/etc/nginx/snippets/headers.conf';
  
     client_max_body_size '10M';     client_max_body_size '10M';
Line 129: Line 123:
     }     }
 }</code> }</code>
 +
 +==== Enable ====
 +
 +****
 +
 +  sudo rm -f '/etc/nginx/sites-enabled/main.conf' && sudo ln -s '/etc/nginx/sites-available/main.conf' '/etc/nginx/sites-enabled/main.conf' && sudo systemctl reload 'nginx' && sync
  
 ====== Initial Setup ====== ====== Initial Setup ======
Line 227: Line 227:
 **** ****
  
-  sudo -H -u 'nginx' wget 'https://licensebuttons.net/l/by-sa/4.0/80x15.png' -O '/var/www/main/images/cc-by-sa-40.png'+  sudo -H -u 'www-data' wget 'https://licensebuttons.net/l/by-sa/4.0/80x15.png' -O '/var/www/main/images/cc-by-sa-40.png'
  
 === Text === === Text ===
Line 234: Line 234:
   * Remove ''Bootstrap by Twitter'' and ''Font Awesome'' mentions   * Remove ''Bootstrap by Twitter'' and ''Font Awesome'' mentions
  
-  sudo -H -u 'nginx' -e '/var/www/main/templates/purity_iii/tpls/blocks/footer.php'+  sudo -H -u 'www-data' -e '/var/www/main/templates/purity_iii/tpls/blocks/footer.php'
  
 <code> <code>
Line 248: Line 248:
   * Requires [[servers:nginx:joomla#purity_iii | Purity III Template]]   * Requires [[servers:nginx:joomla#purity_iii | Purity III Template]]
  
-  sudo -H -u 'nginx' -e '/var/www/main/templates/purity_iii/css/custom.css'+  sudo -H -u 'www-data' -e '/var/www/main/templates/purity_iii/css/custom.css'
  
   html,   html,
Line 309: Line 309:
 <code> <code>
 [Service] [Service]
-User=nginx +User=www-data 
-Group=nginx+Group=www-data
 Type=oneshot Type=oneshot
 ExecStart='/usr/bin/git' -C '/var/www/main' pull origin 'staging' ExecStart='/usr/bin/git' -C '/var/www/main' pull origin 'staging'
-ExecStartPost='/usr/bin/sync'</code>+ExecStartPost='/bin/sync'</code>
  
 ==== Timer ==== ==== Timer ====
Line 342: Line 342:
 <code> <code>
 [Service] [Service]
-User=nginx +User=www-data 
-Group=nginx+Group=www-data
 Type=oneshot Type=oneshot
 ExecStart='/usr/bin/git' -C '/var/www/main' gc --aggressive --prune='all' ExecStart='/usr/bin/git' -C '/var/www/main' gc --aggressive --prune='all'
 ExecStart='/usr/bin/git' -C '/var/www/main' fsck --full --strict ExecStart='/usr/bin/git' -C '/var/www/main' fsck --full --strict
-ExecStartPost='/usr/bin/sync'</code>+ExecStartPost='/bin/sync'</code>
  
 ==== Timer ==== ==== Timer ====
Line 380: Line 380:
 Type=oneshot Type=oneshot
 WorkingDirectory=/var/www WorkingDirectory=/var/www
-ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -cvzf "/home/CHANGEME/backups/joomla-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "main"' +ExecStart='/bin/bash' -c '"/bin/tar" -cvzf "/home/CHANGEME/backups/joomla-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "main"' 
-ExecStartPost='/usr/bin/sync'</code>+ExecStartPost='/bin/sync'</code>
  
 === Timer === === Timer ===
Line 420: Line 420:
 WorkingDirectory=/var/lib/mysql/tmp WorkingDirectory=/var/lib/mysql/tmp
 ExecStartPre='/usr/bin/mysqldump' --defaults-extra-file='/var/lib/mysql/auth/joomla' --single-transaction 'joomla' -r '/var/lib/mysql/tmp/joomla.sql' ExecStartPre='/usr/bin/mysqldump' --defaults-extra-file='/var/lib/mysql/auth/joomla' --single-transaction 'joomla' -r '/var/lib/mysql/tmp/joomla.sql'
-ExecStart='/usr/bin/gzip' -f '/var/lib/mysql/tmp/joomla.sql' +ExecStart='/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"' +ExecStart='/bin/bash' -c '"/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>+ExecStartPost='/bin/sync'</code>
  
 === Timer === === Timer ===
Line 452: Line 452:
 **** ****
  
-  sudo systemctl stop nginx php-fpm+  sudo systemctl stop nginx php7.4-fpm
  
 ==== Backup Folder ==== ==== Backup Folder ====
Line 464: Line 464:
 **** ****
  
-  sudo -u 'mysql' mysqldump --defaults-extra-file='/var/lib/mysql/auth/joomla' --single-transaction 'joomla' -r ~/'joomla-database-manual-'$(date +%Y-%m-%d)'.sql' && sync+  sudo mysqldump --defaults-extra-file='/var/lib/mysql/auth/joomla' --single-transaction 'joomla' -r ~/'joomla-database-manual-'$(date +%Y-%m-%d)'.sql' && sync
  
 ==== Start Services ==== ==== Start Services ====
Line 470: Line 470:
 **** ****
  
-  sudo systemctl start nginx php-fpm+  sudo systemctl start nginx php7.4-fpm
  
 ===== Client ===== ===== Client =====
Line 508: Line 508:
 **** ****
  
-  sudo systemctl stop nginx php-fpm+  sudo systemctl stop nginx php7.4-fpm
  
 ==== Restore Joomla! Folder ==== ==== Restore Joomla! Folder ====
Line 514: Line 514:
 **** ****
  
-  cd '/var/www' && sudo tar -xvzf ~/'joomla-files-'*'.tar.gz' 'main' && sudo chown -R 'nginx':'nginx' '/var/www/main' && cd ~ && sync +  cd '/var/www' && sudo tar -xvzf ~/'joomla-files-'*'.tar.gz' 'main' && sudo chown -R 'www-data':'www-data' '/var/www/main' && cd ~ && sync
- +
-==== SELinux ==== +
- +
-  sudo semanage fcontext --deleteall "/var/www/main(/.*)?" +
- +
-  sudo semanage fcontext --add --type 'httpd_sys_rw_content_t' "/var/www/main(/.*)?" +
- +
-  sudo restorecon -R -v '/var/www/main' && sync+
  
 ==== Drop Previous Database ==== ==== Drop Previous Database ====
  
-  mysql --user='root' --password+  sudo mysql
  
   DROP DATABASE joomla;   DROP DATABASE joomla;
  
   FLUSH TABLES;   FLUSH TABLES;
 +
 +  EXIT
  
 ==== Re-create Databases ==== ==== Re-create Databases ====
  
-  mysql --user='root' --password+  sudo mysql
  
   CREATE DATABASE joomla;   CREATE DATABASE joomla;
 +
 +  EXIT
  
 ==== Restore Database ==== ==== Restore Database ====
Line 542: Line 538:
 **** ****
  
-  mysql --user='root' --password 'joomla' < ~/'joomla-database-'*'.sql' && sync+  sudo mysql 'joomla' < ~/'joomla-database-'*'.sql' && sync
  
 ==== Reapply Permissions ==== ==== Reapply Permissions ====
  
-  mysql --user='root' --password+  sudo mysql
  
   GRANT ALL PRIVILEGES ON joomla.* to 'joomla'@'localhost' IDENTIFIED BY 'x';   GRANT ALL PRIVILEGES ON joomla.* to 'joomla'@'localhost' IDENTIFIED BY 'x';
  
   FLUSH PRIVILEGES;   FLUSH PRIVILEGES;
 +
 +  EXIT
  
 ==== Start Services ==== ==== Start Services ====
Line 556: Line 554:
 **** ****
  
-  sudo systemctl start nginx php-fpm+  sudo systemctl start nginx php7.4-fpm
  
 ==== Remove Backups ==== ==== Remove Backups ====
servers/nginx/joomla.1561772764.txt.gz · Last modified: 2019/06/28 21:46 by Sean Rhone