<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Arquivos Let’s Encrypt - Remontti</title>
	<atom:link href="https://blog.remontti.com.br/tag/lets-encrypt/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.remontti.com.br/tag/lets-encrypt</link>
	<description>rudimar@remontti</description>
	<lastBuildDate>Thu, 15 Jun 2023 17:34:40 +0000</lastBuildDate>
	<language>pt-BR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.remontti.com.br/wp-content/uploads/2024/09/icone-rr-80x80.png</url>
	<title>Arquivos Let’s Encrypt - Remontti</title>
	<link>https://blog.remontti.com.br/tag/lets-encrypt</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Servidor WEB NGINX + PHP 8.2 + PostgreSQL +Let’s Encrypt  Debian 12 Bookworm (LNP)</title>
		<link>https://blog.remontti.com.br/7413</link>
					<comments>https://blog.remontti.com.br/7413#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Wed, 14 Jun 2023 17:32:09 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[bookworm]]></category>
		<category><![CDATA[Debian 12]]></category>
		<category><![CDATA[Let’s Encrypt]]></category>
		<category><![CDATA[LNP]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP 8.2]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[Servidor WEB]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=7413</guid>

					<description><![CDATA[<p>Neste tutorial vamos configurar um servidor web com NGINX (lê-se “engine x”), o concorrente do Apache. NGINX é um servidor web (HTTP e IMAP/POP3/Proxy) rápido, leve e com inúmeras possibilidades de configuração para melhor&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/7413">Servidor WEB NGINX + PHP 8.2 + PostgreSQL +Let’s Encrypt  Debian 12 Bookworm (LNP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/lnp_debian_12-1.jpg" alt="" width="720" height="340" class="alignnone size-full wp-image-7423" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/lnp_debian_12-1.jpg 720w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lnp_debian_12-1-300x142.jpg 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lnp_debian_12-1-520x245.jpg 520w" sizes="(max-width: 720px) 100vw, 720px" /></p>
<p>Neste tutorial vamos configurar um servidor web com NGINX (lê-se “engine x”), o concorrente do Apache. NGINX é um servidor web (HTTP e IMAP/POP3/Proxy) rápido, leve e com inúmeras possibilidades de configuração para melhor performance. O Apache, sem dúvidas, é o servidor web mais popular. No entanto, o NGINX a cada ano ganha mais popularidade e está sendo a preferência dos novos projetos. Também estarei instalando o banco de dados PostgreSQL e phpPgAdmin como gerenciador web. </p>
<p>Distribuição utilizada: <strong><a href="https://blog.remontti.com.br/7236" rel="noopener noreferrer" target="_blank">Debian 12 Bookworm / Instalação Limpa</a></strong></p>
<h3>NGINX 1.22</h3>
<p><a href="https://www.nginx.com" rel="noopener" target="_blank">https://www.nginx.com</a><br />
Vamos instalar-lo e remover a assinatura para que não vejam a versão do mesmo (Boas praticas)</p>
<pre class="remontti-code"># apt install nginx
# sed -i &#039;s/# server_tokens/server_tokens/&#039; /etc/nginx/nginx.conf
# systemctl restart nginx</pre>
<p>Acesse agora em seu navegador http://IP-SERVIDOR/<br />
<img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1.png" alt="" width="1100" height="310" class="alignnone size-full wp-image-5467" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1.png 1100w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1-300x85.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1-1024x289.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1-768x216.png 768w" sizes="(max-width: 1100px) 100vw, 1100px" /><br />
Pronto nosso NGINX está rodando! </p>
<h3>PostgreSQL</h3>
<pre class="remontti-code"># apt install postgresql postgresql-contrib</pre>
<p>Torne-se o usuário postgres, para poder criar o banco de dados.</p>
<pre class="remontti-code"># su - postgres</pre>
<p>Execute para entrar no terminal de comandos do banco.</p>
<pre class="remontti-code">$ psql</pre>
<p>Para definir a senha do usuário postgres e instalar o adminpack.</p>
<pre class="remontti-code">postgres=# \password postgres
Digite nova senha para postgres: 
Digite-a novamente:
postgres=# CREATE EXTENSION adminpack;
CREATE EXTENSION
postgres=# \q 
$ exit</pre>
<p>Ajustes no pg_hba.conf, assim toda alteração será necessaria validação do postgres com a senha que acabou de definir.</p>
<pre class="remontti-code"># vim /etc/postgresql/15/main/pg_hba.conf</pre>
<p>Altere as seguintes linhas: </p>
<pre class="remontti-code">local   all             postgres                                peer
local   all             all                                     peer</pre>
<p>Para:</p>
<pre class="remontti-code">local   all             postgres                                md5
local   all             all                                     md5</pre>
<p><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/postgres.png" alt="" width="1010" height="268" class="alignnone size-full wp-image-5501" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/postgres.png 1010w, https://blog.remontti.com.br/wp-content/uploads/2021/04/postgres-300x80.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/postgres-768x204.png 768w" sizes="(max-width: 1010px) 100vw, 1010px" /><br />
Reinicie o postgres</p>
<pre class="remontti-code"># systemctl restart postgresql</pre>
<p>Volte para o postgres</p>
<pre class="remontti-code"># su - postgres</pre>
<p>Agora para toda ação será necessário autenticar.</p>
<pre class="remontti-code">$ psql 
Senha para usuário postgres: !!SUA_SENHA!!
psql (15.3 (Debian 15.3-0+deb12u1))
Type &quot;help&quot; for help.
postgres-# \q</pre>
<p>Para demonstração irei criar um banco/usuário teste, não esqueça de alterar a senha.</p>
<pre class="remontti-code">$ createuser --pwprompt teste
Digite a senha para a nova role: &lt;&lt; NOVA SENHA PARA O USUÁRIO TESTE
Digite-a novamente: &lt;&lt; REPITA
Senha: &lt;&lt; SENHA DO QUE SETOU ANTES  NO COMANDO &quot;\password postgres&quot;</pre>
<p>Agora crie o  banco e vincule ao usuário.</p>
<pre class="remontti-code">$ createdb -O teste meubd
Senha: &lt;&lt;&lt; SENHA DO POSTGRES </pre>
<p>Verifique se o mesmo foi criado.</p>
<pre class="remontti-code">$ psql -l 
Senha para usuário postgres: 
                               Lista dos bancos de dados
   Nome    |   Dono   | Codificação |   Collate   |    Ctype    | Privilégios de acesso 
-----------+----------+-------------+-------------+-------------+-----------------------
 meubd     | teste    | UTF8        | pt_BR.UTF-8 | pt_BR.UTF-8 | 
....
....</pre>
<p>Acessamos agora o bd teste.</p>
<pre class="remontti-code">$ psql -U teste -d meubd
Senha do usuário teste: 
psql (15.3 (Debian 15.3-0+deb12u1))
Digite &quot;help&quot; para ajuda.

meubd=&gt;</pre>
<p>Vamos fazer uma "brincadeira" só para testar, criaremos uma tabela e inseriremos dados nela.</p>
<pre class="remontti-code">meubd=&gt; CREATE TABLE doacao ( id int,nome text, valor text );
meubd=&gt; INSERT INTO doacao (id,nome,valor) values (1,&#039;Rudimar Remontti&#039;,&#039;R$ 5,00&#039;); 
meubd=&gt; SELECT * FROM doacao;

 id |       nome       |  valor  
----+------------------+---------
  1 | Rudimar Remontti | R$ 5,00

meubd=&gt; \q</pre>
<p>Se deseja remover o banco/usuário teste.</p>
<pre class="remontti-code">$ dropdb meubd
Senha: &lt;&lt; SENHA DO POSTGRES
$ dropuser teste
Senha: &lt;&lt; SENHA DO POSTGRES</pre>
<p>Volte para root</p>
<pre class="remontti-code">$ exit</pre>
<h3>PHP 8.2</h3>
<p>Incluirei algumas extensões do PHP que são normalmente utilizada também na instalação.</p>
<pre class="remontti-code">#  apt install --no-install-recommends \
 php php-{fpm,cli,mysql,pear,gd,gmp,bcmath,mbstring,curl,xml,zip,json,pgsql}</pre>
<p>Agora vamos fazer a "integração" do PHP com o NGINX. Moveremos o arquivo defaul.</p>
<pre class="remontti-code"># mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.original</pre>
<p>Crie um novo:</p>
<pre class="remontti-code"># vim /etc/nginx/sites-available/default</pre>
<p>Ajuste:</p>
<pre class="remontti-code">server {
    listen 80;
    listen [::]:80;

    root /var/www/html;
    index index.php index.html index.htm;

    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}</pre>
<p>Teste a configuração se não tem nada errado e restart os serviços:</p>
<pre class="remontti-code"># nginx -t
# systemctl restart nginx php8.2-fpm</pre>
<p>Vamos criar um arquivo em PHP para testa se nosso NGINX está interpretando o PHP.</p>
<pre class="remontti-code"># echo &#039;&lt;?php phpinfo();&#039; &gt;&gt; /var/www/html/teste.php</pre>
<p>Acesse em seu navegador <strong>http://IP-SERVIDOR/teste.php</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2.png" data-rel="lightbox-gallery-ExEvKb1q" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2-300x292.png" alt="" width="300" height="292" class="alignnone size-medium wp-image-7417" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2-300x292.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2-768x748.png 768w, https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2.png 950w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><br />
Servidor WEB com PHP está funcionando! </p>
<p>Exemplo para multiplos domínios/subdomínios </p>
<pre class="remontti-code"># vim /etc/nginx/sites-available/sub1.conf</pre>
<p>Neste ex: vou representar o <em>sub1.remontti.com.br</em></p>
<pre class="remontti-code">server {
    listen 80;
    listen [::]:80;

    root /var/www/sub1;
    index index.php index.html index.htm;

    add_header Strict-Transport-Security &quot;max-age=31536000; includeSubDomains&quot; always;

    server_name sub1.remontti.com.br;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}</pre>
<pre class="remontti-code"># vim /etc/nginx/sites-available/sub2e3.conf</pre>
<p>Neste ex: vou representar o <em>sub2.remontti.com.br</em> e <em>sub3.remontti.com.br</em></p>
<pre class="remontti-code">server {
    listen 80;
    listen [::]:80;

    root /var/www/sub2e3;
    index index.php index.html index.htm;

    server_name sub2.remontti.com.br sub3.remontti.com.br;

    add_header Strict-Transport-Security &quot;max-age=31536000; includeSubDomains&quot; always;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}</pre>
<p>Link os arquivos no diretório "/etc/nginx/sites-available"  que será carregado as novas configurações </p>
<pre class="remontti-code"># ln -s /etc/nginx/sites-available/sub1.conf /etc/nginx/sites-enabled/
# ln -s /etc/nginx/sites-available/sub2e3.conf /etc/nginx/sites-enabled/</pre>
<p>Crie os diretórios referente a cada <strong>server_name</strong>.</p>
<pre class="remontti-code"># mkdir /var/www/sub1
# mkdir /var/www/sub2e3
# echo &#039;&lt;?php echo &quot;Olá mundo do sub1!&quot;; ?&gt;&#039; &gt;&gt; /var/www/sub1/index.php
# echo &#039;&lt;?php echo &quot;Olá mundo do sub2e3!&quot;; ?&gt;&#039; &gt;&gt; /var/www/sub2e3/index.php
</pre>
<p>Verifique se não tem nenhum erro e reinicie o serviço:</p>
<pre class="remontti-code"># nginx -t
# systemctl restart nginx</pre>
<h3>:: Let's Encrypt ::</h3>
<p>Criando certificado grátis para seus sub/domínios.</p>
<pre class="remontti-code"># apt install certbot python3-certbot-nginx</pre>
<p>Para gerar o certificado use o comando:</p>
<pre class="remontti-code"># certbot</pre>
<p>Não esqueça de colocar no seu cron para ele renovar o certificado, pois a cada 90 ele expira. Neste exemplo todo dia primeiro tento renovar.</p>
<pre class="remontti-code"># certbot -q renew</pre>
<p>Para testar acesse: <a href="https://www.cdn77.com/tls-test/" rel="noopener" target="_blank">https://www.cdn77.com/tls-test/</a><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste.png" data-rel="lightbox-gallery-ExEvKb1q" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-300x182.png" alt="" width="300" height="182" class="alignnone size-medium wp-image-6158" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-300x182.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-1024x620.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-768x465.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste.png 1099w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Gostou?</p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a><br />
Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p><strong>Fontes:</strong> <a href="https://docs.nginx.com/" rel="noopener" target="_blank">https://docs.nginx.com/</a><br />
<a href="https://docs.nginx.com/nginx/admin-guide/web-server/web-server/" rel="noopener" target="_blank">https://docs.nginx.com/nginx/admin-guide/web-server/web-server/</a></p>
<p>O post <a href="https://blog.remontti.com.br/7413">Servidor WEB NGINX + PHP 8.2 + PostgreSQL +Let’s Encrypt  Debian 12 Bookworm (LNP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/7413/feed</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>Servidor WEB NGINX + PHP 8.2 + MariaDB + phpMyAdmin + Let’s Encrypt Debian 12 Bookworm (LNMP)</title>
		<link>https://blog.remontti.com.br/7460</link>
					<comments>https://blog.remontti.com.br/7460#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Wed, 14 Jun 2023 15:17:45 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bookworm]]></category>
		<category><![CDATA[Debian 12]]></category>
		<category><![CDATA[Let’s Encrypt]]></category>
		<category><![CDATA[LNMP]]></category>
		<category><![CDATA[MariaDB]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpMyAdmin]]></category>
		<category><![CDATA[Servidor WEB]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=7460</guid>

					<description><![CDATA[<p>Neste tutorial vamos configurar um servidor web com NGINX (lê-se “engine x”), o concorrente do Apache. NGINX é um servidor web (HTTP e IMAP/POP3/Proxy) rápido, leve e com inúmeras possibilidades de configuração para melhor&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/7460">Servidor WEB NGINX + PHP 8.2 + MariaDB + phpMyAdmin + Let’s Encrypt Debian 12 Bookworm (LNMP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><center><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian12.jpg" alt="" width="720" height="340" class="alignnone size-full wp-image-7476" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian12.jpg 720w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian12-300x142.jpg 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian12-520x245.jpg 520w" sizes="auto, (max-width: 720px) 100vw, 720px" /></center></p>
<p>Neste tutorial vamos configurar um servidor web com NGINX (lê-se “engine x”), o concorrente do Apache. NGINX é um servidor web (HTTP e IMAP/POP3/Proxy) rápido, leve e com inúmeras possibilidades de configuração para melhor performance. O Apache, sem dúvidas, é o servidor web mais popular. No entanto, o NGINX a cada ano ganha mais popularidade e está sendo a preferência dos novos projetos.</p>
<p>Distribuição utilizada: <strong><a href="https://blog.remontti.com.br/7236" rel="noopener noreferrer" target="_blank">Debian 12 Stretch / Instalação Limpa</a></strong></p>
<h3>NGINX</h3>
<p><a href="https://www.nginx.com" rel="noopener" target="_blank">https://www.nginx.com</a><br />
Vamos instalar-lo e remover a assinatura para que não vejam a versão do mesmo (Boas praticas)</p>
<pre class="remontti-code"># apt install nginx
# sed -i &#039;s/# server_tokens/server_tokens/&#039; /etc/nginx/nginx.conf
# systemctl restart nginx</pre>
<p>Acesse agora em seu navegador http://IP-SERVIDOR/<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1.png" alt="" width="1100" height="310" class="alignnone size-full wp-image-5467" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1.png 1100w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1-300x85.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1-1024x289.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx1-768x216.png 768w" sizes="auto, (max-width: 1100px) 100vw, 1100px" /></p>
<p>Pronto nosso NGINX está rodando! </p>
<h3>MARIADB</h3>
<p>MariaDB para quem ainda não sabe é um fork do MySQL, criado pelo próprio fundador do projeto MySQL após sua aquisição pela Oracle.</p>
<pre class="remontti-code"># apt install mariadb-server mariadb-client</pre>
<p>Ao final do tutorial iremos colocar uma senha para o usuario root do mariadb. Não iremos fazer isso agora para não dar problema na instalação do phpmyadmin.</p>
<h3>PHP 8.2</h3>
<p>Incluirei algumas extensões do PHP que são normalmente utilizada também na instalação.</p>
<pre class="remontti-code"># apt install --no-install-recommends \
 php php-{fpm,cli,mysql,pear,gd,gmp,bcmath,mbstring,curl,xml,zip,json,pgsql}</pre>
<p>Agora vamos fazer a &#8220;integração&#8221; do PHP com o NGINX. Moveremos o arquivo defaul.</p>
<pre class="remontti-code"># mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.original</pre>
<p>Crie um novo:</p>
<pre class="remontti-code"># vim /etc/nginx/sites-available/default</pre>
<p>Ajuste:</p>
<pre class="remontti-code">server {
    listen 80;
    listen [::]:80;

    root /var/www/html;
    index index.php index.html index.htm;

    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}</pre>
<p>Teste a configuração se não tem nada errado e restart os serviços:</p>
<pre class="remontti-code"># nginx -t
# systemctl restart nginx php8.2-fpm</pre>
<p>Vamos criar um arquivo em PHP para testa se nosso NGINX está interpretando o PHP.</p>
<pre class="remontti-code"># echo &#039;&lt;?php phpinfo();&#039; &gt;&gt; /var/www/html/teste.php</pre>
<p>Acesse em seu navegador http://IP-SERVIDOR/teste.php<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2.png" alt="" width="950" height="925" class="alignnone size-full wp-image-7417" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2.png 950w, https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2-300x292.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2-768x748.png 768w" sizes="auto, (max-width: 950px) 100vw, 950px" /><br />
Servidor WEB com PHP está funcionando! </p>
<p>Exemplo para múltiplos domínios/subdomínios </p>
<pre class="remontti-code"># vim /etc/nginx/sites-available/sub1.conf</pre>
<p>Neste ex: vou representar o <em>sub1.remontti.com.br</em></p>
<pre class="remontti-code">server {
    listen 80;
    listen [::]:80;

    root /var/www/sub1;
    index index.php index.html index.htm;

    server_name sub1.remontti.com.br;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}</pre>
<pre class="remontti-code"># vim /etc/nginx/sites-available/sub2e3.conf</pre>
<p>Neste ex: vou representar o <em>sub2.remontti.com.br</em> e <em>sub3.remontti.com.br</em></p>
<pre class="remontti-code">server {
    listen 80;
    listen [::]:80;

    root /var/www/sub2e3;
    index index.php index.html index.htm;

    server_name sub2.remontti.com.br sub3.remontti.com.br;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}</pre>
<p>Link os arquivos no diretório &#8220;/etc/nginx/sites-available&#8221;  que será carregado as novas configurações </p>
<pre class="remontti-code"># ln -s /etc/nginx/sites-available/sub1.conf /etc/nginx/sites-enabled/
# ln -s /etc/nginx/sites-available/sub2e3.conf /etc/nginx/sites-enabled/</pre>
<p>Crie os diretórios referente a cada <strong>server_name</strong>.</p>
<pre class="remontti-code"># mkdir /var/www/sub1
# mkdir /var/www/sub2e3
# echo &#039;&lt;?php echo &quot;Olá mundo do sub1!&quot;; ?&gt;&#039; &gt;&gt; /var/www/sub1/index.php
# echo &#039;&lt;?php echo &quot;Olá mundo do sub2e3!&quot;; ?&gt;&#039; &gt;&gt; /var/www/sub2e3/index.php
</pre>
<p>Verifique se não tem nenhum erro e restart:</p>
<pre class="remontti-code"># nginx -t
# systemctl restart nginx</pre>
<h3>phpMyAdmin</h3>
<pre class="remontti-code"># apt install phpmyadmin -y </pre>
<p>Não selecione nenhum, apenas <strong>OK</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12.png" alt="" width="1239" height="424" class="alignnone size-full wp-image-7467" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12.png 1239w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12-300x103.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12-1024x350.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12-768x263.png 768w" sizes="auto, (max-width: 1239px) 100vw, 1239px" /></p>
<p>Responda <strong>Sim</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12_nginx.png" alt="" width="1249" height="370" class="alignnone size-full wp-image-7468" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12_nginx.png 1249w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12_nginx-300x89.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12_nginx-1024x303.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_debian12_nginx-768x228.png 768w" sizes="auto, (max-width: 1249px) 100vw, 1249px" /></p>
<p>Irá solicitar a senha para a base de dados <strong>phpmyadmin</strong>, informe sua <strong>senha e repita</strong>. </p>
<pre class="remontti-code"># vim /etc/nginx/sites-available/default</pre>
<p>Adicione as linhas destacadas:</p>
<pre class="remontti-code">server {
    listen 80;
    listen [::]:80;

    root /var/www/html;
    index index.php index.html index.htm;

    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }

    location ^~ /phpmyadmin {
        root /usr/share;
        try_files $uri $uri/ =404;
        #allow  192.168.87.0/24;
        #allow  2001:0db8::/32;
        #deny   all;
        #error_page  403   http://www.remontti.com.br;
        location ~ .php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        }
    }

}</pre>
<p>Se deseja tonar o phpmyadmin acessivel apenas de alguns endereços IPs basta descomentar as linhas, e incluir seus prefixos. O error_page é para que quando a o acessante levar um proibido seja direcionado para um site.</p>
<pre class="remontti-code">allow  192.168.87.0/24;
allow  2001:0db8::/32;
deny   all;
error_page  403   http://www.remontti.com.br;</pre>
<p>Verifique se não tem nenhum erro e restart:</p>
<pre class="remontti-code"># nginx -t
# systemctl restart nginx</pre>
<p>Acesse agora <strong>http://SERVIDOR/phpmyadmin</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login.png" alt="" width="1523" height="556" class="alignnone size-full wp-image-7471" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login.png 1523w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login-300x110.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login-1024x374.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login-768x280.png 768w" sizes="auto, (max-width: 1523px) 100vw, 1523px" /></p>
<h4>Definindo senha para o root do mariaDB</h4>
<p>Por segurança vamos setar uma senha do usuario root do MariaDB</p>
<pre class="remontti-code"># mariadb -u root</pre>
<p>Para aumentar a seguraçã vamos definir uma senha para o usuário root do MariDB, não esqueça de alterar ALTERE_3ST4_SENHA pela sua senha. Dica acesse<a href="https://senhasegura.remontti.com.br/" rel="noopener" target="_blank"> https://senhasegura.remontti.com.br/</a> e gere uma!</p>
<pre class="remontti-code">USE mysql;
ALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;ALTERE_3ST4_SENHA&#039;;
FLUSH PRIVILEGES;
EXIT;
</pre>
<p>Apague seus rastros, em /root/.mysql_history temos um histórico com todos os comandos dado no terminal do MariaDB, então não é legal deixar lá em texto puro a senha que setamos!</p>
<pre class="remontti-code"># &gt; /root/.mysql_history</pre>
<p>Agora quando for acessar o mariadb será necessário informar a senha juntamente da opção <strong>-p</strong>.</p>
<pre class="remontti-code"># mariadb -u root -p</pre>
<pre class="remontti-code-plain">Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 46
Server version: 10.11.3-MariaDB-1 Debian 12

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type &#039;help;&#039; or &#039;\h&#039; for help. Type &#039;\c&#039; to clear the current input statement.

MariaDB [(none)]&gt; exit;
Bye
</pre>
<h3>Let&#8217;s Encrypt</h3>
<p>Criando certificado grátis para seus sub/domínios.</p>
<pre class="remontti-code"># apt install certbot python3-certbot-nginx</pre>
<p>Para gerar o certificado use o comando:</p>
<pre class="remontti-code"># certbot</pre>
<p>Não esqueça de colocar no seu cron para ele renovar o certificado, pois a cada 90 ele expira. Neste exemplo todo dia primeiro tento renovar.</p>
<pre class="remontti-code"># certbot -q renew</pre>
<p>Para testar acesse: <a href="https://www.cdn77.com/tls-test/" rel="noopener" target="_blank">https://www.cdn77.com/tls-test/</a><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste.png" data-rel="lightbox-gallery-79ZboVXc" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-300x182.png" alt="" width="300" height="182" class="alignnone size-medium wp-image-6158" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-300x182.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-1024x620.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-768x465.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste.png 1099w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Gostou?</p>
<p>Gostou?</p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a><br />
Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p><strong>Fontes:</strong> <a href="https://docs.nginx.com/" rel="noopener" target="_blank">https://docs.nginx.com/</a><br />
<a href="https://docs.nginx.com/nginx/admin-guide/web-server/web-server/" rel="noopener" target="_blank">https://docs.nginx.com/nginx/admin-guide/web-server/web-server/</a></p>
<p>O post <a href="https://blog.remontti.com.br/7460">Servidor WEB NGINX + PHP 8.2 + MariaDB + phpMyAdmin + Let’s Encrypt Debian 12 Bookworm (LNMP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/7460/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Servidor WEB Apache2 + PHP 8.2 + MariaDB +Let’s Encrypt Debian 12 Bookworm (LAMP)</title>
		<link>https://blog.remontti.com.br/7496</link>
					<comments>https://blog.remontti.com.br/7496#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Sun, 11 Jun 2023 16:40:46 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Administração de banco de dados.]]></category>
		<category><![CDATA[Ambiente de servidor]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[Autenticação de servidor]]></category>
		<category><![CDATA[bookworm]]></category>
		<category><![CDATA[Certificado SSL]]></category>
		<category><![CDATA[Configuração do Apache]]></category>
		<category><![CDATA[Configuração do servidor]]></category>
		<category><![CDATA[Debian 12]]></category>
		<category><![CDATA[Desenvolvimento web]]></category>
		<category><![CDATA[Gerenciamento de banco de dados]]></category>
		<category><![CDATA[Hospedagem web]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[Let’s Encrypt]]></category>
		<category><![CDATA[MariaDB]]></category>
		<category><![CDATA[PHP 8.2]]></category>
		<category><![CDATA[Proteção de dados]]></category>
		<category><![CDATA[Segurança na web]]></category>
		<category><![CDATA[Servidor WEB]]></category>
		<category><![CDATA[Versão do PHP]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=7496</guid>

					<description><![CDATA[<p>Distribuição utilizada: &#8211; Debian 12 Bookworm / Instalação Limpa Acesse seu bash e vire root com o comando su &#8211; para evitar comandos &#8220;que não existem&#8221;, e antes de mais nada tenha seu repositório&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/7496">Servidor WEB Apache2 + PHP 8.2 + MariaDB +Let’s Encrypt Debian 12 Bookworm (LAMP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><center><a href="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12.jpg" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12.jpg" alt="" width="720" height="340" class="alignnone size-full wp-image-7503" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12.jpg 720w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12-300x142.jpg 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12-520x245.jpg 520w" sizes="auto, (max-width: 720px) 100vw, 720px" /></a></center></p>
<p>Distribuição utilizada:<br />
&#8211; <strong><a href="https://blog.remontti.com.br/7236" rel="noopener noreferrer" target="_blank">Debian 12 Bookworm / Instalação Limpa</a></strong></p>
<p>Acesse seu bash e vire root com o comando su &#8211; para evitar comandos &#8220;que não existem&#8221;, e antes de mais nada tenha seu repositório atualizado.</p>
<pre class="remontti-code"># su -
# apt update
# apt upgrade</pre>
<h3>:: Instalação do Apache2 ::</h3>
<pre class="remontti-code"># apt install apache2 apache2-utils -y</pre>
<p>Após a instação, habilitamos o <strong>mod_rewrite</strong> do Apache que é muito utilizado. Este é um módulo que utiliza um mecanismo baseado em regras de reescrita. (phpipa, wordpress todos usam), e o <strong>mod_headers</strong> Este módulo fornece diretivas para controlar e modificar os cabeçalhos de solicitação e resposta HTTP. Comando para habilita-lo:</p>
<pre class="remontti-code"># a2enmod rewrite ; a2enmod headers</pre>
<p>A página que vimos ao abri o ip do nosso servidor no navegador fica no diretório /var/www/html, isso está sendo informado no arquivo default do apache que fica em /etc/apache2/sites-enabled/000-default.conf, e para que nosso mod_rewrite e headers funcione corretamente será necessário adicionar alguma linhas.<br />
O HTTP Strict Transport Security ou HSTS (RFC 6797) é um novo padrão de segurança SSL aprovado recentemente pelo IETF. Ele traz diversas melhorias para o SSL como forçar a utilização do HTTPS impedindo que sites sejam acessados usando o protocolo HTTP ou que partes do código de um site que está usando HTTPS seja executado em servidores usando o HTTP entre outras.</p>
<pre class="remontti-code"># vim /etc/apache2/sites-enabled/000-default.conf</pre>
<p>Adicione abaixo de &#8220;DocumentRoot /var/www/html&#8221; o seguinte:</p>
<pre class="remontti-code">
	Header always set Strict-Transport-Security &quot;max-age=63072000; includeSubDomains&quot;

	&lt;Directory /var/www/html/&gt;
    		Options FollowSymLinks
    		AllowOverride All
	&lt;/Directory&gt;</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2021/10/apache_HSTS.png" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/apache_HSTS-300x281.png" alt="" width="300" height="281" class="alignnone size-medium wp-image-6154" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/apache_HSTS-300x281.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/apache_HSTS-768x720.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/10/apache_HSTS.png 1024w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Para você aprender mais como o apache funciona recomendo: <strong><a href="https://blog.remontti.com.br/3464" rel="noopener" target="_blank">Como ter diversos sub/domínios no mesmo servidor</a></strong></p>
<p>Por segurança remova a assinatura do apache e reinicie o apache2 para que tenha efeito as nossas alterações.</p>
<pre class="remontti-code"># sed -i &#039;s/ServerTokens OS/ServerTokens Prod/&#039; /etc/apache2/conf-available/security.conf
# sed -i &#039;s/ServerSignature On/ServerSignature Off/&#039; /etc/apache2/conf-available/security.conf
# systemctl restart apache2</pre>
<p><strong>http://[SERVER_IP]</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2021/10/apache2.png" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/apache2-150x150.png" alt="" width="150" height="150" class="alignnone size-thumbnail wp-image-5897" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/apache2-150x150.png 150w, https://blog.remontti.com.br/wp-content/uploads/2021/10/apache2-80x80.png 80w, https://blog.remontti.com.br/wp-content/uploads/2021/10/apache2-320x320.png 320w" sizes="auto, (max-width: 150px) 100vw, 150px" /></a></p>
<h3>:: Instalação do PHP 8.2 ::</h3>
<p>Para instalação do PHP vou incluir algumas extensões que são as mais utilizada, mas seu preferir você pode optar em não instalar, as necessárias são libapache2-mod-php php php-mysql php-cli.</p>
<pre class="remontti-code"># apt install libapache2-mod-php php php-mysql php-cli php-pear php-gmp php-gd php-bcmath php-mbstring php-curl php-xml php-zip -y</pre>
<p>É necessário reiniciar o apache para que o php tenha efeito.</p>
<pre class="remontti-code"># systemctl restart apache2</pre>
<p>Consultado informações de versão:</p>
<pre class="remontti-code"># php --version</pre>
<pre class="remontti-code-plain">
PHP 8.2.7 (cli) (built: Jun  9 2023 19:37:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies
</pre>
<p>Você pode criar um arquivo php com a função <a href="https://php.net/manual/pt_BR/function.phpinfo.php" rel="noopener noreferrer" target="_blank">phpinfo()</a> para mostrar todas as informações.</p>
<pre class="remontti-code"># echo &#039;&lt;?php phpinfo(); ?&gt;&#039; &gt; /var/www/html/phpinfo.php</pre>
<p><strong>http://[SERVER_IP]/phpinfo.php</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2.png" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2-300x292.png" alt="" width="300" height="292" class="alignnone size-medium wp-image-7417" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2-300x292.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2-768x748.png 768w, https://blog.remontti.com.br/wp-content/uploads/2023/06/debian12_php8.2.png 950w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<h3>:: Instalação do MariaDB 10.11 + phpMyAdmin 5 ::</h3>
<pre class="remontti-code"># apt install mariadb-server mariadb-client phpmyadmin</pre>
<p>Por padrão o pacote MaraiDB no Debian usa unix_socket para autenticar o login do usuário, o que basicamente significa que você pode usar o nome de usuário e a senha do sistema operacional para efetuar login no console do MariaDB. Assim, você pode logar diretamente sem fornecer a senha root do MariaDB. Mais a frente vou ensinar como definir uma senha, não farei agora pois se você alterar nesse momento ao instalar o phpMyAdmin terá um erro.</p>
<p>Selecione <strong>Apache2</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_1.png" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_1.png" alt="" width="1256" height="408" class="alignnone size-full wp-image-7499" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_1.png 1256w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_1-300x97.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_1-1024x333.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_1-768x249.png 768w" sizes="auto, (max-width: 1256px) 100vw, 1256px" /></a></p>
<p>Responda <strong>Sim</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_2.png" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_2.png" alt="" width="1257" height="513" class="alignnone size-full wp-image-7500" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_2.png 1257w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_2-300x122.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_2-1024x418.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_2-768x313.png 768w" sizes="auto, (max-width: 1257px) 100vw, 1257px" /></a></p>
<p><strong>Informe a senha</strong> para o banco de dados do phpmyadmin. <a href="http://senhasegura.remontti.com.br/" rel="noopener" target="_blank">http://senhasegura.remontti.com.br/</a><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_3.png" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_3.png" alt="" width="1261" height="410" class="alignnone size-full wp-image-7501" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_3.png 1261w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_3-300x98.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_3-1024x333.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_3-768x250.png 768w" sizes="auto, (max-width: 1261px) 100vw, 1261px" /></a></p>
<p>Repita a senha<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_4.png" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_4.png" alt="" width="1264" height="437" class="alignnone size-full wp-image-7502" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_4.png 1264w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_4-300x104.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_4-1024x354.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/06/lamp_debian_12_4-768x266.png 768w" sizes="auto, (max-width: 1264px) 100vw, 1264px" /></a></p>
<p>Para acessar o phpmyadmin:<strong>http://[SERVER_IP]/phpmyadmin/</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login.png" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login.png" alt="" width="1523" height="556" class="alignnone size-full wp-image-7471" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login.png 1523w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login-300x110.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login-1024x374.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/06/phpmyadmin_login-768x280.png 768w" sizes="auto, (max-width: 1523px) 100vw, 1523px" /></a></p>
<p>Por segurança eu sempre fecho o acesso ao phpmyadmin para os IPs da administração, assim evito que uma possível vulnerabilidade venha me afetar. Para isso edite:</p>
<pre class="remontti-code"># vim /etc/phpmyadmin/apache.conf</pre>
<p>Se deseja deixar o atalho para o phpmyadmin restrito apenas aos seus IP de gerencia faça da seguinte forma. Lembre-se de alterar os IPs 200.200.200.0/26 2001:db8:cafe:d0ce::/64 para os seus.</p>
<pre class="remontti-code"># phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin

&lt;Directory /usr/share/phpmyadmin&gt;
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php

    # Restrito aos IPs
    AllowOverride All
    Require ip 127.0.0.1 ::1 200.200.200.0/26 2001:db8:cafe:d0ce::/64

    # limit libapache2-mod-php to files and directories necessary by pma
    &lt;IfModule mod_php7.c&gt;
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/usr/share/doc/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/:/usr/share/javascript/
    &lt;/IfModule&gt;

    # PHP 8+
    &lt;IfModule mod_php.c&gt;
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/usr/share/doc/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/:/usr/share/javascript/
    &lt;/IfModule&gt;

&lt;/Directory&gt;

# Disallow web access to directories that don&#039;t need it
&lt;Directory /usr/share/phpmyadmin/templates&gt;
    Require all denied
&lt;/Directory&gt;
&lt;Directory /usr/share/phpmyadmin/libraries&gt;
    Require all denied
&lt;/Directory&gt;</pre>
<p>Reinicie o Apache.</p>
<pre class="remontti-code"> systemctl restart apache2</pre>
<h4>:: Definindo senha para o root do mariaDB ::</h4>
<p>Para aumentar a seguraçã vamos definir uma senha para o usuário root do MariDB, não esqueça de alterar <strong>ALTERE_3ST4_SENHA</strong> pela sua senha.</p>
<pre class="remontti-code"># mariadb -u root</pre>
<pre class="remontti-code">USE mysql;
ALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;ALTERE_3ST4_SENHA&#039;;
FLUSH PRIVILEGES;
EXIT;</pre>
<p>Apague seus rastros, em /root/.mysql_history temos um histórico com todos os comandos dado no terminal do MariaDB, então não é legal deixar lá em texto puro a senha que setamos!</p>
<pre class="remontti-code"># &gt; /root/.mysql_history</pre>
<h3>:: Let&#8217;s Encrypt ::</h3>
<p>Criando certificado grátis para seus sub/domínios.</p>
<pre class="remontti-code"># apt install certbot python3-certbot-apache</pre>
<p>Para gerar o certificado use o comando:</p>
<pre class="remontti-code"># certbot</pre>
<p>Não esqueça de colocar no seu cron para ele renovar o certificado, pois a cada 90 ele expira. Neste exemplo todo dia primeiro tento renovar.</p>
<pre class="remontti-code"># certbot -q renew</pre>
<p>Para testar acesse: <a href="https://www.cdn77.com/tls-test/" rel="noopener" target="_blank">https://www.cdn77.com/tls-test/</a><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste.png" data-rel="lightbox-gallery-uZ7zaEFk" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-300x182.png" alt="" width="300" height="182" class="alignnone size-medium wp-image-6158" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-300x182.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-1024x620.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-768x465.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste.png 1099w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><br />
Gostou?</p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<p>O post <a href="https://blog.remontti.com.br/7496">Servidor WEB Apache2 + PHP 8.2 + MariaDB +Let’s Encrypt Debian 12 Bookworm (LAMP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/7496/feed</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
		<item>
		<title>Criando certificado grátis com  Let’s Encrypt para o Apache  no Debian 10</title>
		<link>https://blog.remontti.com.br/3548</link>
					<comments>https://blog.remontti.com.br/3548#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Tue, 17 Sep 2019 19:19:05 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[certificado]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Domínio]]></category>
		<category><![CDATA[Let’s Encrypt]]></category>
		<category><![CDATA[letsencrypt]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php7]]></category>
		<category><![CDATA[Virtual]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=3548</guid>

					<description><![CDATA[<p>Let’s Encrypt entrega certificados digitais que permite HTTPS (SSL/TLS) para sites gratuitamente, de maneira fácil. É um serviço fornecido pelo Internet Security Research Group Requisitos: Debian 10 Stretch / Instalação Limpa (Funciona no Deb9)&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/3548">Criando certificado grátis com  Let’s Encrypt para o Apache  no Debian 10</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://letsencrypt.org" rel="noopener noreferrer" target="_blank">Let’s Encrypt</a> entrega certificados digitais que permite HTTPS (SSL/TLS) para sites gratuitamente, de maneira fácil. É um serviço fornecido pelo Internet Security Research Group</p>
<p>Requisitos:<br />
<a href="https://blog.remontti.com.br/2966" rel="noopener noreferrer" target="_blank">Debian 10 Stretch / Instalação Limpa</a><br />
<em>(Funciona no Deb9)</em></p>
<p>Let’s Encrypt apresentado, vamos a instalação.</p>
<pre class="remontti-code"># su - 
# apt update
# apt upgrade
# apt install letsencrypt python-certbot-apache</pre>
<p>Para nosso exemplo crie um domínio virtual nas configurações do apache.<br />
Lei mais em: <a href="https://blog.remontti.com.br/3464" rel="noopener noreferrer" target="_blank">Como ter diversos sub/domínios no mesmo servidor? (Domínios virtuais com Apache2)</a></p>
<p>Lembre de em seu servidor DNS ter configurado do host (no meu ex.: &#8220;blog&#8221;) apontando para o IP de seu servidor.</p>
<p>Criamos o arquivo que vai representar o host blog. Vou utilizar como base o diretório /var/www/blog que vamos criar em seguida.</p>
<pre class="remontti-code"># vim /etc/apache2/sites-available/cloud.conf</pre>
<pre class="remontti-code">&lt;virtualhost *:80&gt;
        ServerName blog.remontti.com.br
        ServerAdmin noc@remontti.com.br
 
        DocumentRoot /var/www/blog 
 
        &lt;directory /var/www/blog/ &gt;
                Options FollowSymLinks
                AllowOverride All
        &lt;/directory&gt; 
 
        LogLevel warn 
        ErrorLog ${APACHE_LOG_DIR}/error_cloud.log
        CustomLog ${APACHE_LOG_DIR}/access_cloud.log combined
&lt;/virtualhost&gt;</pre>
<p>Por segurança recomendo remover a assinatura do servidor, evitando os &#8220;espertinhos&#8221;</p>
<pre class="remontti-code"># sed -i &#039;s/ServerTokens OS/ServerTokens Prod/&#039; /etc/apache2/conf-available/security.conf
# sed -i &#039;s/ServerSignature On/ServerSignature Off/&#039; /etc/apache2/conf-available/security.conf</pre>
<p>Crie o diretório e uma uma index só para representar nosso &#8220;olá mundo&#8221;.</p>
<pre class="remontti-code"># mkdir /var/www/blog/
#  echo &#039;&lt;h1&gt;Hello world!&lt;/h1&gt;&#039; &gt; /var/www/blog/index.html</pre>
<p>Antes de gerar o certificado pare &#8220;blog.remontti.com.br&#8221;.</p>
<pre class="remontti-code"># systemctl stop apache2</pre>
<pre class="remontti-code"># letsencrypt --authenticator standalone --installer apache -d blog.remontti.com.br</pre>
<p>Responda como abaixo:</p>
<pre class="remontti-code">Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter &#039;c&#039; to
cancel): seu@email.com.br
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let&#039;s Encrypt project and the non-profit
organization that develops Certbot? We&#039;d like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for blog.remontti.com.br
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/blog-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/blog-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/blog-le-ssl.conf
 
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you&#039;re confident your site works on HTTPS. You can undo this
change by editing your web server&#039;s configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press &#039;c&#039; to cancel): 2
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://blog.remontti.com.br
 
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=blog.remontti.com.br
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/blog.remontti.com.br/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/blog.remontti.com.br/privkey.pem
   Your cert will expire on 2019-10-24. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the &quot;certonly&quot; option. To non-interactively renew *all* of
   your certificates, run &quot;certbot renew&quot;
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:
 
   Donating to ISRG / Lets Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le</pre>
<p>Já pode acessar no navegador o domínio com HTTPS &#8220;blog.remontti.com.br&#8221;</p>
<p>Dica, se desejar desativar o TLS1.0 e TLS1.1 após criar um certificado um arquivo é criado /etc/letsencrypt/options-ssl-apache.conf, então edite e inclua no SSLProtocol TLSv1 -TLSv1.1</p>
<pre class="remontti-code"># vim /etc/letsencrypt/options-ssl-apache.conf</pre>
<p>Ficando</p>
<pre class="remontti-code">#SSLProtocol            all -SSLv2 -SSLv3
SSLProtocol             all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1</pre>
<p>Reinicie o Apache:</p>
<pre class="remontti-code"># systemctl restart apache2</pre>
<p>Para testar acesse: <a href="https://www.cdn77.com/tls-test/" rel="noopener" target="_blank">https://www.cdn77.com/tls-test/</a><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste.png" data-rel="lightbox-gallery-Jw9zVEBz" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-300x182.png" alt="" width="300" height="182" class="alignnone size-medium wp-image-6158" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-300x182.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-1024x620.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste-768x465.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/10/tls_teste.png 1099w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Para renovar automaticamente crie um script e adicione ao cron.</p>
<pre class="remontti-code"># vim  /etc/renova-cert.sh</pre>
<p>Adicione</p>
<pre class="remontti-code">#!/bin/bash
/usr/bin/systemctl stop apache2
/usr/bin/certbot -q renew
/usr/bin/systemctl start apache2</pre>
<p>Damos permissão para executar</p>
<pre class="remontti-code"># chmod +x /etc/renova-cert.sh</pre>
<p>Adicionamos ao Cron para toda meia noite renovar</p>
<pre class="remontti-code"># echo &#039;00 00   * * *   root    /etc/renova-cert.sh&#039; &gt;&gt; /etc/crontab
# systemctl restart cron</pre>
<p>Agora você já tem seu domínio com certificado! Esse certificado pode ser utilizado para outro serviços.</p>
<p><center><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></center></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<p>O post <a href="https://blog.remontti.com.br/3548">Criando certificado grátis com  Let’s Encrypt para o Apache  no Debian 10</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/3548/feed</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
			</item>
	</channel>
</rss>
