From 80182ba6e5642ec49fe7b919223c9228be7c01c7 Mon Sep 17 00:00:00 2001 From: Emerson Rocha Luiz Date: Fri, 24 May 2019 10:44:32 -0300 Subject: [PATCH] aguia-pescadora-bravo (#16), php (#7), php-web (#41): MVP de exibir conteudo gerado por PHP via HTTP/HTTPS --- logbook/aguia-pescadora-bravo.sh | 16 +++-- .../sites-available/fititnt.apb.etica.ai.conf | 10 ++-- .../fititnt.apb.etica.ai.conf--antigo | 60 ------------------- .../loopchaves.apb.etica.ai.conf | 34 +++++++++++ .../usuariodeteste.apb.etica.ai.conf | 34 +++++++++++ 5 files changed, 83 insertions(+), 71 deletions(-) delete mode 100644 logbook/aguia-pescadora-bravo/etc/nginx/sites-available/fititnt.apb.etica.ai.conf--antigo diff --git a/logbook/aguia-pescadora-bravo.sh b/logbook/aguia-pescadora-bravo.sh index 33eb63b..63c04a4 100644 --- a/logbook/aguia-pescadora-bravo.sh +++ b/logbook/aguia-pescadora-bravo.sh @@ -416,8 +416,11 @@ sudo usermod -a -G www-data loopchaves sudo -u loopchaves mkdir /home2/loopchaves/web sudo -u loopchaves mkdir /home2/loopchaves/web/public_html sudo -u loopchaves mkdir /home2/loopchaves/web/public_api +sudo -u loopchaves mkdir /home2/loopchaves/web/php sudo -u loopchaves echo "loopchaves
Servidor comunitario: http://aguia-pescadora-bravo.etica.ai
Arquivo: /home2/loopchaves/web/public_html/index.html" > /home2/loopchaves/web/public_html/index.html +sudo -u loopchaves echo "loopchaves
Servidor comunitario: http://aguia-pescadora-bravo.etica.ai
Arquivo: /home2/loopchaves/web/php/index.php
" > /home2/loopchaves/web/php/index.php + sudo cp /etc/nginx/sites-available/EXEMPLO-USUARIO.abp.etica.ai.conf /etc/nginx/sites-available/loopchaves.apb.etica.ai.conf @@ -429,6 +432,7 @@ sudo nginx -t sudo systemctl reload nginx sudo certbot --nginx -d loopchaves.apb.etica.ai +sudo certbot --nginx -d php.loopchaves.apb.etica.ai sudo chown loopchaves:loopchaves -R /home2/loopchaves @@ -447,12 +451,13 @@ sudo chmod 751 /home2/usuariodeteste # Em Home2, prepara diretórios comuns para sair usando apps web -sudo mkdir /home2/usuariodeteste/web -sudo mkdir /home2/usuariodeteste/web/public_html -sudo mkdir /home2/usuariodeteste/web/public_api +sudo -u usuariodeteste mkdir /home2/usuariodeteste/web +sudo -u usuariodeteste mkdir /home2/usuariodeteste/web/public_html +sudo -u usuariodeteste mkdir /home2/usuariodeteste/web/public_api +sudo -u usuariodeteste mkdir /home2/usuariodeteste/web/php -sudo echo "usuariodeteste
Servidor comunitario: http://aguia-pescadora-bravo.etica.ai
Arquivo: /home2/usuariodeteste/web/public_html/index.html" > /home2/usuariodeteste/web/public_html/index.html -sudo chown usuariodeteste:usuariodeteste /home2/usuariodeteste/web/public_html/index.html +sudo -u usuariodeteste echo "usuariodeteste
Servidor comunitario: http://aguia-pescadora-bravo.etica.ai
Arquivo: /home2/usuariodeteste/web/public_html/index.html" > /home2/usuariodeteste/web/public_html/index.html +sudo -u usuariodeteste echo "usuariodeteste
Servidor comunitario: http://aguia-pescadora-bravo.etica.ai
Arquivo: /home2/usuariodeteste/web/php/index.php
" > /home2/usuariodeteste/web/php/index.php sudo vim /etc/nginx/sites-available/usuariodeteste.apb.etica.ai.conf # Adicione todas as customizacoes deste usuario no arquivo acima... @@ -482,6 +487,7 @@ curl http://python.usuariodeteste.lb-ap.etica.ai # Linha de comando para obter certificados. Automaticamente já edita configurações do NGinx # Nota: o subdominio de lb-ap via HTTPS ainda não sera adicionado, veja https://github.com/fititnt/cplp-aiops/issues/35#issuecomment-495508373 sudo certbot --nginx -d usuariodeteste.apb.etica.ai +sudo certbot --nginx -d php.usuariodeteste.apb.etica.ai #------------------------------------------------------------------------------# # SEÇÃO 1.1: USUÁRIOS DO SISTEMA - MENSAGENS INFORMATIVAS # diff --git a/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/fititnt.apb.etica.ai.conf b/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/fititnt.apb.etica.ai.conf index 44617b7..d696b1d 100644 --- a/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/fititnt.apb.etica.ai.conf +++ b/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/fititnt.apb.etica.ai.conf @@ -31,28 +31,26 @@ server { ### OPÇÕES PARA DEBUG EXCLUSIVAMENTE NESTE DOMINIO, INICIO # Autoindex não é algo recomendado. Porém fititnt está debugando - autoindex on; + #autoindex on; # Desliguei isso no final. Este modo de debug é MUITO detalhado. Pode lotar o disco! - error_log /var/log/nginx/error-fititnt.log debug; + #error_log /var/log/nginx/error-fititnt.log debug; # Use isto por terminal: # tail -f /var/log/nginx/error-fititnt.log ### OPÇÕES PARA DEBUG EXCLUSIVAMENTE NESTE DOMINIO, INICIO location / { - try_files $uri $uri/ /index.php?$query_string; + try_files $uri $uri/ =404; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } location ~ \.php$ { + include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; - fastcgi_index index.php; - include fastcgi_params; } - listen [::]:443 ssl; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/php.fititnt.apb.etica.ai/fullchain.pem; # managed by Certbot diff --git a/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/fititnt.apb.etica.ai.conf--antigo b/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/fititnt.apb.etica.ai.conf--antigo deleted file mode 100644 index 35fcd8a..0000000 --- a/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/fititnt.apb.etica.ai.conf--antigo +++ /dev/null @@ -1,60 +0,0 @@ -# FILE: /etc/nginx/sites-available/fititnt.apb.etica.ai.conf - -server { - root /home2/fititnt/web/public_html; - - index index.html; - - server_name fititnt.apb.etica.ai fititnt.lb-ap.etica.ai; - - ### OPES PARA DEBUG EXCLUSIVAMENTE NESTE DOMINIO, INICIO - # Autoindex no algo recomendado. Porm fititnt est debugando - autoindex on; - # Desliguei isso no final. Este modo de debug MUITO detalhado. Pode lotar o disco! - error_log /var/log/nginx/error-fititnt.log debug; - - # Use isto por terminal: - # tail -f /var/log/nginx/error-fititnt.log - ### OPES PARA DEBUG EXCLUSIVAMENTE NESTE DOMINIO, INICIO - - location / { - try_files $uri $uri/ =404; - } - - location ^~ /php { - root /home2/fititnt/web/php; - - index index.php; - try_files $uri $uri/ index.php; - - location ~ \.php$ { - include snippets/fastcgi-php.conf; - # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; - } - } - - listen [::]:443 ssl; # managed by Certbot - listen 443 ssl; # managed by Certbot - ssl_certificate /etc/letsencrypt/live/fititnt.apb.etica.ai/fullchain.pem; # managed by Certbot - ssl_certificate_key /etc/letsencrypt/live/fititnt.apb.etica.ai/privkey.pem; # managed by Certbot - include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot - ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot - -} - -server { - if ($host = fititnt.apb.etica.ai) { - return 301 https://$host$request_uri; - } # managed by Certbot - - - - listen 80; - listen [::]:80; - - server_name fititnt.apb.etica.ai fititnt.lb-ap.etica.ai; - return 404; # managed by Certbot - - -} \ No newline at end of file diff --git a/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/loopchaves.apb.etica.ai.conf b/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/loopchaves.apb.etica.ai.conf index a13cd9a..974e356 100644 --- a/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/loopchaves.apb.etica.ai.conf +++ b/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/loopchaves.apb.etica.ai.conf @@ -21,4 +21,38 @@ server { include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot +} + +# PHP +server { + + listen 80; + listen [::]:80; + root /home2/loopchaves/web/php; + + index index.html index.htm index.php; + + server_name php.loopchaves.apb.etica.ai php.loopchaves.lb-ap.etica.ai; + + location / { + try_files $uri $uri/ =404; + } + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + } + + + + listen [::]:443 ssl; # managed by Certbot + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/php.loopchaves.apb.etica.ai/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/php.loopchaves.apb.etica.ai/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + } \ No newline at end of file diff --git a/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/usuariodeteste.apb.etica.ai.conf b/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/usuariodeteste.apb.etica.ai.conf index 332fcd1..5af2899 100644 --- a/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/usuariodeteste.apb.etica.ai.conf +++ b/logbook/aguia-pescadora-bravo/etc/nginx/sites-available/usuariodeteste.apb.etica.ai.conf @@ -21,4 +21,38 @@ server { include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot +} + +# PHP +server { + + listen 80; + listen [::]:80; + root /home2/usuariodeteste/web/php; + + index index.html index.htm index.php; + + server_name php.usuariodeteste.apb.etica.ai php.usuariodeteste.lb-ap.etica.ai; + + location / { + try_files $uri $uri/ =404; + } + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + } + + + + listen [::]:443 ssl; # managed by Certbot + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/php.usuariodeteste.apb.etica.ai/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/php.usuariodeteste.apb.etica.ai/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + } \ No newline at end of file