User Tools

Site Tools


servers:nginx:wordpress

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
servers:nginx:wordpress [2020/04/24 12:19] – Ubuntu 20.04 Sean Rhoneservers:nginx:wordpress [2021/06/14 11:42] – Fedora Sean Rhone
Line 7: Line 7:
 ===== Prerequisites ===== ===== Prerequisites =====
  
-  * [[distros:ubuntu_server|Ubuntu Server]] ((Last tested on 20.04))+  * [[distros:fedora_workstation_gnome#server|Fedora]]
   * [[servers:mariadb|MariaDB]]   * [[servers:mariadb|MariaDB]]
   * [[servers:nginx_php_php-fpm|nginx + PHP + PHP-FPM]]   * [[servers:nginx_php_php-fpm|nginx + PHP + PHP-FPM]]
Line 20: Line 20:
 **** ****
  
-  sudo git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/WordPress/WordPress.git' '/var/www/blog' && sudo chown -R 'www-data':'www-data' '/var/www/blog' && sync+  sudo git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/WordPress/WordPress.git' '/var/www/blog' && sudo chown -R 'nginx':'nginx' '/var/www/blog' && sync 
 + 
 +===== SELinux ===== 
 + 
 +**** 
 + 
 +  sudo semanage fcontext --add --type 'httpd_sys_content_t' "/var/www/blog(/.*)?" && sudo restorecon -I -R '/var/www/blog' && sync
  
 ====== Database ====== ====== Database ======
Line 38: Line 44:
 ===== PHP-FPM Socket ===== ===== PHP-FPM Socket =====
  
-  sudo -e '/etc/php/7.4/fpm/pool.d/blog.conf' && sudo systemctl restart 'php7.4-fpm'+  sudo -e '/etc/php-fpm.d/blog.conf' && sudo systemctl restart 'php-fpm'
  
 <code> <code>
 [blog] [blog]
-user = www-data +user = nginx 
-group = www-data+group = nginx
  
-listen = /run/php/blog.sock +listen = /run/php-fpm/blog.sock 
-listen.owner = www-data +listen.owner = nginx 
-listen.group = www-data+listen.group = nginx
 listen.allowed_clients = 127.0.0.1 listen.allowed_clients = 127.0.0.1
  
-pm = dynamic +pm = ondemand 
-pm.max_children = 8 +pm.max_children = 4 
-pm.start_servers +pm.process_idle_timeout 30
-pm.min_spare_servers = 2 +
-pm.max_spare_servers = 4+
  
 php_value[date.timezone] = "America/New_York" php_value[date.timezone] = "America/New_York"
Line 72: Line 76:
 ===== FastCGI ===== ===== FastCGI =====
  
-  sudo -e '/etc/nginx/snippets/blog.conf'+  sudo -e '/etc/nginx/default.d/blog.conf'
  
 <code> <code>
Line 84: Line 88:
     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/blog.sock;+    fastcgi_pass unix:/run/php-fpm/blog.sock;
 }</code> }</code>
  
Line 91: Line 95:
   * :!: ''style-src'' in the CSP blocks a Google font URL from being loaded ((at least with the Twenty Seventeen theme; nothing appears broken, so looks good to me)) ((add ''fonts.googleapis.com'' after ''unsafe-inline'' in ''style-src'' to fix this))   * :!: ''style-src'' in the CSP blocks a Google font URL from being loaded ((at least with the Twenty Seventeen theme; nothing appears broken, so looks good to me)) ((add ''fonts.googleapis.com'' after ''unsafe-inline'' in ''style-src'' to fix this))
  
-  sudo -e '/etc/nginx/sites-available/blog.conf'+  sudo -e '/etc/nginx/vhosts.d/blog.conf' && sudo systemctl reload 'nginx' && sync
  
 <code> <code>
Line 100: Line 104:
     index 'index.php';     index 'index.php';
  
-    include '/etc/nginx/snippets/blog.conf'; +    include '/etc/nginx/default.d/blog.conf'; 
-    include '/etc/nginx/snippets/headers.conf';+    include '/etc/nginx/default.d/headers.conf';
  
     client_max_body_size '10M';     client_max_body_size '10M';
Line 120: Line 124:
     }     }
 }</code> }</code>
- 
-==== Enable ==== 
- 
-**** 
- 
-  sudo rm -f '/etc/nginx/sites-enabled/blog.conf' && sudo ln -s '/etc/nginx/sites-available/blog.conf' '/etc/nginx/sites-enabled/blog.conf' && sudo systemctl reload 'nginx' && sync 
  
 ====== Initial Setup ====== ====== Initial Setup ======
Line 145: Line 143:
 <code> <code>
 [Service] [Service]
-User=www-data +User=nginx 
-Group=www-data+Group=nginx
 Type=oneshot Type=oneshot
 ExecStart='/usr/bin/git' -C '/var/www/blog' pull origin 'master' ExecStart='/usr/bin/git' -C '/var/www/blog' pull origin 'master'
-ExecStartPost='/bin/sync'</code>+ExecStartPost='/usr/bin/sync'</code>
  
 ==== Timer ==== ==== Timer ====
Line 178: Line 176:
 <code> <code>
 [Service] [Service]
-User=www-data +User=nginx 
-Group=www-data+Group=nginx
 Type=oneshot Type=oneshot
 ExecStart='/usr/bin/git' -C '/var/www/blog' gc --aggressive --prune='all' ExecStart='/usr/bin/git' -C '/var/www/blog' gc --aggressive --prune='all'
 ExecStart='/usr/bin/git' -C '/var/www/blog' fsck --full --strict ExecStart='/usr/bin/git' -C '/var/www/blog' fsck --full --strict
-ExecStartPost='/bin/sync'</code>+ExecStartPost='/usr/bin/sync'</code>
  
 ==== Timer ==== ==== Timer ====
Line 216: Line 214:
 Type=oneshot Type=oneshot
 WorkingDirectory=/var/www WorkingDirectory=/var/www
-ExecStart='/bin/bash' -c '"/bin/tar" -cvzf "/home/CHANGEME/backups/wordpress-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "blog"' +ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -cvzf "/home/CHANGEME/backups/wordpress-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "blog"' 
-ExecStartPost='/bin/sync'</code>+ExecStartPost='/usr/bin/sync'</code>
  
 === Timer === === Timer ===
Line 256: Line 254:
 WorkingDirectory=/var/lib/mysql/tmp WorkingDirectory=/var/lib/mysql/tmp
 ExecStartPre='/usr/bin/mysqldump' --defaults-extra-file='/var/lib/mysql/auth/wordpress' --single-transaction 'wordpress' -r '/var/lib/mysql/tmp/wordpress.sql' ExecStartPre='/usr/bin/mysqldump' --defaults-extra-file='/var/lib/mysql/auth/wordpress' --single-transaction 'wordpress' -r '/var/lib/mysql/tmp/wordpress.sql'
-ExecStart='/bin/gzip' -f '/var/lib/mysql/tmp/wordpress.sql' +ExecStart='/usr/bin/gzip' -f '/var/lib/mysql/tmp/wordpress.sql' 
-ExecStart='/bin/bash' -c '"/bin/mv" "/var/lib/mysql/tmp/wordpress.sql.gz" "/home/CHANGEME/backups/wordpress-database-auto-"$$(date +%%Y-%%m-%%d)".sql.gz"' +ExecStart='/usr/bin/bash' -c '"/usr/bin/mv" "/var/lib/mysql/tmp/wordpress.sql.gz" "/home/CHANGEME/backups/wordpress-database-auto-"$$(date +%%Y-%%m-%%d)".sql.gz"' 
-ExecStartPost='/bin/sync'</code>+ExecStartPost='/usr/bin/sync'</code>
  
 === Timer === === Timer ===
Line 288: Line 286:
 **** ****
  
-  sudo systemctl stop nginx php7.4-fpm+  sudo systemctl stop nginx php-fpm
  
 ==== Backup Folder ==== ==== Backup Folder ====
Line 306: Line 304:
 **** ****
  
-  sudo systemctl start nginx php7.4-fpm+  sudo systemctl start nginx php-fpm
  
 ===== Client ===== ===== Client =====
Line 314: Line 312:
 **** ****
  
-  scp espionage724@192.168.1.153:~/'wordpress-files-'*'.tar.gz' espionage724@192.168.1.153:~/'wordpress-database-'*'.sql' ~/'Downloads' && sync+  scp espionage724@192.168.1.152:~/'wordpress-files-'*'.tar.gz' espionage724@192.168.1.152:~/'wordpress-database-'*'.sql' ~/'Downloads' && sync
  
 ====== Restore ====== ====== Restore ======
Line 330: Line 328:
 **** ****
  
-  scp ~/'Downloads/wordpress-files-'*'.tar.gz' ~/'Downloads/wordpress-database-'*'.sql' espionage724@192.168.1.153:~+  scp ~/'Downloads/wordpress-files-'*'.tar.gz' ~/'Downloads/wordpress-database-'*'.sql' espionage724@192.168.1.152:~
  
 ==== Remove Files ==== ==== Remove Files ====
Line 344: Line 342:
 **** ****
  
-  sudo systemctl stop nginx php7.4-fpm+  sudo systemctl stop nginx php-fpm
  
 ==== Remove Previous Folder ==== ==== Remove Previous Folder ====
Line 356: Line 354:
 **** ****
  
-  cd '/var/www' && sudo tar -xvzf ~/'wordpress-files-'*'.tar.gz' 'blog' && sudo chown -R 'www-data':'www-data' '/var/www/blog' && cd ~ && sync+  cd '/var/www' && sudo tar -xvzf ~/'wordpress-files-'*'.tar.gz' 'blog' && sudo chown -R 'nginx':'nginx' '/var/www/blog' && sudo chown -R 'nginx':'nginx' '/var/www/blog&& sudo restorecon -I -R -v '/var/www/blog' && cd ~ && sync
  
 ==== Drop Previous Database ==== ==== Drop Previous Database ====
Line 396: Line 394:
 **** ****
  
-  sudo systemctl start nginx php7.4-fpm+  sudo systemctl start nginx php-fpm
  
 ==== Remove Backups ==== ==== Remove Backups ====
/var/www/wiki/data/pages/servers/nginx/wordpress.txt · Last modified: 2024/02/01 10:03 by Sean Rhone