<?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 phpMyAdmin - Remontti</title>
	<atom:link href="https://blog.remontti.com.br/tag/phpmyadmin/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.remontti.com.br/tag/phpmyadmin</link>
	<description>rudimar@remontti</description>
	<lastBuildDate>Wed, 14 Jun 2023 21:18:29 +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 phpMyAdmin - Remontti</title>
	<link>https://blog.remontti.com.br/tag/phpmyadmin</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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 fetchpriority="high" 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="(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 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" /></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 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="(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-Xd74MtRj" 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>Passo-a-passo como criar um servidor WEB Apache + PHP + MariaDB + phpMyAdmin + Let&#8217;s Encrypt no Debian 11 bullseye &#8220;LAMP&#8221;</title>
		<link>https://blog.remontti.com.br/5893</link>
					<comments>https://blog.remontti.com.br/5893#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Wed, 20 Oct 2021 15:01:11 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Bullseye]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[debian 11]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[php7.4]]></category>
		<category><![CDATA[phpMyAdmin]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=5893</guid>

					<description><![CDATA[<p>Distribuição utilizada: Debian 11 Bullseye / 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 atualizado.&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/5893">Passo-a-passo como criar um servidor WEB Apache + PHP + MariaDB + phpMyAdmin + Let&#8217;s Encrypt no Debian 11 bullseye &#8220;LAMP&#8221;</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/debian_11_lamp.png" alt="" width="790" height="374" class="alignnone size-full wp-image-5909" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/debian_11_lamp.png 790w, https://blog.remontti.com.br/wp-content/uploads/2021/10/debian_11_lamp-300x142.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/debian_11_lamp-768x364.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/10/debian_11_lamp-520x245.png 520w, https://blog.remontti.com.br/wp-content/uploads/2021/10/debian_11_lamp-720x340.png 720w" sizes="auto, (max-width: 790px) 100vw, 790px" /><br />
Distribuição utilizada: <strong><a href="https://blog.remontti.com.br/5792" rel="noopener noreferrer" target="_blank">Debian 11 Bullseye / 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 Apache ::</h3>
<pre class="remontti-code"># apt install apache2 apache2-utils</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-IWVQc9J6" 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-IWVQc9J6" 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 MariaDB 10.5 ::</h3>
<pre class="remontti-code"># apt install mariadb-server mariadb-client </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.<br />
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>
<h3>:: Instalação do PHP 7.4 ::</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</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 7.4.21 (cli) (built: Jul  2 2021 03:59:48) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, 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/2021/10/php7.png" data-rel="lightbox-gallery-IWVQc9J6" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/php7-150x150.png" alt="" width="150" height="150" class="alignnone size-thumbnail wp-image-5896" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/php7-150x150.png 150w, https://blog.remontti.com.br/wp-content/uploads/2021/10/php7-80x80.png 80w, https://blog.remontti.com.br/wp-content/uploads/2021/10/php7-320x320.png 320w" sizes="auto, (max-width: 150px) 100vw, 150px" /></a></p>
<h3>:: phpMyAdmin ::</h3>
<p>Adivinha quem voltou para o repositório? Sim! phpmyadmin está de volta!</p>
<pre class="remontti-code"># apt install phpmyadmin</pre>
<p>Selecione <strong>Apache2</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_1.png" alt="" width="1047" height="299" class="alignnone size-full wp-image-5899" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_1.png 1047w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_1-300x86.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_1-1024x292.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_1-768x219.png 768w" sizes="auto, (max-width: 1047px) 100vw, 1047px" /></p>
<p><strong>Sim</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_2.png" alt="" width="1648" height="363" class="alignnone size-full wp-image-5900" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_2.png 1648w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_2-300x66.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_2-1024x226.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_2-768x169.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_2-1536x338.png 1536w" sizes="auto, (max-width: 1648px) 100vw, 1648px" /></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></p>
<p>Aguarde finalizar&#8230; <font color="blue"><strong>Se você é um menino que seguiu a risca não vai ter o erro seguinte, então pode pular esta parte.</strong></font></p>
<p><font color="red"><strong>POSSÍVEL ERRO!</strong><br />
Este erro acontece quando o usuário root do mariaDB está com senha. Caso isso acontecer, selecione <strong>IGNORAR</strong> e siga os passos a baixo.</font><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_4.png" alt="" width="900" height="758" class="alignnone size-full wp-image-5902" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_4.png 900w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_4-300x253.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_4-768x647.png 768w" sizes="auto, (max-width: 900px) 100vw, 900px" /><br />
<font color="red">SE OCORRER O ERRO: SIGAS ESTES PASSOS PARA RESOLUÇÃO DO PROBLEMA ACIMA.</font><br />
<font color="red">Como o usuário root já tem senha e o script de instalção não sabe qual é a senha ele ele acaba apresentando esse erro ao criar o banco de dados bem como as tabelas do phpmyadmin, então vamos ter que criar na mão.<br />
Se você quiser certificar qual a senha digitou na instalação do phpmyadmin basta olhar o arquivo:</font></p>
<pre class="remontti-code"># vim /etc/phpmyadmin/config-db.php</pre>
<pre class="remontti-code-plain">$dbuser=&#039;phpmyadmin&#039;;
$dbpass=&#039;SUPER_SENHA&#039;;
$basepath=&#039;&#039;;
$dbname=&#039;phpmyadmin&#039;;
$dbserver=&#039;localhost&#039;;
$dbport=&#039;3306&#039;;
$dbtype=&#039;mysql&#039;;</pre>
<p><font color="red">Agora entre no mariadb e vamos criar o banco bem como o usuário phpmyadmin <em>(Use a mesma senha que está no config-db.php, ou altere também no config-db.php)</em></font></p>
<pre class="remontti-code"># mariadb -u root -p </pre>
<p><font color="red">Não esqueça de alterar a SUPER_SENHA.</font></p>
<pre class="remontti-code">CREATE DATABASE phpmyadmin;
CREATE USER &#039;phpmyadmin&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;SUPER_SENHA&#039;;
GRANT ALL PRIVILEGES ON phpmyadmin.* TO &#039;phpmyadmin&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;SUPER_SENHA&#039; WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;</pre>
<p>Importe as tabelas:</p>
<pre class="remontti-code"># mariadb -u root -p phpmyadmin &lt; /usr/share/phpmyadmin/sql/create_tables.sql</pre>
<p><font color="red">Pronto erro solucionado!</font></p>
<hr />
<p>Para acessar o phpmyadmin:<strong>http://[SERVER_IP]/phpmyadmin/</strong><br />
Caso seu phpmyadmin não abrir, certifique-se que o arquivo phpmyadmin.conf está lincado em /etc/apache2/conf-enabled/</p>
<pre class="remontti-code"># ls -lh /etc/apache2/conf-available/ | grep phpmyadmin.conf</pre>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_apache_debian_11.png" alt="" width="991" height="93" class="alignnone size-full wp-image-5999" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_apache_debian_11.png 991w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_apache_debian_11-300x28.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_apache_debian_11-768x72.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_apache_debian_11-980x93.png 980w" sizes="auto, (max-width: 991px) 100vw, 991px" /><br />
<font color="red">Caso não esteja execute o comando, e reinicie o apache:</font></p>
<pre class="remontti-code"># ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled/phpmyadmin.conf
# systemctl restart apache2</pre>
<p>Agora tente novamente.,</p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_5.png" data-rel="lightbox-gallery-IWVQc9J6" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_5-150x150.png" alt="" width="150" height="150" class="alignnone size-thumbnail wp-image-5905" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_5-150x150.png 150w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_5-80x80.png 80w, https://blog.remontti.com.br/wp-content/uploads/2021/10/phpmyadmin_debian_11_5-320x320.png 320w" sizes="auto, (max-width: 150px) 100vw, 150px" /></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

    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;

&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"># echo &gt; /root/.mysql_history</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-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>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-IWVQc9J6" 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/5893">Passo-a-passo como criar um servidor WEB Apache + PHP + MariaDB + phpMyAdmin + Let&#8217;s Encrypt no Debian 11 bullseye &#8220;LAMP&#8221;</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/5893/feed</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
		<item>
		<title>Servidor WEB NGINX + PHP + PostgreSQL + phpPgAdmin + Letsencrypt no Debian 10 Buster (LNPP)</title>
		<link>https://blog.remontti.com.br/5487</link>
					<comments>https://blog.remontti.com.br/5487#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Wed, 07 Apr 2021 20:56:22 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[buster]]></category>
		<category><![CDATA[certificado]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[debian 10]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[letsencrypt]]></category>
		<category><![CDATA[LNMP]]></category>
		<category><![CDATA[lnpp]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[pgadmin]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php-fpm]]></category>
		<category><![CDATA[phpMyAdmin]]></category>
		<category><![CDATA[phppgadmin]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=5487</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/5487">Servidor WEB NGINX + PHP + PostgreSQL + phpPgAdmin + Letsencrypt no Debian 10 Buster (LNPP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/NGINX-LNNP.png" alt="" width="720" height="340" class="alignnone size-full wp-image-5514" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/NGINX-LNNP.png 720w, https://blog.remontti.com.br/wp-content/uploads/2021/04/NGINX-LNNP-300x142.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/NGINX-LNNP-520x245.png 520w" sizes="auto, (max-width: 720px) 100vw, 720px" /><br />
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/2966" rel="noopener noreferrer" target="_blank">Debian 10 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></p>
<pre class="remontti-code"># apt install 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" /><br />
Se você acessar um diretório que não existe um erro dizendo que não existe, e junto informações que não é legal aparecer.<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2.png" alt="" width="1036" height="296" class="alignnone size-full wp-image-5468" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2.png 1036w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2-300x86.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2-1024x293.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2-768x219.png 768w" sizes="auto, (max-width: 1036px) 100vw, 1036px" /><br />
Vamos remover assinatura do nginx onde ele exibe a versão do mesmo. Ninguém precisa saber! Correto?</p>
<pre class="remontti-code"># sed -i &#039;s/# server_tokens/server_tokens/&#039; /etc/nginx/nginx.conf
# systemctl restart nginx</pre>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx3.png" alt="" width="712" height="157" class="alignnone size-full wp-image-5469" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx3.png 712w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx3-300x66.png 300w" sizes="auto, (max-width: 712px) 100vw, 712px" /></p>
<p>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/11/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 loading="lazy" 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="auto, (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 (11.11 (Debian 11.11-0+deb10u1))
Digite &quot;help&quot; para ajuda.
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 para usuário postgres: 
psql (11.11 (Debian 11.11-0+deb10u1))
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
$ dropuser teste</pre>
<p>Volte para root</p>
<pre class="remontti-code">$ exit</pre>
<h3>PHP7</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 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/php7.3-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 php7.3-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/2021/04/nginx-php7.png" alt="" width="1173" height="899" class="alignnone size-full wp-image-5473" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx-php7.png 1173w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx-php7-300x230.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx-php7-1024x785.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx-php7-768x589.png 768w" sizes="auto, (max-width: 1173px) 100vw, 1173px" /><br />
<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Nosso 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;

    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/php7.3-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/php7.3-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>phpPgAdmin</h3>
<p>O phppgadmin até pode ser instalado via apt, porém seu empacotamento esta na versão 5, vou baixar a versão mais recente direta do <a href="https://github.com/phppgadmin/phppgadmin/releases" rel="noopener" target="_blank">https://github.com/phppgadmin/phppgadmin/releases</a> hoje (abril 2021) na versão 7.13.0</p>
<pre class="remontti-code"># apt install wget 
# cd /tmp/
# wget https://github.com/phppgadmin/phppgadmin/releases/download/REL_7-13-0/phpPgAdmin-7.13.0.tar.gz
# tar vxf phpPgAdmin-7.13.0.tar.gz
# mv /tmp/phpPgAdmin-7.13.0 /usr/share/phppgadmin</pre>
<p>Ajustes no config.inc.php</p>
<pre class="remontti-code"># vim /usr/share/phppgadmin/conf/config.inc.php</pre>
<p>Localize as linhas e ajuste:</p>
<pre class="remontti-code">$conf[&#039;servers&#039;][0][&#039;host&#039;] = &#039;localhost&#039;;
$conf[&#039;extra_login_security&#039;] = false;
$conf[&#039;owned_only&#039;] = true;</pre>
<p>Para torna-lo acessível altere o arquivo de configuração do seu NGINX, no exemplo vou colocar no arquivo default, mas você poderia estar configurando em seus domínios. </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/php7.3-fpm.sock;
    }

    location ^~ /phppgadmin {
        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/php7.3-fpm.sock;
        }

    }

}</pre>
<p>Se deseja tonar o phppgadmin acessível apenas de alguns endereços IPs (RECOMENDO) 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 reinicie o serviço:</p>
<pre class="remontti-code"># nginx -t
# systemctl restart nginx</pre>
<p>Basta acessar http://IP-SERVIDOR/phppgadmin<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/phppgadmin7.png" alt="" width="1033" height="340" class="alignnone size-full wp-image-5495" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/phppgadmin7.png 1033w, https://blog.remontti.com.br/wp-content/uploads/2021/04/phppgadmin7-300x99.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/phppgadmin7-1024x337.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/04/phppgadmin7-768x253.png 768w" sizes="auto, (max-width: 1033px) 100vw, 1033px" /><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/postgres2.png" alt="" width="1401" height="576" class="alignnone size-full wp-image-5511" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/postgres2.png 1401w, https://blog.remontti.com.br/wp-content/uploads/2021/04/postgres2-300x123.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/postgres2-1024x421.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/04/postgres2-768x316.png 768w" sizes="auto, (max-width: 1401px) 100vw, 1401px" /></p>
<h3>LETSENCRYPT</h3>
<p>Criando certificado valido para nossos domínios.</p>
<pre class="remontti-code"># apt install letsencrypt python-certbot-nginx</pre>
<p>Tenha seu(s) domínio(s) configurado em /etc/nginx/sites-enabled/</p>
<pre class="remontti-code"># letsencrypt</pre>
<p>Retorno do questionário:</p>
<pre class="remontti-code">Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter &#039;c&#039; to
cancel): dev@null.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: sub1.remontti.com.br
2: sub2.remontti.com.br   &lt;&lt; CASO VOCÊ TENHA MAIS DE UM SUB CONFIGURADO
3: sub3.remontti.com.br    &lt;&lt; IRÁ APARECER AQUI 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter &#039;c&#039; to cancel): 1 &lt;&lt; ESCOLHA QUAIS VC DESEJA
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for sub1.remontti.com.br
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/sub1.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 &lt;&lt; SE QUISER FORCAR SEMPRE HTTPS
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/sub1.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled
https://sub1.remontti.com.br

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=sub1.remontti.com.br
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/sub1.remontti.com.br/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/sub1.remontti.com.br/privkey.pem
   Your cert will expire on 2021-07-05. 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 / Let&#039;s Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le
</pre>
<p>Você pode também criar o certificado diretamente para um domínio. </p>
<pre class="remontti-code"># letsencrypt --authenticator standalone --installer nginx -d sub1.remontti.com.br</pre>
<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-IZaHSVY5" 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>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"># echo &#039;00 00   1 * *   root    /usr/bin/certbot -q renew&#039; &gt;&gt; /etc/crontab
# systemctl restart cron</pre>
<p>Caso não renovar apenas rode o comando letsencrypt novamente. </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/5487">Servidor WEB NGINX + PHP + PostgreSQL + phpPgAdmin + Letsencrypt no Debian 10 Buster (LNPP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/5487/feed</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>Servidor WEB NGINX + PHP + MariaDB + phpMyAdmin + Letsencrypt no Debian 10 Buster (LNMP)</title>
		<link>https://blog.remontti.com.br/5465</link>
					<comments>https://blog.remontti.com.br/5465#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Wed, 07 Apr 2021 00:44:49 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[LNMP]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php-fpm]]></category>
		<category><![CDATA[phpMyAdmin]]></category>
		<category><![CDATA[webserver]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=5465</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/5465">Servidor WEB NGINX + PHP + MariaDB + phpMyAdmin + Letsencrypt no Debian 10 Buster (LNMP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/NGINX.png" alt="" width="720" height="340" class="alignnone size-full wp-image-5485" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/NGINX.png 720w, https://blog.remontti.com.br/wp-content/uploads/2021/04/NGINX-300x142.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/NGINX-520x245.png 520w" sizes="auto, (max-width: 720px) 100vw, 720px" /><br />
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/2966" rel="noopener noreferrer" target="_blank">Debian 10 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></p>
<pre class="remontti-code"># apt install 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" /><br />
Se você acessar um diretório que não existe um erro dizendo que não existe, e junto informações que não é legal aparecer.<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2.png" alt="" width="1036" height="296" class="alignnone size-full wp-image-5468" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2.png 1036w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2-300x86.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2-1024x293.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx2-768x219.png 768w" sizes="auto, (max-width: 1036px) 100vw, 1036px" /><br />
Vamos remover assinatura do nginx onde ele exibe a versão do mesmo. Ninguém precisa saber! Correto?</p>
<pre class="remontti-code"># sed -i &#039;s/# server_tokens/server_tokens/&#039; /etc/nginx/nginx.conf
# systemctl restart nginx</pre>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx3.png" alt="" width="712" height="157" class="alignnone size-full wp-image-5469" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx3.png 712w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx3-300x66.png 300w" sizes="auto, (max-width: 712px) 100vw, 712px" /></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>Por segurança vamos setar uma senha do </p>
<pre class="remontti-code"># mariadb -u root</pre>
<p>Não use a mesma senha do seu servidor, crie uma nova totalmente diferente! 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;
UPDATE user SET password=PASSWORD(&#039;SENHA&#039;) WHERE User=&#039;root&#039;;
UPDATE user SET plugin=&quot;mysql_native_password&quot;;
FLUSH PRIVILEGES;
quit;</pre>
<p>Agora quando for acessar o mariadb será necessário informar a senha.</p>
<pre class="remontti-code"># mariadb -u root -p</pre>
<h3>PHP7</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 php php-{fpm,cli,mysql,pear,gd,gmp,bcmath,mbstring,curl,xml,zip,json}</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/php7.3-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 php7.3-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/2021/04/nginx-php7.png" alt="" width="1173" height="899" class="alignnone size-full wp-image-5473" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx-php7.png 1173w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx-php7-300x230.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx-php7-1024x785.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/04/nginx-php7-768x589.png 768w" sizes="auto, (max-width: 1173px) 100vw, 1173px" /><br />
<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Nosso 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;

    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/php7.3-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/php7.3-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>
<p>Cade ele do repositório? O PHPMyAdmin não está mais disponível como pacote .deb no Debian 10. Fazendo um pesquisa o motivo é que o &#8220;pessoal&#8221; que faz empacotamento não tem uma versão estável. <a href="https://security-tracker.debian.org/tracker/CVE-2018-19968" rel="noopener noreferrer" target="_blank">https://security-tracker.debian.org/tracker/CVE-2018-19968</a><br />
Desta forma debian &#8220;obriga&#8221; com que o usuário instale-o a partir da fonte. <a href="https://www.phpmyadmin.net/downloads/" rel="noopener noreferrer" target="_blank">https://www.phpmyadmin.net/downloads/</a></p>
<pre class="remontti-code"># apt install wget
# cd /tmp/
# wget https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.tar.gz
# tar -vxzf phpMyAdmin-5.1.0-all-languages.tar.gz -C /usr/share/
# mv /usr/share/phpMyAdmin-5.1.0-all-languages /usr/share/phpmyadmin
# mkdir /etc/phpmyadmin
# touch /etc/phpmyadmin/htpasswd.setup
# mkdir -p /var/lib/phpmyadmin/tmp
# chown www-data. /var/lib/phpmyadmin/ -R</pre>
<p>Para nosso phpmyadmin funcionar corretamente precisamos criar um banco de dados para ele, e por segurança vamos tb criar um usuário só para ele.</p>
<pre class="remontti-code"># mariadb -p</pre>
<p>Não esqueça de alterar &#8220;SUA_SENHA&#8221;.</p>
<pre class="remontti-code">CREATE DATABASE phpmyadmin;
CREATE USER &#039;pma&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;SUA_SENHA&#039;;
GRANT ALL PRIVILEGES ON phpmyadmin.* TO &#039;pma&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;SUA_SENHA&#039; WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;</pre>
<p>Agora vamos importar as tabelas e configura-lo.</p>
<pre class="remontti-code"># mariadb -u root -p phpmyadmin &lt; /usr/share/phpmyadmin/sql/create_tables.sql
# cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
# vim /usr/share/phpmyadmin/config.inc.php</pre>
<p>Descomente/Adicone/Altere:</p>
<pre class="remontti-code">/* INFORME O BLOWFISH SECRET USE O GERADOR DE SENHA. DEVE TER 32 CARACTERES */
$cfg[&#039;blowfish_secret&#039;] = &#039;dkJhGx83XR3JjuFrDn8kPp9NtXnkLptl&#039;;

/* ADICIONE  */
$cfg[&#039;TempDir&#039;] = &#039;/var/lib/phpmyadmin/tmp&#039;;

/* DESCOMENTE */ 
/* User used to manipulate with storage */
$cfg[&#039;Servers&#039;][$i][&#039;controlhost&#039;] = &#039;localhost&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;controlport&#039;] = &#039;&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;controluser&#039;] = &#039;pma&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;controlpass&#039;] = &#039;SUA_SENHA&#039;;
 
/* DESCOMENTE */
/* Storage database and tables */
$cfg[&#039;Servers&#039;][$i][&#039;pmadb&#039;] = &#039;phpmyadmin&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;bookmarktable&#039;] = &#039;pma__bookmark&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;relation&#039;] = &#039;pma__relation&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;table_info&#039;] = &#039;pma__table_info&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;table_coords&#039;] = &#039;pma__table_coords&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;pdf_pages&#039;] = &#039;pma__pdf_pages&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;column_info&#039;] = &#039;pma__column_info&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;history&#039;] = &#039;pma__history&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;table_uiprefs&#039;] = &#039;pma__table_uiprefs&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;tracking&#039;] = &#039;pma__tracking&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;userconfig&#039;] = &#039;pma__userconfig&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;recent&#039;] = &#039;pma__recent&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;favorite&#039;] = &#039;pma__favorite&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;users&#039;] = &#039;pma__users&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;usergroups&#039;] = &#039;pma__usergroups&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;navigationhiding&#039;] = &#039;pma__navigationhiding&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;savedsearches&#039;] = &#039;pma__savedsearches&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;central_columns&#039;] = &#039;pma__central_columns&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;designer_settings&#039;] = &#039;pma__designer_settings&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;export_templates&#039;] = &#039;pma__export_templates&#039;;</pre>
<p>Para torna-lo acessível altere o arquivo de configuração do seu NGINX, no exemplo vou colocar no arquivo default, mas você poderia estar configurando em seus domínios. </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/php7.3-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/php7.3-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>Basta acessar http://IP-SERVIDOR/phpmyadmin</p>
<h3>LETSENCRYPT</h3>
<p>Criando certificado valido para nossos domínios.</p>
<pre class="remontti-code"># apt install letsencrypt python-certbot-nginx</pre>
<p>Tenha seu(s) domínio(s) configurado em /etc/nginx/sites-enabled/</p>
<pre class="remontti-code"># letsencrypt</pre>
<p>Retorno do questionário:</p>
<pre class="remontti-code">Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter &#039;c&#039; to
cancel): dev@null.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: sub1.remontti.com.br
2: sub2.remontti.com.br   &lt;&lt; CASO VOCÊ TENHA MAIS DE UM SUB CONFIGURADO
3: sub3.remontti.com.br    &lt;&lt; IRÁ APARECER AQUI 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter &#039;c&#039; to cancel): 1 &lt;&lt; ESCOLHA QUAIS VC DESEJA
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for sub1.remontti.com.br
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/sub1.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 &lt;&lt; SE QUISER FORCAR SEMPRE HTTPS
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/sub1.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled
https://sub1.remontti.com.br

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=sub1.remontti.com.br
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/sub1.remontti.com.br/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/sub1.remontti.com.br/privkey.pem
   Your cert will expire on 2021-07-05. 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 / Let&#039;s Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le
</pre>
<p>Você pode também criar o certificado diretamente para um domínio. </p>
<pre class="remontti-code"># letsencrypt --authenticator standalone --installer nginx -d sub1.remontti.com.br</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"># echo &#039;00 00   1 * *   root    /usr/bin/certbot -q renew&#039; &gt;&gt; /etc/crontab
# systemctl restart cron</pre>
<p>Caso não renovar apenas rode o comando letsencrypt novamente. </p>
<h3>Bônus: Modelo para WordPress</h3>
<p>Como rewrite no NGINX é um pouco diferente vou deixar um ex.:</p>
<pre class="remontti-code">server {
    listen 80;
    listen [::]:80;

    root /var/www/sub2e3;
    index index.php index.html index.htm;

    server_name remontti.com.br www.remontti.com.br;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    }
}</pre>
<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-IK2fDPWS" 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/5465">Servidor WEB NGINX + PHP + MariaDB + phpMyAdmin + Letsencrypt no Debian 10 Buster (LNMP)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/5465/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Passo-a-passo como criar um servidor WEB Apache + PHP + MariaDB + phpMyAdmin no Debian 10 Buster &#8220;LAMP&#8221;</title>
		<link>https://blog.remontti.com.br/3006</link>
					<comments>https://blog.remontti.com.br/3006#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Tue, 16 Jul 2019 19:05:12 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[buster]]></category>
		<category><![CDATA[debian 10]]></category>
		<category><![CDATA[debian buster]]></category>
		<category><![CDATA[debian10]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[MariaDB]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpMyAdmin]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=3006</guid>

					<description><![CDATA[<p>Distribuição utilizada: Debian 10 Stretch / Instalação Limpa Vale lembrar que desde o Debian 9 o PHP foi atualizado para a versão 7 e agora para 7.3, e o MySQL foi substituído pelo seu&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/3006">Passo-a-passo como criar um servidor WEB Apache + PHP + MariaDB + phpMyAdmin no Debian 10 Buster &#8220;LAMP&#8221;</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/debian10-lamp.jpg" alt="" width="800" height="376" class="alignnone size-full wp-image-3028" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/07/debian10-lamp.jpg 800w, https://blog.remontti.com.br/wp-content/uploads/2019/07/debian10-lamp-300x141.jpg 300w, https://blog.remontti.com.br/wp-content/uploads/2019/07/debian10-lamp-768x361.jpg 768w, https://blog.remontti.com.br/wp-content/uploads/2019/07/debian10-lamp-520x245.jpg 520w" sizes="auto, (max-width: 800px) 100vw, 800px" /><br />
Distribuição utilizada: <strong><a href="https://blog.remontti.com.br/2966" rel="noopener noreferrer" target="_blank">Debian 10 Stretch / Instalação Limpa</a></strong><br />
Vale lembrar que desde o Debian 9 o PHP foi atualizado para a versão 7 e agora para 7.3, e o MySQL foi substituído pelo seu fork MariaBD<br />
Antes de mais nada tenha seu repositório atualizado</p>
<pre class="remontti-code"># su -
# apt update
# apt upgrade</pre>
<h3>:: Instalação do Apache 2.4 ::</h3>
<pre class="remontti-code"># apt install apache2 apache2-utils</pre>
<p>Vamos habilitar o mod_rewrite do Apache que é muito utilizado.<br />
Este é um módulo do Apache que utiliza um mecanismo baseado em regras de reescrita.<br />
Vamos ao comando para habilita-lo:</p>
<pre class="remontti-code"># a2enmod rewrite</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 funcione corretamente será necessário adicionar alguma linhas.</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">	&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/2019/07/apache2-deb10-rewrite.png" data-rel="lightbox-gallery-poKVS78S" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/apache2-deb10-rewrite-300x251.png" alt="" width="300" height="251" class="alignnone size-medium wp-image-3012" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/07/apache2-deb10-rewrite-300x251.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/07/apache2-deb10-rewrite-768x642.png 768w, https://blog.remontti.com.br/wp-content/uploads/2019/07/apache2-deb10-rewrite.png 887w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><br />
Agora precisamos restartar o apache2 para que tenha efeito as alterações.</p>
<pre class="remontti-code"># systemctl restart apache2</pre>
<p>http://[SERVER_IP]/<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2019/07/apache-debian-10-buster.png" data-rel="lightbox-gallery-poKVS78S" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/apache-debian-10-buster-230x300.png" alt="" width="230" height="300" class="alignnone size-medium wp-image-3010" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/07/apache-debian-10-buster-230x300.png 230w, https://blog.remontti.com.br/wp-content/uploads/2019/07/apache-debian-10-buster-768x1003.png 768w, https://blog.remontti.com.br/wp-content/uploads/2019/07/apache-debian-10-buster-784x1024.png 784w, https://blog.remontti.com.br/wp-content/uploads/2019/07/apache-debian-10-buster.png 941w" sizes="auto, (max-width: 230px) 100vw, 230px" /></a><br />
Por segurança remova a assinatura do apache.</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>
<h3>:: Instalação do MariaDB 10.3 ::</h3>
<pre class="remontti-code"># apt install mariadb-server mariadb-client </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.<br />
Assim, você pode logar diretamente sem fornecer a senha root do MariaDB. Mas isso é estranho, pois minha senha do root do MariaDB é diferente do meu usuário unix.<br />
Bom se você é meio paranoico com segurança, para alterar a senha do usuário root do MariaDB de forma bruta faça o seguinte:</p>
<pre class="remontti-code"># mariadb -u root</pre>
<pre class="remontti-code">USE mysql;
UPDATE user SET password=PASSWORD(&#039;SENHA.db.ROOT&#039;) WHERE User=&#039;root&#039;;
UPDATE user SET plugin=&quot;mysql_native_password&quot;;
FLUSH PRIVILEGES;
quit;</pre>
<h3>:: Instalação do PHP 7.3 ::</h3>
<p>Vou incluir algumas extensões do PHP que são normalmente utilizada</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</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">PHP 7.3.4-2 (cli) (built: Apr 13 2019 19:05:48) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.4-2, Copyright (c) 1999-2018, 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>http://[SERVER_IP]/phpinfo.php<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpinfo-debian-10-buster.png" data-rel="lightbox-gallery-poKVS78S" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpinfo-debian-10-buster-300x261.png" alt="" width="300" height="261" class="alignnone size-medium wp-image-3018" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpinfo-debian-10-buster-300x261.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpinfo-debian-10-buster-768x668.png 768w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpinfo-debian-10-buster.png 994w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<h3>:: phpMyAdmin ::</h3>
<p>Cade ele do repositório?<br />
O PHPMyAdmin não está mais disponível como pacote .deb no Debian 10. Fazendo um pesquisa o motivo é que o &#8220;pessoal&#8221; que faz empacotamento não tem uma versão estável. <a href="https://security-tracker.debian.org/tracker/CVE-2018-19968" rel="noopener noreferrer" target="_blank">https://security-tracker.debian.org/tracker/CVE-2018-19968</a><br />
Desta forma debian &#8220;obriga&#8221; com que o usuário instale-o a partir da fonte. <a href="https://www.phpmyadmin.net/downloads/" rel="noopener noreferrer" target="_blank">https://www.phpmyadmin.net/downloads/</a></p>
<pre class="remontti-code"># apt install wget</pre>
<p>Escolha qual versão do irá utilizar phpMyAdmin 5.x.x ou 4.x.x</p>
<pre class="remontti-code"># cd /tmp/</pre>
<p>Para <strong>phpMyAdmin 5</strong> (06/04/2020)</p>
<pre class="remontti-code"># wget https://files.phpmyadmin.net/phpMyAdmin/5.0.4/phpMyAdmin-5.0.4-all-languages.tar.gz
# tar -vxzf phpMyAdmin-5.0.4-all-languages.tar.gz -C /usr/share/
# mv /usr/share/phpMyAdmin-5.0.4-all-languages /usr/share/phpmyadmin</pre>
<p>Para <strong>phpMyAdmin 4</strong> (06/04/2020)</p>
<pre class="remontti-code"># wget https://files.phpmyadmin.net/phpMyAdmin/4.9.5/phpMyAdmin-4.9.5-all-languages.tar.gz
# tar -vxzf phpMyAdmin-4.9.5-all-languages.tar.gz -C /usr/share/
# mv /usr/share/phpMyAdmin-4.9.5-all-languages /usr/share/phpmyadmin</pre>
<p>Seguimos para <strong>phpMyAdmin 5 ou 4</strong> </p>
<pre class="remontti-code"># mkdir /etc/phpmyadmin
# touch /etc/phpmyadmin/htpasswd.setup
# mkdir -p /var/lib/phpmyadmin/tmp
# chown www-data. /var/lib/phpmyadmin/ -R</pre>
<p>Criaremos o arquivo de configuração do Apache.</p>
<pre class="remontti-code"># vim /etc/apache2/conf-available/phpmyadmin.conf</pre>
<pre class="remontti-code"># phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin

&lt;Directory /usr/share/phpmyadmin&gt;
 Options FollowSymLinks
 DirectoryIndex index.php

 &lt;IfModule mod_php7.c&gt;
 AddType application/x-httpd-php .php

 php_flag magic_quotes_gpc Off
 php_flag track_vars On
 php_flag register_globals Off
 php_value include_path .
 &lt;/IfModule&gt;

&lt;/Directory&gt;

# Authorize for setup
&lt;Directory /usr/share/phpmyadmin/setup&gt;
 &lt;IfModule mod_authn_file.c&gt;
 AuthType Basic
 AuthName &quot;phpMyAdmin Setup&quot;
 AuthUserFile /etc/phpmyadmin/htpasswd.setup
 &lt;/IfModule&gt;
 Require valid-user
&lt;/Directory&gt;

# Disallow web access to directories that don&#039;t need it
&lt;Directory /usr/share/phpmyadmin/libraries&gt;
 Order Deny,Allow
 Deny from All
&lt;/Directory&gt;
&lt;Directory /usr/share/phpmyadmin/setup/lib&gt;
 Order Deny,Allow
 Deny from All
&lt;/Directory&gt;</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 FollowSymLinks
 DirectoryIndex index.php

 AllowOverride All
 Require ip 127.0.0.1 ::1 200.200.200.0/26 2001:db8:cafe:d0ce::/64

 &lt;IfModule mod_php7.c&gt;
 AddType application/x-httpd-php .php
 
 php_flag magic_quotes_gpc Off
 php_flag track_vars On
 php_flag register_globals Off
 php_value include_path .
 &lt;/IfModule&gt;
 
&lt;/Directory&gt;
 
# Authorize for setup
&lt;Directory /usr/share/phpmyadmin/setup&gt;
 AllowOverride All
 Require ip 127.0.0.1 ::1 200.200.200.0/26 2001:db8:cafe:d0ce::/64
 &lt;IfModule mod_authn_file.c&gt;
 AuthType Basic
 AuthName &quot;phpMyAdmin Setup&quot;
 AuthUserFile /etc/phpmyadmin/htpasswd.setup
 &lt;/IfModule&gt;
 Require valid-user
&lt;/Directory&gt;
 
# Disallow web access to directories that don&#039;t need it
&lt;Directory /usr/share/phpmyadmin/libraries&gt;
 AllowOverride All
 Require ip 127.0.0.1 ::1 200.200.200.0/26 2001:db8:cafe:d0ce::/64
 Order Deny,Allow
 Deny from All
&lt;/Directory&gt;
&lt;Directory /usr/share/phpmyadmin/setup/lib&gt;
 AllowOverride All
 Require ip 127.0.0.1 ::1 200.200.200.0/26 2001:db8:cafe:d0ce::/64
 Order Deny,Allow
 Deny from All
&lt;/Directory&gt;
</pre>
<p>Ative a configuração e reinicie o Apache.</p>
<pre class="remontti-code"># a2enconf phpmyadmin
# systemctl restart apache2
# systemctl status apache2</pre>
<p>Na próxima etapa, vamos configurar o armazenamento de configuração do phpMyadmin (banco de dados).<br />
Faça o login no MariaDB como usuário root:</p>
<pre class="remontti-code"># mariadb -p</pre>
<p>Criamos um novo banco de dados para o chamado phpmyadmin e um usuario pma (altere para sua senha). Em seguida, concedemos as permissões do banco de dados.<br />
Você pode gerar uma senha acessando <a href="https://senhasegura.remontti.com.br/" rel="noopener noreferrer" target="_blank">https://senhasegura.remontti.com.br/</a></p>
<pre class="remontti-code">CREATE DATABASE phpmyadmin;
CREATE USER &#039;pma&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;SUA_SENHA&#039;;
GRANT ALL PRIVILEGES ON phpmyadmin.* TO &#039;pma&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;SUA_SENHA&#039; WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;</pre>
<p>Carregue as tabelas do banco de dados: (Informe a senha do root do MariaDB)</p>
<pre class="remontti-code"># mariadb -u root -p phpmyadmin &lt; /usr/share/phpmyadmin/sql/create_tables.sql</pre>
<p>Agora é necessário ajustar o arquivo de configuração do phpmyadmin.<br />
Definir:<br />
* senha segura (blowfish secret) que deve ter 32 caracteres. Não use o meu exemplo blowfish secreto, defina o seu próprio! Use o gerador <a href="https://senhasegura.remontti.com.br" rel="noopener noreferrer" target="_blank">https://senhasegura.remontti.com.br</a><br />
* diretório que o PHPMyAdmin deve usar para armazenar arquivos temporários.<br />
* Descomentar as linhas $cfg['Servers']<br />
- controlhost : localhost<br />
- controlpass : SUA_SENHA</p>
<pre class="remontti-code"># cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
# vim /usr/share/phpmyadmin/config.inc.php</pre>
<pre class="remontti-code">$cfg[&#039;blowfish_secret&#039;] = &#039;dkJhGx83XR3JjuFrDn8kPp9NtXnkLptl&#039;;
/* Adicione esta linha */
$cfg[&#039;TempDir&#039;] = &#039;/var/lib/phpmyadmin/tmp&#039;;

/* User used to manipulate with storage */
$cfg[&#039;Servers&#039;][$i][&#039;controlhost&#039;] = &#039;localhost&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;controlport&#039;] = &#039;&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;controluser&#039;] = &#039;pma&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;controlpass&#039;] = &#039;SUA_SENHA&#039;;

/* Storage database and tables */
$cfg[&#039;Servers&#039;][$i][&#039;pmadb&#039;] = &#039;phpmyadmin&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;bookmarktable&#039;] = &#039;pma__bookmark&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;relation&#039;] = &#039;pma__relation&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;table_info&#039;] = &#039;pma__table_info&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;table_coords&#039;] = &#039;pma__table_coords&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;pdf_pages&#039;] = &#039;pma__pdf_pages&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;column_info&#039;] = &#039;pma__column_info&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;history&#039;] = &#039;pma__history&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;table_uiprefs&#039;] = &#039;pma__table_uiprefs&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;tracking&#039;] = &#039;pma__tracking&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;userconfig&#039;] = &#039;pma__userconfig&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;recent&#039;] = &#039;pma__recent&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;favorite&#039;] = &#039;pma__favorite&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;users&#039;] = &#039;pma__users&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;usergroups&#039;] = &#039;pma__usergroups&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;navigationhiding&#039;] = &#039;pma__navigationhiding&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;savedsearches&#039;] = &#039;pma__savedsearches&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;central_columns&#039;] = &#039;pma__central_columns&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;designer_settings&#039;] = &#039;pma__designer_settings&#039;;
$cfg[&#039;Servers&#039;][$i][&#039;export_templates&#039;] = &#039;pma__export_templates&#039;;</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster.png" data-rel="lightbox-gallery-poKVS78S" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-300x296.png" alt="" width="300" height="296" class="alignnone size-medium wp-image-3021" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-300x296.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-768x757.png 768w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster.png 901w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><br />
http://[SERVER_IP]/phpmyadmin/<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-1.png" data-rel="lightbox-gallery-poKVS78S" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-1-300x155.png" alt="" width="300" height="155" class="alignnone size-medium wp-image-3022" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-1-300x155.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-1-768x397.png 768w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-1-1024x530.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-1.png 1680w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><a href="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-2.png" data-rel="lightbox-gallery-poKVS78S" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-2-300x156.png" alt="" width="300" height="156" class="alignnone size-medium wp-image-3023" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-2-300x156.png 300w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-2-768x399.png 768w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-2-1024x532.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2019/07/phpmyadmin-debian-10-buster-2.png 1680w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Gostou?</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/3006">Passo-a-passo como criar um servidor WEB Apache + PHP + MariaDB + phpMyAdmin no Debian 10 Buster &#8220;LAMP&#8221;</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/3006/feed</wfw:commentRss>
			<slash:comments>70</slash:comments>
		
		
			</item>
		<item>
		<title>Passo-a-passo como criar um servidor web Apache2, PHP 7.0, MariaDB, PHPMyAdmin &#8220;LAMP&#8221; no Debian 9 Stretch</title>
		<link>https://blog.remontti.com.br/2024</link>
					<comments>https://blog.remontti.com.br/2024#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Mon, 19 Jun 2017 18:55:38 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[Debian 9]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[MariaDB]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP 7.0]]></category>
		<category><![CDATA[phpMyAdmin]]></category>
		<category><![CDATA[Stretch]]></category>
		<category><![CDATA[webserver]]></category>
		<guid isPermaLink="false">http://blog.remontti.com.br/?p=2024</guid>

					<description><![CDATA[<p>Distribuição utilizada: Debian 9 Stretch / Instalação Limpa Com o lançamento do Debian 9 alguns pacotes foram substituído como: PHP5 -> PHP7.0 Mysql -> MariaDB (MariaDB é um banco de dados que surgiu como&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/2024">Passo-a-passo como criar um servidor web Apache2, PHP 7.0, MariaDB, PHPMyAdmin &#8220;LAMP&#8221; no Debian 9 Stretch</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/webdev-debian9.jpg" alt="" width="800" height="376" class="alignnone size-full wp-image-2046" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/webdev-debian9.jpg 800w, https://blog.remontti.com.br/wp-content/uploads/2017/06/webdev-debian9-300x141.jpg 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/webdev-debian9-768x361.jpg 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/webdev-debian9-520x245.jpg 520w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p>Distribuição utilizada: Debian 9 Stretch / <a href="https://blog.remontti.com.br/1152">Instalação Limpa</a></p>
<p>Com o lançamento do Debian 9 alguns pacotes foram substituído como:<br />
<strong>PHP5 -> PHP7.0</strong><br />
<strong>Mysql -> <a href="https://pt.wikipedia.org/wiki/MariaDB" target="_blank" rel="noopener noreferrer">MariaDB</a></strong> (<em>MariaDB é um banco de dados que surgiu como fork do MySQL, criado pelo próprio fundador do projeto após sua aquisição pela Oracle.</em>)</p>
<p>Vamos a instalação</p>
<pre class="remontti-code"># apt update
# apt upgrade
# apt install apache2 libapache2-mod-php7.0 php7.0 mariadb-client mariadb-server phpmyadmin</pre>
<p>Instale todos os pacotes dependentes. (S)</p>
<p><em>OBS: Se você instalar o pacote <strong>mysql-server</strong> ele vai estar instalando o mariadb-client mariadb-server.</em></p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143240.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143240-300x199.png" alt="" width="300" height="199" class="alignnone size-medium wp-image-2028" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143240-300x199.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143240-768x509.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143240-1024x679.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143240.png 1192w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Na próxima tela selecione a opção apache2.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143756.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143756-300x199.png" alt="" width="300" height="199" class="alignnone size-medium wp-image-2029" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143756-300x199.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143756-768x509.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143756-1024x679.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_143756.png 1192w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Configurando o banco do phpmyadmin:<br />
Responda Sim.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144016.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144016-300x199.png" alt="" width="300" height="199" class="alignnone size-medium wp-image-2030" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144016-300x199.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144016-768x509.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144016-1024x679.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144016.png 1192w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Defina uma senha para a base do phpmyadmin:<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144112.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144112-300x199.png" alt="" width="300" height="199" class="alignnone size-medium wp-image-2031" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144112-300x199.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144112-768x509.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144112-1024x679.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144112.png 1192w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Repita a senha:<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144154.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144154-300x199.png" alt="" width="300" height="199" class="alignnone size-medium wp-image-2032" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144154-300x199.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144154-768x509.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144154-1024x679.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144154.png 1192w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><br />
Instalação concluída!<br />
Acesse <strong>http://ip-do-seu-servidor/</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150403.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150403-300x158.png" alt="" width="300" height="158" class="alignnone size-medium wp-image-2039" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150403-300x158.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150403-768x403.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150403-1024x538.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150403.png 1680w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p><strong>Não sentiu que faltou algo nessa instalação?</strong><br />
<strong>Sim!</strong> No MySQL você definia uma senha para para o usuário root do mysql na instalação, com o MariaDB isso não acontece pois ele vem sem senha de root! Como usuário root não tem senha você não vai conseguir logar com ele no PHPMyAdmin.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144650.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144650-202x300.png" alt="" width="202" height="300" class="alignnone size-medium wp-image-2034" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144650-202x300.png 202w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_144650.png 432w" sizes="auto, (max-width: 202px) 100vw, 202px" /></a></p>
<p>Para alterar a senha do usuário root do MariaDB faça:</p>
<pre class="remontti-code"># mariadb -u root</pre>
<pre class="remontti-code">USE mysql;
UPDATE user SET password=PASSWORD(&#039;SUA-SENHA&#039;) WHERE User=&#039;root&#039;;
UPDATE user SET plugin=&quot;mysql_native_password&quot;;
FLUSH PRIVILEGES;
quit;</pre>
<p>Mas não se assuste! MariaDB é praticamente o seu velho MySQL. Para saber mais acesse: <a href="https://mariadb.com/kb/pt-br/mariadb-versus-mysql-compatibility/" target="_blank" rel="noopener noreferrer">MariaDB versus MySQL &#8211; Compatibilidade</a>. Veja pelo lado bom, não permitindo login com root temos mais segurança!<br />
O que fazer então? Simples crie uma base de dados e um usuário para acessa-la. Eu sempre recomendei usar para cada aplicação um usuário com a sua base, assim numa falha você  não deixa exposto o que não deveria!<br />
Acesse via linha de comando nosso o mariadb (o comando mysql -p funciona também) </p>
<pre class="remontti-code"># mariadb -p</pre>
<p>Por padrão vem sem senha.</p>
<pre class="remontti-code">CREATE DATABASE minhabase;
GRANT ALL PRIVILEGES ON minhabase.* TO &#039;meuusuario&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;minhasenha&#039;;
FLUSH PRIVILEGES;
quit;</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_145812.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_145812-300x106.png" alt="" width="300" height="106" class="alignnone size-medium wp-image-2035" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_145812-300x106.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_145812-768x271.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_145812-1024x362.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_145812.png 1157w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Agora pode acessar seu PHPMyAdmin com seu seu usuário e senha. <strong>http://ip-do-seu-servidor/phpmyadmin</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150017.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150017-300x157.png" alt="" width="300" height="157" class="alignnone size-medium wp-image-2036" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150017-300x157.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150017-768x402.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150017-1024x536.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150017.png 1680w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><a href="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150027.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150027-300x158.png" alt="" width="300" height="158" class="alignnone size-medium wp-image-2037" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150027-300x158.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150027-768x404.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150027-1024x539.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150027.png 1680w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Agora vamos habilitar o <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html">mod_rewrite</a> do Apache que é muito utilizado. Este é um módulo do Apache que utiliza um mecanismo baseado em regras de reescrita.</p>
<p>Diretório de configurações do Apache fica em <strong>/etc/apache2/</strong></p>
<p>Vamos ao comando para habilita-lo:</p>
<pre class="remontti-code"># a2enmod rewrite</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 <em>/etc/apache2/sites-enabled/000-default.conf</em>, e para que nosso <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html">mod_rewrite</a> funcione corretamente será necessário adicionar alguma linhas.</p>
<p>Edite o arquivo /etc/apache2/sites-enabled/000-default.conf (vou usar o editor vim, que não vem instalado por padrão no sistema, mas se você pode usar qualquer edito ex o nano)</p>
<pre class="remontti-code"># vim /etc/apache2/sites-enabled/000-default.conf</pre>
<p>Adicione abaixo de &#8220;<span style="color: #000080;"><strong>DocumentRoot /var/www/html</strong>&#8220;</span> o seguinte:</p>
<pre class="remontti-code">	
	&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/2017/06/Screenshot_20170619_150942.png" data-rel="lightbox-gallery-LT32eNaM" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150942-300x172.png" alt="" width="300" height="172" class="alignnone size-medium wp-image-2042" srcset="https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150942-300x172.png 300w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150942-768x441.png 768w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150942-1024x588.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2017/06/Screenshot_20170619_150942.png 1192w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<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>Agora precisamos restartar o apache para que tenha efeito nossas alterações.</p>
<pre class="remontti-code"># /etc/init.d/apache2 restart</pre>
<p>Ou</p>
<pre class="remontti-code"># systemctl restart apache2</pre>
<p>Parabéns seu servidor está &#8220;Pronto&#8221;!</p>
<p>O post <a href="https://blog.remontti.com.br/2024">Passo-a-passo como criar um servidor web Apache2, PHP 7.0, MariaDB, PHPMyAdmin &#8220;LAMP&#8221; no Debian 9 Stretch</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/2024/feed</wfw:commentRss>
			<slash:comments>47</slash:comments>
		
		
			</item>
	</channel>
</rss>
