Welcome to our serious tutorial. When we are installing PrestaShop 1.7.6.3 on CWP7.pro server, we are getting error "Nginx 504 Gateway Time-out " That means CWP The gateway did not receive a timely response from the upstream server or application.
1. Adjust Timeout Value for proxy settings
Now Llet's add fastcgi_read_timeout variable inside our Nginx virtual host configuration. If you use PHP-FPM hosting then add (you can use 600s)
1. Adjust Timeout Value for proxy settings
# vi /etc/nginx/proxy.inc
proxy_connect_timeout 600s;
proxy_send_timeout 600;
proxy_read_timeout 600;
2. Change the default_socket_timeout # vi /opt/alt/php-fpm72/usr/php/php.ini
default_socket_timeout 600
Change PHP-FPM Configuration:
Default Location:/opt/alt/php-fpm72/usr/etc/
/opt/alt/php-fpm72/usr/etc/php-fpm.d/
/opt/alt/php-fpm72/usr/etc/php-fpm.d/users/
3. Add following value cwpsvc.conf file : # vi /opt/alt/php-fpm72/usr/etc/php-fpm.d/cwpsvc.conf
[cwpsvc]
listen = /opt/alt/php-fpm72/usr/var/sockets/cwpsvc.sock
listen.owner = cwpsvc
listen.group = cwpsvc
listen.mode = 0640
user = cwpsvc
group = cwpsvc
;request_slowlog_timeout = 5s
;slowlog = /opt/alt/php-fpm72/usr/var/log/php-fpm-slowlog-cwpsvc.log
listen.allowed_clients = 127.0.0.1
pm = ondemand
pm.max_children = 1000
pm.process_idle_timeout = 300s
;listen.backlog = -1
request_terminate_timeout = 300s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
4. Add following value nobody.conf file :# vi /opt/alt/php-fpm72/usr/etc/php-fpm.d/users/nobody.conf
[nobody]
listen = /opt/alt/php-fpm72/usr/var/sockets/nobody.sock
listen.allowed_clients = 127.0.0.1
listen.owner = nobody
listen.group = nobody
listen.mode = 0660
user = nobody
group = nobody
;request_slowlog_timeout = 15s
;slowlog = /opt/alt/php-fpm72/usr/var/log/php-fpm-slowlog-nobody.log
pm = ondemand
pm.max_children = 1000
pm.max_requests = 6000
pm.process_idle_timeout = 300s
;listen.backlog = -1
request_terminate_timeout = 300s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
env[PATH] = /usr/local/bin:/usr/bin:/bin
5. Change the following # vi /opt/alt/php-fpm72/usr/etc/php-fpm.d/users/datahead.conf
[datahead]
listen = /opt/alt/php-fpm72/usr/var/sockets/datahead.sock
listen.allowed_clients = 127.0.0.1
;listen.owner = "datahead"
listen.group = "nobody"
listen.mode = 0660
user = "datahead"
group = "datahead"
;request_slowlog_timeout = 15s
;slowlog = /opt/alt/php-fpm72/usr/var/log/php-fpm-slowlog-datahead.log
pm = ondemand
pm.max_children = 1000
pm.max_requests = 4000
pm.process_idle_timeout = 300s
;listen.backlog = -1
request_terminate_timeout = 300s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[TMP] = /home/datahead/tmp
env[TMPDIR] = /home/datahead/tmp
env[TEMP] = /home/datahead/tmp
env[PATH] = /usr/local/bin:/usr/bin:/bin
N.B: Change the value only which is only marked as Blue.Now Llet's add fastcgi_read_timeout variable inside our Nginx virtual host configuration. If you use PHP-FPM hosting then add (you can use 600s)
# vi /etc/nginx/conf.d/vhosts/datahead.biz.ssl.conf
fastcgi_pass unix:/opt/alt/php-fpm72/usr/var/sockets/datahead.sock;
fastcgi_index index.php;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
include /etc/nginx/fastcgi_params;
If you use PHP-CGI , then use it nginx.conf file: # Proxy settings
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
proxy_buffers 32 4k;
If you use PHP Selector 2# sed -i 's,^upload_max_filesize =.*$,upload_max_filesize = 4096M,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^post_max_size =.*$,post_max_size = 4146M,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^memory_limit =.*$,memory_limit = 5120M,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^max_input_time =.*$,max_input_time = 300,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^max_execution_time =.*$,max_execution_time = 300,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^; max_input_vars =.*$,max_input_vars = 5000,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^max_file_uploads =.*$,max_file_uploads = 50,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^allow_url_fopen =.*$,allow_url_fopen = On,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^allow_url_include =.*$,allow_url_include = Off,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^short_open_tag =.*$,short_open_tag = Off,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^;date.timezone =.*$,date.timezone = Asia/Dhaka,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^display_errors =.*$,display_errors = Off,' /opt/alt/php72/usr/php/php.ini
# sed -i 's,^expose_php =.*$,expose_php = Off,' /opt/alt/php72/usr/php/php.ini
PHP Security
https://nixcp.com/hardening-php-on-cpanel/
https://docs.cpanel.net/knowledge-base/security/php-security-concepts/
https://www.cyberciti.biz/faq/linux-unix-apache-lighttpd-phpini-disable-functions/
https://www.cyberciti.biz/tips/php-security-best-practices-tutorial.html
https://electrictoolbox.com/php-command-line-syntax-checking/
https://tecadmin.net/category/programming/php-2/
Comments
Post a Comment
You are always welcome to comment here, but your remarks should be relevant to the conversation. To keep the exchanges focused and engaging, we reserve the right to remove off-topic comments, or self-promoting URLs and vacuous messages.
We will try to reply to your queries as soon as time allows.
Regards,
Admin