Skip to content

Commit

Permalink
aguia-pescadora-bravo (#16), php (#7), php-web (#41): instalado php-fpm
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed May 24, 2019
1 parent 17bee01 commit d160a1b
Show file tree
Hide file tree
Showing 7 changed files with 2,686 additions and 4 deletions.
45 changes: 42 additions & 3 deletions logbook/aguia-pescadora-bravo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ sudo usermod -aG sudo fititnt
## Dominios customizados de fititnt (já adicionados na CloudFlare)
curl http://fititnt.apb.etica.ai
curl http://fititnt.lb-ap.etica.ai
curl http://php.fititnt.apb.etica.ai
curl http://php.fititnt.lb-ap.etica.ai
curl http://go.fititnt.apb.etica.ai
curl http://go.fititnt.lb-ap.etica.ai

# Aviso: descrição da razão dessaes passos esta em usuariodeteste
sudo mkdir /home2/fititnt
Expand All @@ -367,10 +371,10 @@ sudo usermod -a -G www-data fititnt
sudo -u fititnt mkdir /home2/fititnt/web
sudo -u fititnt mkdir /home2/fititnt/web/public_html
sudo -u fititnt mkdir /home2/fititnt/web/public_api
sudo -u fititnt mkdir /home2/fititnt/web/public_php
sudo -u fititnt mkdir /home2/fititnt/web/php

sudo -u fititnt echo "fititnt <br>Servidor comunitario: http://aguia-pescadora-bravo.etica.ai <br>Arquivo: /home2/fititnt/web/public_html/index.html" > /home2/fititnt/web/public_html/index.html
sudo -u fititnt echo "fititnt <br>Servidor comunitario: http://aguia-pescadora-bravo.etica.ai <br>Arquivo: /home2/fititnt/web/public_php/index.php <br><?php phpinfo(); ?>" > /home2/fititnt/web/public_php/index.php
sudo -u fititnt echo "fititnt <br>Servidor comunitario: http://aguia-pescadora-bravo.etica.ai <br>Arquivo: /home2/fititnt/web/php/index.php <br><?php phpinfo(); ?>" > /home2/fititnt/web/php/index.php

sudo cp /etc/nginx/sites-available/EXEMPLO-USUARIO.abp.etica.ai.conf /etc/nginx/sites-available/fititnt.apb.etica.ai.conf

Expand All @@ -382,6 +386,7 @@ sudo nginx -t
sudo systemctl reload nginx

sudo certbot --nginx -d fititnt.apb.etica.ai
sudo certbot --nginx -d php.fititnt.apb.etica.ai
# Nota: neste site escolhido redirecionar todo trafico HTTP para HTTPS

sudo chown fititnt:fititnt -R /home2/fititnt
Expand All @@ -394,6 +399,12 @@ sudo usermod -aG sudo loopchaves
## Dominios customizados de loopchaves (já adicionados na CloudFlare)
curl http://loopchaves.apb.etica.ai
curl http://loopchaves.lb-ap.etica.ai
curl http://php.loopchaves.apb.etica.ai
curl http://php.loopchaves.lb-ap.etica.ai
curl http://go.loopchaves.apb.etica.ai
curl http://go.loopchaves.lb-ap.etica.ai
curl http://python.loopchaves.apb.etica.ai
curl http://python.loopchaves.lb-ap.etica.ai

# Aviso: descrição da razão dessaes passos esta em usuariodeteste
sudo mkdir /home2/loopchaves
Expand Down Expand Up @@ -460,6 +471,12 @@ sudo chown usuariodeteste:usuariodeteste -R /home2/usuariodeteste
## Dominios customizados de usuariodeteste (já adicionados na CloudFlare)
curl http://usuariodeteste.apb.etica.ai
curl http://usuariodeteste.lb-ap.etica.ai
curl http://php.usuariodeteste.apb.etica.ai
curl http://php.usuariodeteste.lb-ap.etica.ai
curl http://go.usuariodeteste.apb.etica.ai
curl http://go.usuariodeteste.lb-ap.etica.ai
curl http://python.usuariodeteste.apb.etica.ai
curl http://python.usuariodeteste.lb-ap.etica.ai

## Certificado HTTPS para usuariodeteste
# Linha de comando para obter certificados. Automaticamente já edita configurações do NGinx
Expand Down Expand Up @@ -814,10 +831,12 @@ sudo apt-get install sbcl
# Após esta operação, serão utilizados 47,7 MB adicionais de espaço em disco

##### PHP ______________________________________________________________________
# @see https://github.com/fititnt/cplp-aiops/issues/7
# @see https://github.com/fititnt/cplp-aiops/issues/41
# @see https://php.net/
# @see https://www.php.net/manual/pt_BR/

# PHP 7.2
## PHP 7.2
sudo apt install php-cli php-common
# Resultado do comando acima:
# (...)
Expand All @@ -830,6 +849,26 @@ sudo apt install php-cli php-common
# @TODO adicionar multiplas versões de PHP, não apenas a 7.2
# (fititnt, 2019-05-18 21:22 BRT)

## PHP 7.2, para web
# @see https://github.com/fititnt/cplp-aiops/issues/7
sudo apt install php-fpm

sudo systemctl start php7.2-fpm
sudo systemctl enable php7.2-fpm
# AVISO: o sistema tem um PHP-FPM padrão que roda com www-data, que pode servir
# para casos simples. Porém o recomendado é que cada usuário e projeto
# tenha seu próprio worker de PHP-FPM

# Nota: arquivo /etc/php/7.2/fpm/pool.d/www.conf pode precisar de ajuste para
# usar o log a seguir
sudo touch /var/log/fpm-php.www.log
sudo chown www-data:www-data /var/log/fpm-php.www.log

## Acompanhar logs de erros comuns (usados caso usuario não especifique)
sudo tail -f /var/log/fpm-php.www.log
sudo tail -f /etc/nginx/error.log
sudo tail -f /etc/nginx/access.log

##### Python ___________________________________________________________________
# @see https://www.python.org/
# @see https://pypi.org/
Expand Down
38 changes: 38 additions & 0 deletions logbook/aguia-pescadora-bravo/etc/nginx/fititnt.apb.etica.ai.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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;

location / {
try_files $uri $uri/ =404;
}


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


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ server {
try_files $uri $uri/ =404;
}


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
Expand All @@ -20,6 +21,47 @@ server {

}

# PHP
server {
server_name php.fititnt.apb.etica.ai php.fititnt.lb-ap.etica.ai;

root /home2/fititnt/web/php;

index index.html index.htm index.php;

### OPÇÕES PARA DEBUG EXCLUSIVAMENTE NESTE DOMINIO, INICIO
# Autoindex não é algo recomendado. Porém 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
### OPÇÕES PARA DEBUG EXCLUSIVAMENTE NESTE DOMINIO, INICIO

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

location ~ \.php$ {
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
ssl_certificate_key /etc/letsencrypt/live/php.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;
Expand All @@ -30,7 +72,20 @@ server {
listen 80;
listen [::]:80;

server_name fititnt.apb.etica.ai fititnt.lb-ap.etica.ai;
server_name fititnt.apb.etica.ai fititnt.lb-ap.etica.ai ;
return 404; # managed by Certbot


}
server {
if ($host = php.fititnt.apb.etica.ai) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80;
listen [::]:80;
server_name php.fititnt.apb.etica.ai php.fititnt.lb-ap.etica.ai;
return 404; # managed by Certbot


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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;

### OP��ES PARA DEBUG EXCLUSIVAMENTE NESTE DOMINIO, INICIO
# Autoindex n�o � algo recomendado. Por�m 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
### OP��ES 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


}
Loading

0 comments on commit d160a1b

Please sign in to comment.