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 19:42] Sean Rhoneservers:bsd:nginx:wordpress [2025/05/16 21:51] (current) – [Download Source] Sean Rhone
Line 4: Line 4:
   * [[Information:Realm of Espionage]]   * [[Information:Realm of Espionage]]
   * https://blog.realmofespionage.xyz   * https://blog.realmofespionage.xyz
- 
-  * 2025/05/16: WIP 
  
 ===== Prerequisites ===== ===== Prerequisites =====
Line 24: Line 22:
  
 ====== Download Source ====== ====== Download Source ======
 +
 +  * https://github.com/WordPress/WordPress/commits/master/
  
   su -   su -
Line 31: Line 31:
 ====== Database ====== ====== Database ======
  
-  sudo mariadb+  mariadb -u 'root' -p
  
   CREATE DATABASE wordpress;   CREATE DATABASE wordpress;
  
-  GRANT ALL PRIVILEGES ON wordpress.* to 'wordpress'@'localhost' IDENTIFIED BY 'x';+  CREATE USER wordpress@localhost IDENTIFIED BY 'x'; 
 + 
 +  GRANT ALL PRIVILEGES ON wordpress.* to wordpress@localhost;
  
   FLUSH PRIVILEGES;   FLUSH PRIVILEGES;
Line 93: Line 95:
 ===== Server Block ===== ===== Server Block =====
  
-  * 2023/09/12: CSPs disabled; TODO: Re-figure out CSPs+  su -
  
-  sudo -e '/etc/nginx/vhosts.d/blog.conf' && sudo systemctl reload 'nginx' && sync+  ee '/usr/local/etc/nginx/vhosts.d/blog.conf' && service 'nginx' reload && sync
  
 <code> <code>
 server { server {
-    listen '443' 'ssl' 'http2';+    listen 443 ssl
 +#    http2 on;
     server_name 'blog.realmofespionage.xyz';     server_name 'blog.realmofespionage.xyz';
-    root '/var/www/blog';+    root '/usr/local/www/blog';
     index 'index.php';     index 'index.php';
  
-    include '/etc/nginx/default.d/blog.conf'; +    include '/usr/local/etc/nginx/default.d/blog.conf'; 
-    include '/etc/nginx/default.d/headers.conf';+    include '/usr/local/etc/nginx/default.d/headers.conf';
  
     client_max_body_size '10M';     client_max_body_size '10M';
Line 111: Line 114:
 #    add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; font-src 'self' data:; img-src 'self' data: s.w.org" always; #    add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; font-src 'self' data:; img-src 'self' data: s.w.org" always;
  
-#    access_log  /var/log/nginx/media-access.log; +#    access_log  /var/log/nginx/blog-access.log; 
-#    error_log  /var/log/nginx/media-error.log;+#    error_log  /var/log/nginx/blog-error.log;
  
     location / {     location / {
Line 123: Line 126:
           access_log off; log_not_found off; expires max;           access_log off; log_not_found off; expires max;
     }     }
-}</code>+} 
 + 
 +# End</code>
  
 ====== Initial Setup ====== ====== Initial Setup ======
Line 132: Line 137:
  
   * Date Format: Y/m/d   * Date Format: Y/m/d
 +
 +===== DB Connection Fix =====
 +
 +  * https://forums.freebsd.org/threads/wordpress-cant-connect-to-mysql-database.71914/#post-436461
 +  * ''DB_HOST'' to ''127.0.0.1''
 +
 +  su -
 +
 +  ee '/usr/local/www/blog/wp-config.php'
 +
 +<code>define( 'DB_HOST', 'localhost' );^M</code>
 +
 +<code>define( 'DB_HOST', '127.0.0.1' );^M</code>
 +
 +====== Temp Commands ======
 +
 +===== Update =====
 +
 +  * https://github.com/WordPress/WordPress/commits/master/
 +
 +  su -
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/blog' pull origin 'master'"
 +
 +===== Etc =====
 +
 +  su -
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/blog' reset --hard"
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/blog' pull origin 'master' --rebase"
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/blog' gc --aggressive --prune='all'"
 +
 +  su -m 'www' -c "'/usr/local/bin/git' -C '/usr/local/www/blog' fsck --full --strict"
  
 ====== Services ====== ====== Services ======
Line 344: Line 384:
   sudo systemctl stop nginx php-fpm   sudo systemctl stop nginx php-fpm
  
-==== Remove Previous Folder ====+====== Restore ======
  
-****+===== Files =====
  
-  sudo rm -Rf '/var/www/blog'+  su -
  
-==== Restore WordPress Folder ====+  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
  
-  cd '/var/www' && sudo tar -xvzf ~/'wordpress-files-'*'.tar.gz' 'blog' && sudo chown -R 'nginx':'nginx' '/var/www/blog' && sudo semanage fcontext --add --type 'httpd_sys_rw_content_t' '/var/www/blog(/.*)?' && sudo restorecon -F -I -R '/var/www/blog' && cd ~ && sync +===== Database =====
- +
-==== Drop Previous Database ==== +
- +
-  sudo mariadb +
- +
-  DROP DATABASE wordpress; +
- +
-  FLUSH TABLES; +
- +
-  EXIT +
- +
-==== Re-create Databases ==== +
- +
-  sudo mariadb +
- +
-  CREATE DATABASE wordpress; +
- +
-  EXIT +
- +
-==== Restore Database ==== +
- +
-**** +
- +
-  sudo mariadb 'wordpress' < ~/'wordpress-database-'*'.sql' && sync +
- +
-==== Reapply Permissions ==== +
- +
-  sudo mariadb +
- +
-  GRANT ALL PRIVILEGES ON wordpress.* to 'wordpress'@'localhost' IDENTIFIED BY 'x'; +
- +
-  FLUSH PRIVILEGES; +
- +
-  EXIT +
- +
-==== Start Services ==== +
- +
-**** +
- +
-  sudo systemctl start nginx php-fpm+
  
-==== Remove Backups ====+  * [[#database|Initial set-up]]
  
-  * Verify that WordPress works before running+  mariadb -u 'root' -p --execute='CREATE DATABASE wordpress;'
  
-  rm ~/'wordpress-files-'*'.tar.gz' ~/'wordpress-database-'*'.sql' && sync+  mariadb -u 'root' -'wordpress~/'wordpress.sql'
  
/usr/local/www/wiki/data/attic/servers/bsd/nginx/wordpress.1747438936.txt.gz · Last modified: by Sean Rhone