User Tools

Site Tools


servers:bsd: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 revision
Previous revision
servers:bsd:nginx:wordpress [2025/05/16 20:41] Sean Rhoneservers:bsd:nginx:wordpress [2025/08/28 00:46] (current) – [Server Block] Sean Rhone
Line 7: Line 7:
 ===== Prerequisites ===== ===== Prerequisites =====
  
-  * [[bsd:server:freebsd_14.2|FreeBSD 14.2]] +  * [[bsd:server:freebsd_14.3|FreeBSD 14.3]]
-  * [[servers:bsd:mariadb|MariaDB]]+
   * [[servers:bsd:nginx_php_php-fpm|nginx + PHP + PHP-FPM]]   * [[servers:bsd:nginx_php_php-fpm|nginx + PHP + PHP-FPM]]
   * [[servers:bsd:nginx:lets_encrypt|Let's Encrypt]]   * [[servers:bsd:nginx:lets_encrypt|Let's Encrypt]]
 +  * [[servers:bsd:mariadb|MariaDB]]
  
 ====== Dependencies ====== ====== Dependencies ======
Line 22: Line 22:
  
 ====== Download Source ====== ====== Download Source ======
 +
 +  * https://github.com/WordPress/WordPress/commits/master/
  
   su -   su -
  
-  git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/WordPress/WordPress.git' '/usr/local/www/blog' && chown -R 'www':'www' '/usr/local/www/blog' && sync+  git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/WordPress/WordPress.git' '/usr/local/www/blog' && chown -R 'www':'www' '/usr/local/www/blog'
  
 ====== Database ====== ====== Database ======
Line 47: Line 49:
   su -   su -
  
-  ee '/usr/local/etc/php-fpm.d/blog.conf' && service 'php_fpm' restart+  ee '/usr/local/etc/php-fpm.d/blog.conf' && service 'php_fpm' reload
  
 <code> <code>
Line 77: Line 79:
  
 <code> <code>
-# PHP-FPM 
 location ~ \.(php|phar)(/.*)?$ { location ~ \.(php|phar)(/.*)?$ {
     fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;     fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;
Line 95: Line 96:
   su -   su -
  
-  ee '/usr/local/etc/nginx/vhosts.d/blog.conf' && service 'nginx' reload && sync+  ee '/usr/local/etc/nginx/vhosts.d/blog.conf' && service 'nginx' reload
  
 <code> <code>
 server { server {
     listen 443 ssl;     listen 443 ssl;
-#    http2 on;+    http2 on;
     server_name 'blog.realmofespionage.xyz';     server_name 'blog.realmofespionage.xyz';
     root '/usr/local/www/blog';     root '/usr/local/www/blog';
Line 140: Line 141:
   * https://forums.freebsd.org/threads/wordpress-cant-connect-to-mysql-database.71914/#post-436461   * https://forums.freebsd.org/threads/wordpress-cant-connect-to-mysql-database.71914/#post-436461
   * ''DB_HOST'' to ''127.0.0.1''   * ''DB_HOST'' to ''127.0.0.1''
 +  * :?: May need or be fixed with ''dos2unix''
  
   su -   su -
Line 159: Line 161:
   su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/blog' pull origin 'master'"   su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/blog' pull origin 'master'"
  
-===== Etc =====+===== Maintenance =====
  
   su -   su -
Line 171: Line 173:
   su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/blog' fsck --full --strict"   su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/blog' fsck --full --strict"
  
-====== Services ====== +  mariadb-check -'root' -p --f ---auto-repair 'wordpress'
- +
-===== Updater ===== +
- +
-==== Service ==== +
- +
-  sudo -e '/etc/systemd/system/blog-up.service' +
- +
-<code> +
-[Service] +
-User=nginx +
-Group=nginx +
-Type=oneshot +
-ExecStart='/usr/bin/git' -C '/var/www/blog' pull origin 'master' +
-ExecStartPost='/usr/bin/sync'</code> +
- +
-==== Timer ==== +
- +
-  * Every day at ''04:00:00'' +
- +
-  sudo -e '/etc/systemd/system/blog-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'blog-up.timer' --now && sudo systemctl start 'blog-up' && sudo systemctl status 'blog-up' -l +
- +
-<code> +
-[Unit] +
-Description=WordPress Git Updater +
-After=network-online.target +
-Wants=network-online.target +
- +
-[Timer] +
-OnCalendar=*-*-* 04:00:00 +
-Persistent=true +
- +
-[Install] +
-WantedBy=timers.target</code> +
- +
-===== Maintenance ===== +
- +
-==== Service ==== +
- +
-  sudo -e '/etc/systemd/system/blog-m.service' +
- +
-<code> +
-[Service] +
-User=nginx +
-Group=nginx +
-Type=oneshot +
-ExecStart='/usr/bin/git' -C '/var/www/blog' gc --aggressive --prune='all' +
-ExecStart='/usr/bin/git' -C '/var/www/blog' fsck --full --strict +
-ExecStartPost='/usr/bin/sync'</code> +
- +
-==== Timer ==== +
- +
-  * ''01'' day of every month at ''04:20:00'' ((8-))) +
- +
-  sudo -e '/etc/systemd/system/blog-m.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'blog-m.timer' --now && sudo systemctl start 'blog-m' && sudo systemctl status 'blog-m' -l +
- +
-<code> +
-[Unit] +
-Description=WordPress Maintenance +
-After=network-online.target +
-Wants=network-online.target +
- +
-[Timer] +
-OnCalendar=*-*-01 04:20:00 +
-Persistent=true +
- +
-[Install] +
-WantedBy=timers.target</code> +
- +
-===== Backup ===== +
- +
-==== Files ==== +
- +
-=== Service === +
- +
-  mkdir -p ~/'backups' && sudo -e '/etc/systemd/system/blog-fb.service' && sudo sed -i 's/CHANGEME/'$USER'/g' '/etc/systemd/system/blog-fb.service' +
- +
-<code> +
-[Service] +
-Type=oneshot +
-WorkingDirectory=/var/www +
-ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -czf "/home/CHANGEME/backups/wordpress-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "blog"' +
-ExecStartPost='/usr/bin/sync'</code> +
- +
-=== Timer === +
- +
-  * ''01'' day of every month at ''04:35:00'' +
- +
-  sudo -e '/etc/systemd/system/blog-fb.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'blog-fb.timer' --now && sudo systemctl start 'blog-fb' && sudo systemctl status 'blog-fb' -l +
- +
-<code> +
-[Unit] +
-Description=WordPress Files Backup +
- +
-[Timer] +
-OnCalendar=*-*-01 04: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/wordpress' && sudo chown -R 'mysql':'mysql' '/var/lib/mysql/auth/wordpress' && sudo chmod '600' '/var/lib/mysql/auth/wordpress' && sync +
- +
-<code> +
-[mariadb-dump] +
-user=wordpress +
-password=x</code> +
- +
-=== Service === +
- +
-  mkdir -p ~/'backups&& sudo mkdir -p '/var/lib/mysql/tmp' && sudo -e '/etc/systemd/system/blog-db.service' && sudo sed -i 's/'CHANGEME'/'$USER'/g' '/etc/systemd/system/blog-db.service' +
- +
-<code> +
-[Service] +
-Type=oneshot +
-WorkingDirectory=/var/lib/mysql/tmp +
-ExecStartPre='/usr/bin/mariadb-dump' --defaults-extra-file='/var/lib/mysql/auth/wordpress' --single-transaction 'wordpress' -r '/var/lib/mysql/tmp/wordpress.sql' +
-ExecStart='/usr/bin/gzip' -f '/var/lib/mysql/tmp/wordpress.sql' +
-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='/usr/bin/sync'</code> +
- +
-=== Timer === +
- +
-  * Every day at ''04:45:00'' +
- +
-  sudo -e '/etc/systemd/system/blog-db.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'blog-db.timer' --now && sudo systemctl start 'blog-db' && sudo systemctl status 'blog-db' -l +
- +
-<code> +
-[Unit] +
-Description=WordPress Database Backup +
-After=mariadb.service +
- +
-[Timer] +
-OnCalendar=*-*-* 04:45:00 +
-Persistent=true +
- +
-[Install] +
-WantedBy=timers.target</code>+
  
 ====== Backup ====== ====== Backup ======
  
-  * Create backup archive on server and transfer to client computer+===== Folder =====
  
-===== Server =====+  su -
  
-==== Stop Services ====+  tar -czf '/home/espionage724/wordpress-files-manual-'$(date +%Y-%m-%d)'.tar.gz' -C '/usr/local/www' 'blog'
  
-**** +===== Database =====
- +
-  sudo systemctl stop nginx php-fpm +
- +
-==== Backup Folder ====+
  
 **** ****
  
-  cd '/var/www&& sudo tar -cvzf ~/'wordpress-files-manual-'$(date +%Y-%m-%d)'.tar.gz' 'blog&& cd ~ && sync+  mariadb-dump -u root -p --single-transaction --quick 'wordpress' -'/home/espionage724/wordpress-database-manual-'$(date +%Y-%m-%d)'.sql'
  
-==== Backup Database ====+===== scp =====
  
 **** ****
  
-  sudo mariadb-dump --defaults-extra-file='/var/lib/mysql/auth/wordpress' --single-transaction 'wordpress' -r ~/'wordpress-database-manual-'$(date +%Y-%m-%d)'.sql' && sync +  scp espionage724@192.168.1.152:~/'wordpress-files-'*'.tar.gz' espionage724@192.168.1.152:~/'wordpress-database-'*'.sql' ~/'Downloads'
- +
-==== Start Services ==== +
- +
-**** +
- +
-  sudo systemctl start nginx php-fpm +
- +
-===== Client ===== +
- +
-==== Transfer Files To Client ==== +
- +
-**** +
- +
-  scp espionage724@192.168.1.152:~/'wordpress-files-'*'.tar.gz' espionage724@192.168.1.152:~/'wordpress-database-'*'.sql' ~/'Downloads' && sync+
  
 ====== Restore ====== ====== Restore ======
  
-===== Client ===== +===== scp =====
- +
-==== Uncompress Database ==== +
- +
-  * This is only needed if restoring an **automated** database backup ((manual doesn't gzip)) +
- +
-  gunzip ~/'Downloads/wordpress-database-'*'.sql.gz' +
- +
-==== Transfer Files To Server ====+
  
 **** ****
  
-  scp ~/'Downloads/wordpress-files-'*'.tar.gz' ~/'Downloads/wordpress-database-'*'.sql' espionage724@192.168.1.152:~+  scp ~/'Downloads/wordpress-files-'*'.tar.gz' ~/'Downloads/wordpress'*'.sql' espionage724@192.168.1.152:~
  
-==== Remove Files ==== +===== Folder =====
- +
-**** +
- +
-  rm -f ~/'Downloads/wordpress-files-'*'.tar.gz' ~/'Downloads/wordpress-database-'*'.sql' && sync +
- +
-===== Server ===== +
- +
-==== Stop Services ==== +
- +
-**** +
- +
-  sudo systemctl stop nginx php-fpm +
- +
-====== Restore ====== +
- +
-===== Files =====+
  
   su -   su -
Line 390: Line 209:
   rm -Rf '/usr/local/www/blog'   rm -Rf '/usr/local/www/blog'
  
-  cd '/usr/local/www' && tar -xvzf '/home/'*'/wordpress-files-'*'.tar.gz' 'blog' && chown -R 'www':'www' '/usr/local/www/blog' && cd ~ && sync+  tar -xzf '/home/espionage724/wordpress-files-'*'.tar.gz' -C '/usr/local/www' 'blog' && chown -R 'www':'www' '/usr/local/www/blog' && sync
  
 ===== Database ===== ===== Database =====
Line 398: Line 217:
   mariadb -u 'root' -p --execute='CREATE DATABASE wordpress;'   mariadb -u 'root' -p --execute='CREATE DATABASE wordpress;'
  
-  mariadb -u 'root' -p 'wordpress'~/'wordpress.sql'+  mariadb -u 'root' -p 'wordpress''/home/espionage724/wordpress-database-manual-'*'.sql' 
 + 
 +  mariadb -u 'root' -p 'wordpress' < '/home/espionage724/wordpress.sql'
  
/usr/local/www/wiki/data/attic/servers/bsd/nginx/wordpress.1747442474.txt.gz · Last modified: by Sean Rhone