servers:nginx:wordpress
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
servers:nginx:wordpress [2023/09/01 08:56] – [Database] Sean Rhone | servers:nginx:wordpress [2024/08/13 22:09] (current) – removed Sean Rhone | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Information ====== | ||
- | |||
- | * WordPress ((https:// | ||
- | * [[Information: | ||
- | * https:// | ||
- | |||
- | ===== Prerequisites ===== | ||
- | |||
- | * [[distros: | ||
- | * [[servers: | ||
- | * [[servers: | ||
- | * [[servers: | ||
- | |||
- | ===== Notes ===== | ||
- | |||
- | * :!: Do not initiate any updates from the Admin/ | ||
- | * TODO: https:// | ||
- | |||
- | ====== Dependencies ====== | ||
- | |||
- | * https:// | ||
- | * https:// | ||
- | |||
- | ====== Download Source ====== | ||
- | |||
- | **** | ||
- | |||
- | sudo git clone --branch ' | ||
- | |||
- | ====== Database ====== | ||
- | |||
- | sudo mysql | ||
- | |||
- | CREATE DATABASE wordpress; | ||
- | |||
- | GRANT ALL PRIVILEGES ON wordpress.* to ' | ||
- | |||
- | FLUSH PRIVILEGES; | ||
- | |||
- | EXIT | ||
- | |||
- | ====== nginx + PHP-FPM Configuration ====== | ||
- | |||
- | ===== PHP-FPM Socket ===== | ||
- | |||
- | sudo -e '/ | ||
- | |||
- | < | ||
- | [blog] | ||
- | |||
- | ; User/Group | ||
- | user = nginx | ||
- | group = nginx | ||
- | |||
- | ; Socket | ||
- | listen = 127.0.0.1: | ||
- | listen.acl_users = nginx | ||
- | listen.allowed_clients = 127.0.0.1 | ||
- | |||
- | ; Process Management | ||
- | pm = ondemand | ||
- | pm.max_children = 4 | ||
- | pm.process_idle_timeout = 30 | ||
- | |||
- | ; openSUSE TW php.ini Defaults | ||
- | php_value[session.save_path] = / | ||
- | |||
- | ; General | ||
- | php_value[date.timezone] = " | ||
- | php_value[max_execution_time] = " | ||
- | php_value[memory_limit] = " | ||
- | php_value[post_max_size] = " | ||
- | php_value[upload_max_filesize] = " | ||
- | php_value[max_file_uploads] = " | ||
- | |||
- | ; End</ | ||
- | |||
- | < | ||
- | php_value[upload_tmp_dir] = "/ | ||
- | |||
- | ===== FastCGI ===== | ||
- | |||
- | sudo -e '/ | ||
- | |||
- | < | ||
- | # PHP-FPM | ||
- | location ~ \.(php|phar)(/ | ||
- | fastcgi_split_path_info ^(.+\.(?: | ||
- | |||
- | fastcgi_intercept_errors on; | ||
- | fastcgi_index index.php; | ||
- | include fastcgi_params; | ||
- | fastcgi_param SCRIPT_FILENAME | ||
- | fastcgi_param PATH_INFO $fastcgi_path_info; | ||
- | fastcgi_pass 127.0.0.1: | ||
- | }</ | ||
- | |||
- | ===== Server Block ===== | ||
- | |||
- | * :!: '' | ||
- | |||
- | sudo -e '/ | ||
- | |||
- | < | ||
- | server { | ||
- | listen ' | ||
- | server_name ' | ||
- | root '/ | ||
- | index ' | ||
- | |||
- | include '/ | ||
- | include '/ | ||
- | |||
- | client_max_body_size ' | ||
- | |||
- | add_header Content-Security-Policy " | ||
- | |||
- | # access_log | ||
- | # error_log | ||
- | |||
- | location / { | ||
- | try_files $uri $uri/ / | ||
- | } | ||
- | |||
- | rewrite /wp-admin$ $scheme:// | ||
- | |||
- | location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { | ||
- | access_log off; log_not_found off; expires max; | ||
- | } | ||
- | }</ | ||
- | |||
- | ====== Initial Setup ====== | ||
- | |||
- | * https:// | ||
- | |||
- | ====== Settings ====== | ||
- | |||
- | * Date Format: Y/m/d | ||
- | |||
- | ====== Services ====== | ||
- | |||
- | ===== Updater ===== | ||
- | |||
- | ==== Service ==== | ||
- | |||
- | sudo -e '/ | ||
- | |||
- | < | ||
- | [Service] | ||
- | User=nginx | ||
- | Group=nginx | ||
- | Type=oneshot | ||
- | ExecStart='/ | ||
- | ExecStartPost='/ | ||
- | |||
- | ==== Timer ==== | ||
- | |||
- | * Every day at '' | ||
- | |||
- | sudo -e '/ | ||
- | |||
- | < | ||
- | [Unit] | ||
- | Description=WordPress Git Updater | ||
- | After=network-online.target | ||
- | Wants=network-online.target | ||
- | |||
- | [Timer] | ||
- | OnCalendar=*-*-* 04:00:00 | ||
- | Persistent=true | ||
- | |||
- | [Install] | ||
- | WantedBy=timers.target</ | ||
- | |||
- | ===== Maintenance ===== | ||
- | |||
- | ==== Service ==== | ||
- | |||
- | sudo -e '/ | ||
- | |||
- | < | ||
- | [Service] | ||
- | User=nginx | ||
- | Group=nginx | ||
- | Type=oneshot | ||
- | ExecStart='/ | ||
- | ExecStart='/ | ||
- | ExecStartPost='/ | ||
- | |||
- | ==== Timer ==== | ||
- | |||
- | * '' | ||
- | |||
- | sudo -e '/ | ||
- | |||
- | < | ||
- | [Unit] | ||
- | Description=WordPress Maintenance | ||
- | After=network-online.target | ||
- | Wants=network-online.target | ||
- | |||
- | [Timer] | ||
- | OnCalendar=*-*-01 04:20:00 | ||
- | Persistent=true | ||
- | |||
- | [Install] | ||
- | WantedBy=timers.target</ | ||
- | |||
- | ===== Backup ===== | ||
- | |||
- | ==== Files ==== | ||
- | |||
- | === Service === | ||
- | |||
- | mkdir -p ~/' | ||
- | |||
- | < | ||
- | [Service] | ||
- | Type=oneshot | ||
- | WorkingDirectory=/ | ||
- | ExecStart='/ | ||
- | ExecStartPost='/ | ||
- | |||
- | === Timer === | ||
- | |||
- | * '' | ||
- | |||
- | sudo -e '/ | ||
- | |||
- | < | ||
- | [Unit] | ||
- | Description=WordPress Files Backup | ||
- | |||
- | [Timer] | ||
- | OnCalendar=*-*-01 04:50:00 | ||
- | Persistent=true | ||
- | |||
- | [Install] | ||
- | WantedBy=timers.target</ | ||
- | |||
- | ==== Database ==== | ||
- | |||
- | === Database Auth === | ||
- | |||
- | sudo mkdir -p '/ | ||
- | |||
- | < | ||
- | [mysqldump] | ||
- | user=wordpress | ||
- | password=x</ | ||
- | |||
- | === Service === | ||
- | |||
- | mkdir -p ~/' | ||
- | |||
- | < | ||
- | [Service] | ||
- | Type=oneshot | ||
- | WorkingDirectory=/ | ||
- | ExecStartPre='/ | ||
- | ExecStart='/ | ||
- | ExecStart='/ | ||
- | ExecStartPost='/ | ||
- | |||
- | === Timer === | ||
- | |||
- | * Every day at '' | ||
- | |||
- | sudo -e '/ | ||
- | |||
- | < | ||
- | [Unit] | ||
- | Description=WordPress Database Backup | ||
- | After=mariadb.service | ||
- | |||
- | [Timer] | ||
- | OnCalendar=*-*-* 04:15:00 | ||
- | Persistent=true | ||
- | |||
- | [Install] | ||
- | WantedBy=timers.target</ | ||
- | |||
- | ====== Backup ====== | ||
- | |||
- | * Create backup archive on server and transfer to client computer | ||
- | |||
- | ===== Server ===== | ||
- | |||
- | ==== Stop Services ==== | ||
- | |||
- | **** | ||
- | |||
- | sudo systemctl stop nginx php-fpm | ||
- | |||
- | ==== Backup Folder ==== | ||
- | |||
- | **** | ||
- | |||
- | cd '/ | ||
- | |||
- | ==== Backup Database ==== | ||
- | |||
- | **** | ||
- | |||
- | sudo mysqldump --defaults-extra-file='/ | ||
- | |||
- | ==== Start Services ==== | ||
- | |||
- | **** | ||
- | |||
- | sudo systemctl start nginx php-fpm | ||
- | |||
- | ===== Client ===== | ||
- | |||
- | ==== Transfer Files To Client ==== | ||
- | |||
- | **** | ||
- | |||
- | scp espionage724@192.168.1.152: | ||
- | |||
- | ====== Restore ====== | ||
- | |||
- | ===== Client ===== | ||
- | |||
- | ==== Uncompress Database ==== | ||
- | |||
- | * This is only needed if restoring an **automated** database backup ((manual doesn' | ||
- | |||
- | gunzip ~/' | ||
- | |||
- | ==== Transfer Files To Server ==== | ||
- | |||
- | **** | ||
- | |||
- | scp ~/' | ||
- | |||
- | ==== Remove Files ==== | ||
- | |||
- | **** | ||
- | |||
- | rm -f ~/' | ||
- | |||
- | ===== Server ===== | ||
- | |||
- | ==== Stop Services ==== | ||
- | |||
- | **** | ||
- | |||
- | sudo systemctl stop nginx php-fpm | ||
- | |||
- | ==== Remove Previous Folder ==== | ||
- | |||
- | **** | ||
- | |||
- | sudo rm -Rf '/ | ||
- | |||
- | ==== Restore WordPress Folder ==== | ||
- | |||
- | **** | ||
- | |||
- | cd '/ | ||
- | |||
- | ==== Drop Previous Database ==== | ||
- | |||
- | sudo mysql | ||
- | |||
- | DROP DATABASE wordpress; | ||
- | |||
- | FLUSH TABLES; | ||
- | |||
- | EXIT | ||
- | |||
- | ==== Re-create Databases ==== | ||
- | |||
- | sudo mysql | ||
- | |||
- | CREATE DATABASE wordpress; | ||
- | |||
- | EXIT | ||
- | |||
- | ==== Restore Database ==== | ||
- | |||
- | **** | ||
- | |||
- | sudo mysql ' | ||
- | |||
- | ==== Reapply Permissions ==== | ||
- | |||
- | sudo mysql | ||
- | |||
- | GRANT ALL PRIVILEGES ON wordpress.* to ' | ||
- | |||
- | FLUSH PRIVILEGES; | ||
- | |||
- | EXIT | ||
- | |||
- | ==== Start Services ==== | ||
- | |||
- | **** | ||
- | |||
- | sudo systemctl start nginx php-fpm | ||
- | |||
- | ==== Remove Backups ==== | ||
- | |||
- | * Verify that WordPress works before running | ||
- | |||
- | rm ~/' | ||
/srv/www/wiki/data/attic/servers/nginx/wordpress.1693573005.txt.gz · Last modified: (external edit)