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

Next revision
Previous revision
servers:bsd:nginx:wordpress [2025/05/16 19:34] – created 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 19: Line 17:
   * https://make.wordpress.org/hosting/handbook/server-environment/#php-extensions   * https://make.wordpress.org/hosting/handbook/server-environment/#php-extensions
  
-  sudo dnf install php-mysqlnd php-xml php-pecl-igbinary php-imagick php-intl php-mbstring php-pecl-zip php-sodium php-bcmath php-gd php-process+  su - 
 + 
 +  pkg install git-lite php84-mysqli php84-intl php84-mbstring php84-xml
  
 ====== Download Source ====== ====== Download Source ======
 +
 +  * https://github.com/WordPress/WordPress/commits/master/
  
   su -   su -
Line 29: 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 43: Line 47:
 ===== PHP-FPM Socket ===== ===== PHP-FPM Socket =====
  
-  sudo -'/etc/php-fpm.d/blog.conf' && sudo systemctl restart 'php-fpm'+  su - 
 + 
 +  ee '/usr/local/etc/php-fpm.d/blog.conf' && service 'php_fpmrestart
  
 <code> <code>
Line 49: Line 55:
  
 ; User/Group ; User/Group
-user = nginx +user = www 
-group = nginx+group = www
  
 ; Socket ; Socket
-listen = /run/php-fpm/blog.sock +listen = 127.0.0.1:9004
-listen.acl_users = nginx+
 listen.allowed_clients = 127.0.0.1 listen.allowed_clients = 127.0.0.1
  
Line 61: Line 66:
 pm.max_children = 4 pm.max_children = 4
 pm.process_idle_timeout = 30 pm.process_idle_timeout = 30
- 
-; Fedora php.ini Defaults 
-php_value[session.save_handler] = "files" 
-php_value[session.save_path] = "/var/lib/php/session" 
  
 ; General ; General
 php_value[date.timezone] = "America/New_York" php_value[date.timezone] = "America/New_York"
-php_value[max_execution_time] = "200" 
-php_value[memory_limit] = "512M" 
-php_value[post_max_size] = "10M" 
-php_value[upload_max_filesize] = "10M" 
-php_value[max_file_uploads] = "100" 
  
 ; End</code> ; End</code>
- 
-<code> 
-php_value[upload_tmp_dir] = "/tmp"</code> 
  
 ===== FastCGI ===== ===== FastCGI =====
  
-  sudo -'/etc/nginx/default.d/blog.conf'+  su - 
 + 
 +  ee '/usr/local/etc/nginx/default.d/blog.conf'
  
 <code> <code>
Line 92: Line 87:
     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/blog.sock+    fastcgi_param HTTPS on; 
-}</code>+    fastcgi_pass 127.0.0.1:9004
 +} 
 + 
 +# End</code>
  
 ===== 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 115: 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 127: 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 136: 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 348: 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.1747438474.txt.gz · Last modified: by Sean Rhone