Instalação do NGINX e PHP
Inicie executando as seguintes instruções disponível no bloco abaixo:
dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm && \
dnf makecache -y && \
dnf module install php:remi-7.3
Será solicitado uma confirmação, aceite.
dnf install -y nginx git && \
dnf install -y php-fpm php-cli php-mysqlnd php-gd php-curl php-imap php-zip php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-pdo-dblib php-snmp php-soap php-tidy php-sqlite3 php-opcache && \
dnf install -y php-apcu php-mcrypt && \
pecl channel-update pecl.php.net && \
systemctl enable nginx.service && \
systemctl enable php-fpm && \
systemctl start nginx.service && \
systemctl start php-fpm.service
Agora, vamos preparar pasta do serviço para receber o ILLI e definir as configurações.
Execute as seguintes instruções disponível no bloco abaixo:
mv /var/www /var/www.old && \
ln -s /usr/share/nginx/html /var/www && \
echo ":)" > /usr/share/nginx/html/index.html && \
cp -f /etc/php.ini /etc/php.ini.sample && \
cp -f /etc/php-fpm.conf /etc/php-fpm.conf.sample && \
sed -i -e "s/.*cgi.fix_pathinfo =.*/cgi.fix_pathinfo = 0/" /etc/php.ini && \
sed -i -e "s/.*date.timezone =.*/date.timezone = America\/Sao_Paulo/" /etc/php.ini && \
sed -i -e "s/.*upload_max_filesize =.*/upload_max_filesize = 500M/" /etc/php.ini && \
sed -i -e "s/.*post_max_size =.*/post_max_size = 500M/" /etc/php.ini && \
sed -i -e "s/.*memory_limit =.*/memory_limit = 1024M/" /etc/php.ini && \
sed -i -e "s/.*max_execution_time =.*/max_execution_time = 1800/" /etc/php.ini && \
sed -i -e "s/.*max_input_time =.*/max_input_time = 1800/" /etc/php.ini && \
sed -i -e "s/.*emergency_restart_threshold =.*/emergency_restart_threshold = 3/" /etc/php-fpm.conf && \
sed -i -e "s/.*emergency_restart_interval =.*/emergency_restart_interval = 1m/" /etc/php-fpm.conf && \
sed -i -e "s/.*process_control_timeout =.*/process_control_timeout = 5s/" /etc/php-fpm.conf && \
cd ~ && \
dnf install -y xorg-x11-server-Xvfb && \
dnf install -y https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos8.x86_64.rpm && \
echo 'exec xvfb-run -a -s "-screen 0 1280x1024x16" wkhtmltopdf "$@"' | tee /usr/local/bin/wkhtmltopdf.sh >/dev/null && \
chmod a+x /usr/local/bin/wkhtmltopdf.sh && \
sed -i -e "s/.*opcache.enable=.*/opcache.enable=1/" /etc/php.d/10-opcache.ini && \
sed -i -e "s/.*opcache.interned_strings_buffer=.*/opcache.interned_strings_buffer=8/" /etc/php.d/10-opcache.ini && \
sed -i -e "s/.*opcache.max_accelerated_files=.*/opcache.max_accelerated_files=10000/" /etc/php.d/10-opcache.ini && \
sed -i -e "s/.*opcache.memory_consumption=.*/opcache.memory_consumption=128/" /etc/php.d/10-opcache.ini && \
sed -i -e "s/.*opcache.save_comments=.*/opcache.save_comments=1/" /etc/php.d/10-opcache.ini && \
sed -i -e "s/.*opcache.revalidate_freq=.*/opcache.revalidate_freq=1/" /etc/php.d/10-opcache.ini && \
git config --global --add safe.directory '*'
Para configurar o NGINX, precisamos substituir o arquivo de configuração principal, através do comando:
echo "" > /etc/nginx/nginx.conf && \
nano /etc/nginx/nginx.conf
Inserindo o seguinte conteúdo:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
multi_accept on;
}
http {
log_format main '"$remote_addr" $host [$time_local] '
'"$request" $status $body_bytes_sent '
'$request_length $bytes_sent "$http_referer" '
'"$http_user_agent" $request_time "$gzip_ratio"';
access_log off;
sendfile on;
tcp_nopush off;
tcp_nodelay on;
keepalive_requests 100;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
gzip off;
open_file_cache max=2000 inactive=20s;
open_file_cache_valid 60s;
open_file_cache_min_uses 5;
open_file_cache_errors off;
client_max_body_size 500M;
large_client_header_buffers 4 64k;
server_tokens off;
include /etc/nginx/conf.d/*.conf;
}
Criar o arquivo /etc/nginx/fastcgi_params.conf com os comandos abaixo:
nano /etc/nginx/fastcgi_params.conf
Insira o conteúdo conforme abaixo:
try_files $uri =404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_connect_timeout 1800s;
fastcgi_send_timeout 1800s;
fastcgi_read_timeout 1800s;
fastcgi_buffer_size 4096k;
fastcgi_buffers 128 4096k;
fastcgi_busy_buffers_size 4096k;
include fastcgi_params;
Criar o arquivo /etc/nginx/default.d/proxy.conf com os comandos abaixo:
nano /etc/nginx/default.d/proxy.conf
Insira o conteúdo conforme abaixo:
proxy_redirect off;
proxy_http_version 1.1;
proxy_buffering on;
proxy_buffer_size 4096k;
proxy_buffers 128 4096k;
proxy_busy_buffers_size 4096k;
proxy_connect_timeout 1800s;
proxy_send_timeout 1800s;
proxy_read_timeout 1800s;
send_timeout 1800s;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
Criar o arquivo /etc/nginx/default.d/default.conf com os comandos abaixo:
nano /etc/nginx/default.d/default.conf
Insira o conteúdo conforme abaixo:
location / {
index index.php index.html index.htm;
rewrite ^/gestor/(.*)$ /gestor/index.php?u=$1 last;
try_files $uri $uri/ /index.php?$args;
proxy_buffering on;
proxy_buffer_size 4096k;
proxy_buffers 128 4096k;
proxy_busy_buffers_size 4096k;
proxy_connect_timeout 1800s;
proxy_send_timeout 1800s;
proxy_read_timeout 1800s;
send_timeout 1800s;
}
location ^~ /frontend/ {
gzip on;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/x-component;
}
location ^~ /database {
deny all;
return 404;
}
location ~ \.cnf$ {
deny all;
return 404;
}
location ~ \.log$ {
deny all;
return 404;
}
location ~ \.sh$ {
deny all;
return 404;
}
location ~ cookie_(.*)$ {
deny all;
return 404;
}
location ~ config_local_(.*)$ {
deny all;
return 404;
}
location ^~ /.git/ {
deny all;
return 404;
}
location ^~ /backend/ {
deny all;
return 404;
}
location ^~ /documentacao/ {
deny all;
return 404;
}
location ^~ /migrations/ {
deny all;
return 404;
}
location ^~ /extras/nfe/ {
deny all;
return 404;
}
location ^~ /extras/nfephp/ {
deny all;
return 404;
}
error_page 404 /404.html;
location = /40x.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
Criar o arquivo /etc/nginx/default.d/php.conf com os comandos abaixo:
echo "" > /etc/nginx/default.d/php.conf && \
nano /etc/nginx/default.d/php.conf
Insira o conteúdo conforme abaixo:
location ~ \.php$ {
fastcgi_pass unix:/var/lib/php/php-fpm-illi.sock;
include fastcgi_params.conf;
}
Criar o arquivo /etc/nginx/default.d/php-sincronismo.conf com os comandos abaixo:
nano /etc/nginx/default.d/php-sincronismo.conf
Insira o conteúdo conforme abaixo:
location ~ \.php$ {
fastcgi_pass unix:/var/lib/php/php-fpm-illi-sincronismo.sock;
include fastcgi_params.conf;
}
E finalizamos com a preparação das pastas de trabalho, com os seguintes comandos:
mkdir -p /var/lib/php/sessions && \
mkdir -p /var/lib/php/operacional && \
mkdir -p /var/lib/php/sincronismo && \
mkdir -p /var/lib/php/relatorios && \
chown root:apache /var/lib/php/session && \
chown root:apache /var/lib/php/sessions && \
chmod 777 /var/lib/php/session && \
chmod 777 /var/lib/php/sessions