User Tools

Site Tools


servers:nginx:zenphoto

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
servers:nginx:zenphoto [2019/06/28 22:46]
Sean Rhone Change to Fedora Server
servers:nginx:zenphoto [2019/12/15 10:31] (current)
Sean Rhone [PHP-FPM Socket]
Line 7: Line 7:
 ===== Prerequisites ===== ===== Prerequisites =====
  
-  * [[distros:fedora_server|Fedora Server]] +  * [[distros:ubuntu_server|Ubuntu Server]] 
-  * [[servers:mariadb | MariaDB]] +  * [[servers:mariadb|MariaDB]] 
-  * [[servers:nginx_php_php-fpm | nginx + PHP + PHP-FPM]] +  * [[servers:nginx_php_php-fpm|nginx + PHP + PHP-FPM]] 
-  * [[servers:nginx:lets_encrypt | Let's Encrypt]]+  * [[servers:nginx:lets_encrypt|Let's Encrypt]]
  
 ====== Download Source ====== ====== Download Source ======
Line 16: Line 16:
 **** ****
  
-  sudo rm -Rf '/var/www/media' && sudo git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/zenphoto/zenphoto.git' '/var/www/media' && sudo chown -R 'nginx':'nginx' '/var/www/media' && sync +  sudo rm -Rf '/var/www/media' && sudo git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/zenphoto/zenphoto.git' '/var/www/media' && sudo chown -R 'www-data':'www-data' '/var/www/media' && sync
- +
-===== SELinux ===== +
- +
-  sudo semanage fcontext --deleteall "/var/www/media(/.*)?" +
- +
-  sudo semanage fcontext --add --type 'httpd_sys_rw_content_t' "/var/www/media(/.*)?" +
- +
-  sudo restorecon -R -v '/var/www/media' && sync+
  
 ====== Database ====== ====== Database ======
  
-  mysql --user='root' --password+  sudo mysql
  
   CREATE DATABASE zenphoto;   CREATE DATABASE zenphoto;
Line 35: Line 27:
  
   FLUSH PRIVILEGES;   FLUSH PRIVILEGES;
 +
 +  EXIT
  
 ====== nginx + PHP-FPM Configuration ====== ====== nginx + PHP-FPM Configuration ======
Line 40: Line 34:
 ===== PHP-FPM Socket ===== ===== PHP-FPM Socket =====
  
-  sudo -e '/etc/php-fpm.d/media.conf' && sudo systemctl restart 'php-fpm'+  sudo -e '/etc/php/7.2/fpm/pool.d/media.conf' && sudo systemctl restart 'php7.2-fpm'
  
 <code> <code>
 [media] [media]
-user = nginx +user = www-data 
-group = nginx+group = www-data
  
-listen = /run/php-fpm/media.sock +listen = /run/php/media.sock 
-listen.owner = nginx +listen.owner = www-data 
-listen.group = nginx+listen.group = www-data
 listen.allowed_clients = 127.0.0.1 listen.allowed_clients = 127.0.0.1
  
Line 67: Line 61:
 php_value[max_file_uploads] = "100" php_value[max_file_uploads] = "100"
  
-php_value[session.save_handler] = files +php_value[session.save_handler] = "files" 
-php_value[session.save_path] = /var/lib/php/session +php_value[session.save_path] = "/var/lib/php/sessions" 
-php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache +php_value[soap.wsdl_cache_dir] = "/var/lib/php/wsdlcache" 
-php_value[opcache.file_cache] = /var/lib/php/opcache</code>+php_value[opcache.file_cache] = "/var/lib/php/opcache"</code>
  
 ===== FastCGI ===== ===== FastCGI =====
  
-  sudo -e '/etc/nginx/default.d/media.conf'+  sudo -e '/etc/nginx/snippets/media.conf'
  
 <code> <code>
Line 86: Line 80:
     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/media.sock;+    fastcgi_pass unix:/run/php/media.sock;
 }</code> }</code>
  
 ===== Server Block ===== ===== Server Block =====
  
-  sudo -e '/etc/nginx/conf.d/media.conf' && sudo systemctl reload 'nginx'+  sudo -e '/etc/nginx/sites-available/media.conf'
  
 <code> <code>
Line 100: Line 94:
     index 'index.php';     index 'index.php';
  
-    include '/etc/nginx/default.d/media.conf'; +    include '/etc/nginx/snippets/media.conf'; 
-    include '/etc/nginx/default.d/headers.conf';+    include '/etc/nginx/snippets/headers.conf';
  
     client_max_body_size '500M';     client_max_body_size '500M';
Line 114: Line 108:
     }     }
 }</code> }</code>
 +
 +==== Enable ====
 +
 +****
 +
 +  sudo rm -f '/etc/nginx/sites-enabled/media.conf' && sudo ln -s '/etc/nginx/sites-available/media.conf' '/etc/nginx/sites-enabled/media.conf' && sudo systemctl reload 'nginx' && sync
  
 ====== Initial Setup ====== ====== Initial Setup ======
Line 121: Line 121:
   * Zenphoto tests for a UTF8-compliant filesystem and expects the following file to exist   * Zenphoto tests for a UTF8-compliant filesystem and expects the following file to exist
  
-  sudo -u 'nginx' touch '/var/www/media/zp-data/charset_tést'+  sudo -u 'www-data' touch '/var/www/media/zp-data/charset_tést'
  
 ===== Site ===== ===== Site =====
Line 137: Line 137:
 <code> <code>
 [Service] [Service]
-User=nginx +User=www-data 
-Group=nginx+Group=www-data
 Type=oneshot Type=oneshot
 WorkingDirectory=/var/www/media WorkingDirectory=/var/www/media
 ExecStart='/usr/bin/git' -C '/var/www/media' pull origin 'master' ExecStart='/usr/bin/git' -C '/var/www/media' pull origin 'master'
-ExecStartPost='/usr/bin/sync'</code>+ExecStartPost='/bin/sync'</code>
  
 ==== Timer ==== ==== Timer ====
Line 171: Line 171:
 <code> <code>
 [Service] [Service]
-User=nginx +User=www-data 
-Group=nginx+Group=www-data
 Type=oneshot Type=oneshot
 ExecStart='/usr/bin/git' -C '/var/www/media' gc --aggressive --prune='all' ExecStart='/usr/bin/git' -C '/var/www/media' gc --aggressive --prune='all'
 ExecStart='/usr/bin/git' -C '/var/www/media' fsck --full --strict ExecStart='/usr/bin/git' -C '/var/www/media' fsck --full --strict
-ExecStartPost='/usr/bin/sync'</code>+ExecStartPost='/bin/sync'</code>
  
 ==== Timer ==== ==== Timer ====
Line 209: Line 209:
 Type=oneshot Type=oneshot
 WorkingDirectory=/var/www WorkingDirectory=/var/www
-ExecStart='/usr/bin/bash' -c '"/usr/bin/tar" -cvzf "/home/CHANGEME/backups/zenphoto-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "media"' +ExecStart='/bin/bash' -c '"/bin/tar" -cvzf "/home/CHANGEME/backups/zenphoto-files-auto-"$$(date +%%Y-%%m-%%d)".tar.gz" "media"' 
-ExecStartPost='/usr/bin/sync'</code>+ExecStartPost='/bin/sync'</code>
  
 === Timer === === Timer ===
Line 247: Line 247:
 [Service] [Service]
 Type=oneshot Type=oneshot
-WorkingDirectory=/var/lib/mysqltmp+WorkingDirectory=/var/lib/mysql/tmp
 ExecStartPre='/usr/bin/mysqldump' --defaults-extra-file='/var/lib/mysql/auth/zenphoto' --single-transaction 'zenphoto' -r '/var/lib/mysql/tmp/zenphoto.sql' ExecStartPre='/usr/bin/mysqldump' --defaults-extra-file='/var/lib/mysql/auth/zenphoto' --single-transaction 'zenphoto' -r '/var/lib/mysql/tmp/zenphoto.sql'
-ExecStart='/usr/bin/gzip' -f '/var/lib/mysql/tmp/zenphoto.sql' +ExecStart='/bin/gzip' -f '/var/lib/mysql/tmp/zenphoto.sql' 
-ExecStart='/usr/bin/bash' -c '"/usr/bin/mv" "/var/lib/mysql/tmp/zenphoto.sql.gz" "/home/CHANGEME/backups/zenphoto-database-auto-"$$(date +%%Y-%%m-%%d)".sql.gz"' +ExecStart='/bin/bash' -c '"/bin/mv" "/var/lib/mysql/tmp/zenphoto.sql.gz" "/home/CHANGEME/backups/zenphoto-database-auto-"$$(date +%%Y-%%m-%%d)".sql.gz"' 
-ExecStartPost='/usr/bin/sync'</code>+ExecStartPost='/bin/sync'</code>
  
 === Timer === === Timer ===
Line 281: Line 281:
 **** ****
  
-  sudo systemctl stop nginx php-fpm+  sudo systemctl stop nginx php7.2-fpm
  
 ==== Backup Folder ==== ==== Backup Folder ====
Line 299: Line 299:
 **** ****
  
-  sudo systemctl start nginx php-fpm+  sudo systemctl start nginx php7.2-fpm
  
 ===== Client ===== ===== Client =====
Line 337: Line 337:
 **** ****
  
-  sudo systemctl stop nginx php-fpm+  sudo systemctl stop nginx php7.2-fpm
  
 ==== Remove Previous Folder ==== ==== Remove Previous Folder ====
Line 349: Line 349:
 **** ****
  
-  cd '/var/www' && sudo tar -xvzf ~/'zenphoto-files-'*'.tar.gz' 'media' && sudo chown -R 'nginx':'nginx' '/var/www/media' && cd ~ && sync +  cd '/var/www' && sudo tar -xvzf ~/'zenphoto-files-'*'.tar.gz' 'media' && sudo chown -R 'www-data':'www-data' '/var/www/media' && cd ~ && sync
- +
-==== SELinux ==== +
- +
-  sudo semanage fcontext --deleteall "/var/www/media(/.*)?" +
- +
-  sudo semanage fcontext --add --type 'httpd_sys_rw_content_t' "/var/www/media(/.*)?" +
- +
-  sudo restorecon -R -v '/var/www/media' && sync+
  
 ==== Drop Previous Database ==== ==== Drop Previous Database ====
  
-  mysql --user='root' --password+  sudo mysql
  
   DROP DATABASE zenphoto;   DROP DATABASE zenphoto;
  
   FLUSH TABLES;   FLUSH TABLES;
 +
 +  EXIT
  
 ==== Re-create Databases ==== ==== Re-create Databases ====
  
-  mysql --user='root' --password+  sudo mysql
  
   CREATE DATABASE zenphoto;   CREATE DATABASE zenphoto;
 +
 +  EXIT
  
 ==== Restore Database ==== ==== Restore Database ====
Line 377: Line 373:
 **** ****
  
-  mysql --user='root' --password 'zenphoto' < ~/'zenphoto-database-'*'.sql' && sync+  sudo mysql 'zenphoto' < ~/'zenphoto-database-'*'.sql' && sync
  
 ==== Reapply Permissions ==== ==== Reapply Permissions ====
  
-  mysql --user='root' --password+  sudo mysql
  
   GRANT ALL PRIVILEGES ON zenphoto.* to 'zenphoto'@'localhost' IDENTIFIED BY 'x';   GRANT ALL PRIVILEGES ON zenphoto.* to 'zenphoto'@'localhost' IDENTIFIED BY 'x';
  
   FLUSH PRIVILEGES;   FLUSH PRIVILEGES;
 +
 +  EXIT
  
 ==== Start Services ==== ==== Start Services ====
Line 391: Line 389:
 **** ****
  
-  sudo systemctl start nginx php-fpm+  sudo systemctl start nginx php7.2-fpm
  
 ==== Remove Backups ==== ==== Remove Backups ====
servers/nginx/zenphoto.1561776395.txt.gz · Last modified: 2019/06/28 22:46 by Sean Rhone