{"id":4498,"date":"2018-07-26T14:25:53","date_gmt":"2018-07-26T17:25:53","guid":{"rendered":"https:\/\/blog.clusterweb.com.br\/?p=4498"},"modified":"2018-07-25T14:28:38","modified_gmt":"2018-07-25T17:28:38","slug":"instalando-apache-mariadb-e-php-com-https-no-arch-linux","status":"publish","type":"post","link":"https:\/\/blog.clusterweb.com.br\/?p=4498","title":{"rendered":"INSTALANDO APACHE, MARIADB E PHP COM HTTPS NO ARCH LINUX"},"content":{"rendered":"<h1>APACHE<\/h1>\n<p>&nbsp;<\/p>\n<div>Ambiente:<\/p>\n<ul>\n<li>Sistema:\u00a0Linux\u00a0arch 4.17.3-1-ARCH<\/li>\n<li>Dom\u00ednio: dominio.com.br<\/li>\n<li>Ip: 192.168.0.1<\/li>\n<\/ul>\n<p>1. Update do sistema:<\/p>\n<p><strong># pacman -Syu<\/strong><\/p>\n<p>2. Instalando Apache:<\/p>\n<p><strong># pacman -S apache<\/strong><\/p>\n<p>Habilitando e iniciando servidor Apache:<\/p>\n<p><strong># systemctl enable httpd<br \/>\n# systemctl restart httpd<\/strong><br \/>\n<!--more--><br \/>\nVerificando status do Apache:<\/p>\n<p><strong># systemctl status http<\/strong>\u00a0Sa\u00edda devera ser algo assim:<\/p>\n<pre>\u25cf httpd.service - Apache Web Server\r\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/httpd.service; enabled; vendor preset: disabled)\r\n   Active: active (running) since Fri 2018-07-06 11:58:01 -03; 7s ago\r\n   Main PID: 6367 (httpd)\r\n    Tasks: 82 (limit: 4915)\r\n   Memory: 7.4M\r\n   CGroup: \/system.slice\/httpd.service\r\n           \u251c\u25006367 \/usr\/bin\/httpd -k start -DFOREGROUND\r\n           \u251c\u25006368 \/usr\/bin\/httpd -k start -DFOREGROUND\r\n           \u251c\u25006369 \/usr\/bin\/httpd -k start -DFOREGROUND\r\n           \u2514\u25006370 \/usr\/bin\/httpd -k start -DFOREGROUND\r\n\r\n<\/pre>\n<p>3. Testando Apache:<\/p>\n<p>Edite o arquivo http.conf:<\/p>\n<p><strong># nano \/srv\/http\/index.html<\/strong><\/p>\n<p>Insira as seguintes linhas:<\/p>\n<div class=\"codigo\">&lt;html&gt;<br \/>\n&lt;title&gt;Apache server&lt;\/title&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;h2&gt;Teste deu certo&lt;\/h2&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/div>\n<p>Agora acesse a p\u00e1gina &#8220;http:\/\/localhost&#8221; ou &#8220;http:\/\/192.168.0.1&#8221;.<\/p>\n<\/div>\n<h1>MARIADB<\/h1>\n<p>&nbsp;<\/p>\n<div>1. Instalando\u00a0<em>MariaDB<\/em>:<\/p>\n<p><strong># pacman -S mysql<\/strong><\/p>\n<p>Sa\u00edda dever\u00e1 ser algo assim:<\/p>\n<pre>:: There are 2 providers available for mysql:\r\n:: Repository extra\r\n   1) mariadb\r\n:: Repository community\r\n   2) percona-server\r\n\r\nEnter a number (default=1): &lt;&lt; <strong>[ Enter ]<\/strong>\r\nresolving dependencies...\r\nlooking for conflicting packages...\r\n\r\nPackages (4) jemalloc-1:5.1.0-1  libmariadbclient-10.1.34-1  mariadb-clients-10.1.34-1\r\n             mariadb-10.1.34-1\r\n\r\nTotal Download Size:    32.49 MiB\r\nTotal Installed Size:  229.92 MiB\r\n\r\n:: Proceed with installation? [Y\/n] &lt;&lt; <strong>[ Y ]<\/strong>\r\n\r\n<\/pre>\n<p>2. Agora vamos inicializar a base de dados do MariaDB, necess\u00e1rio antes de iniciar o servi\u00e7o:<\/p>\n<p><strong># mysql_install_db &#8211;user=mysql &#8211;basedir=\/usr &#8211;datadir=\/var\/lib\/mysql<\/strong><\/p>\n<p>3. Agora habilite e inicialize o servi\u00e7o:<\/p>\n<p><strong># systemctl enable mysqld<br \/>\n# systemctl start mysqld<\/strong><\/p>\n<p>Verificando o servi\u00e7o do MariaDB:<\/p>\n<p><strong># systemctl status mysqld<\/strong><\/p>\n<p>Sa\u00edda dever\u00e1 ser algo assim:<\/p>\n<pre>\u25cf mariadb.service - MariaDB 10.1.34 database server\r\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/mariadb.service; enabled; vendor preset: disabled)\r\n   Active: active (running) since Fri 2018-07-06 12:02:33 -03; 5s ago\r\n     Docs: man:mysqld(8)\r\n           https:\/\/mariadb.com\/kb\/en\/library\/systemd\/\r\n  Process: 6750 ExecStartPost=\/bin\/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited&gt;\r\n  Process: 6669 ExecStartPre=\/bin\/sh -c [ ! -e \/usr\/bin\/galera_recovery ] &amp;&amp; VAR= ||   VAR=`\/usr\/bin\/ga&gt;\r\n  Process: 6668 ExecStartPre=\/bin\/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited,&gt;\r\n Main PID: 6722 (mysqld)\r\n   Status: \"Taking your SQL requests now...\"\r\n    Tasks: 27 (limit: 4915)\r\n   Memory: 63.2M\r\n   CGroup: \/system.slice\/mariadb.service\r\n           \u2514\u25006722 \/usr\/bin\/mysqld\r\n\r\nJul 06 12:02:33 arch mysqld[6722]: 2018-07-06 12:02:33 140084921851840 [Note] InnoDB: Highest supported&gt;\r\nJul 06 12:02:33 arch mysqld[6722]: 2018-07-06 12:02:33 140084921851840 [Note] InnoDB: 128 rollback segm&gt;\r\nJul 06 12:02:33 arch mysqld[6722]: 2018-07-06 12:02:33 140084921851840 [Note] InnoDB: Waiting for purge&gt;\r\nJul 06 12:02:33 arch mysqld[6722]: 2018-07-06 12:02:33 140084921851840 [Note] InnoDB:  Percona XtraDB (&gt;\r\nJul 06 12:02:33 arch mysqld[6722]: 2018-07-06 12:02:33 140084921851840 [Note] Plugin 'FEEDBACK' is disa&gt;\r\nJul 06 12:02:33 arch mysqld[6722]: 2018-07-06 12:02:33 140084282128128 [Note] InnoDB: Dumping buffer po&gt;\r\nJul 06 12:02:33 arch mysqld[6722]: 2018-07-06 12:02:33 140084921851840 [Note] Server socket created on &gt;\r\nJul 06 12:02:33 arch mysqld[6722]: 2018-07-06 12:02:33 140084921851840 [Note] \/usr\/bin\/mysqld: ready fo&gt;\r\nJul 06 12:02:33 arch mysqld[6722]: Version: '10.1.34-MariaDB'  socket: '\/run\/mysqld\/mysqld.sock'  port:&gt;\r\nJul 06 12:02:33 arch systemd[1]: Started MariaDB 10.1.34 database server.\r\n\r\n<\/pre>\n<p>4. Colocando password para o root:<\/p>\n<p><strong># mysql_secure_installation<\/strong><\/p>\n<p>Sa\u00edda dever\u00e1 ser algo assim:<\/p>\n<pre>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB\r\n      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!\r\n\r\nIn order to log into MariaDB to secure it, we'll need the current\r\npassword for the root user.  If you've just installed MariaDB, and\r\nyou haven't set the root password yet, the password will be blank,\r\nso you should just press enter here. \r\n\r\nEnter current password for root (enter for none): &lt;&lt; [ Enter ]\r\nOK, successfully used password, moving on...\r\n\r\nSetting the root password ensures that nobody can log into the MariaDB\r\nroot user without the proper authorisation.\r\n\r\nSet root password? [Y\/n]  <strong>[ Enter ]<\/strong>\r\nNew password:  <strong>[ Entre com o password ]<\/strong>\r\nRe-enter new password:  <strong>[ Digite novamente o password ]<\/strong>\r\nPassword updated successfully!\r\nReloading privilege tables..\r\n ... Success!\r\n\r\n\r\nBy default, a MariaDB installation has an anonymous user, allowing anyone\r\nto log into MariaDB without having to have a user account created for\r\nthem.  This is intended only for testing, and to make the installation\r\ngo a bit smoother.  You should remove them before moving into a\r\nproduction environment.\r\n\r\nRemove anonymous users? [Y\/n]  <strong>[ Enter ]<\/strong>\r\n ... Success!\r\n\r\nNormally, root should only be allowed to connect from 'localhost'.  This\r\nensures that someone cannot guess at the root password from the network.\r\n\r\nDisallow root login remotely? [Y\/n]  <strong>[ Enter ]<\/strong>\r\n ... Success!\r\n\r\nBy default, MariaDB comes with a database named 'test' that anyone can\r\naccess.  This is also intended only for testing, and should be removed\r\nbefore moving into a production environment.\r\n\r\nRemove test database and access to it? [Y\/n]  <strong>[ Enter ]<\/strong>\r\n - Dropping test database...\r\n ... Success!\r\n - Removing privileges on test database...\r\n ... Success!\r\n\r\nReloading the privilege tables will ensure that all changes made so far\r\nwill take effect immediately.\r\n\r\nReload privilege tables now? [Y\/n] <strong>[ Enter ]<\/strong>\r\n ... Success!\r\n\r\nCleaning up...\r\n\r\nAll done!  If you've completed all of the above steps, your MariaDB\r\ninstallation should now be secure.\r\n\r\nThanks for using MariaDB!\r\n\r\n<\/pre>\n<p>MariaDB est\u00e1 instalada e pronta para o uso!<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<h1>PHP<\/h1>\n<p>&nbsp;<\/p>\n<div>1. Instalando o\u00a0<em>PHP<\/em>:<\/p>\n<p><strong># pacman -S php php-apache<\/strong><\/p>\n<p>Ap\u00f3s a instala\u00e7\u00e3o edite o arquivo de configura\u00e7\u00e3o do Apache:<\/p>\n<p><strong># nano \/etc\/httpd\/conf\/httpd.conf<\/strong><\/p>\n<p>Encontre a seguinte linha e comente:<\/p>\n<p>LoadModule mpm_event_module modules\/mod_mpm_event.so<\/p>\n<p>Ficando:<\/p>\n<div class=\"codigo\"><span class=\"comentario\">#LoadModule mpm_event_module modules\/mod_mpm_event.so<\/span><\/div>\n<p>E adicione as seguintes linhas ao final do arquivo:<\/p>\n<div class=\"codigo\">LoadModule mpm_prefork_module modules\/mod_mpm_prefork.so<br \/>\nLoadModule php7_module modules\/libphp7.so<br \/>\nAddHandler php7-script php<br \/>\nInclude conf\/extra\/php7_module.conf<\/div>\n<p>2. Testando PHP:<\/p>\n<p><strong># nano \/srv\/http\/test.php<\/strong><\/p>\n<p>Adicione as seguintes linhas:<\/p>\n<div class=\"codigo\">&lt;?php<br \/>\nphpinfo();<br \/>\n?&gt;<\/div>\n<p>Salve e saia.<\/p>\n<p>Reinicie o Apache:<\/p>\n<p><strong># systemctl restart httpd<\/strong><\/p>\n<p>3. Abra a p\u00e1gina &#8220;http:\/\/localhost\/test.php&#8221; ou &#8220;http:\/\/192.168.0.1\/test.php&#8221;.<\/p>\n<p>Dever\u00e1 abrir as informa\u00e7\u00f5es do PHP.<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<h1>HTTPS<\/h1>\n<p>&nbsp;<\/p>\n<div>1. Vamos criar as chaves:<\/p>\n<p><strong># cd \/etc\/httpd\/conf<br \/>\n# openssl req -nodes -newkey rsa:2048 -keyout dominio.com.br.key -out dominio.com.br.csr<\/strong><\/p>\n<p>Sa\u00edda dever\u00e1 ser algo assim:<\/p>\n<pre>Generating a 2048 bit RSA private key\r\n.................................................+++\r\n..................+++\r\nwriting new private key to 'dominio.com.br.key'\r\n-----\r\nYou are about to be asked to enter information that will be incorporated\r\ninto your certificate request.\r\nWhat you are about to enter is what is called a Distinguished Name or a DN.\r\nThere are quite a few fields but you can leave some blank\r\nFor some fields there will be a default value,\r\nIf you enter '.', the field will be left blank.\r\n-----\r\nCountry Name (2 letter code) [AU]: &lt;&lt; <strong>[ Pais ]<\/strong>\r\nState or Province Name (full name) [Some-State]: &lt;&lt; <strong>[ Estado ]<\/strong>\r\nLocality Name (eg, city) []: &lt;&lt; <strong>[ Cidade ]<\/strong>\r\nOrganization Name (eg, company) [Internet Widgits Pty Ltd]: &lt;&lt; <strong>[ nome da empresa ]<\/strong>\r\nOrganizational Unit Name (eg, section) []: &lt;&lt; <strong>[ Parti\u00e7\u00e3o da empresa ]<\/strong>\r\nCommon Name (e.g. server FQDN or YOUR name) []: &lt;&lt; <strong>[ Seu nome ]<\/strong>\r\nEmail Address []: &lt;&lt; <strong>[ E-mail ]<\/strong>\r\n\r\nPlease enter the following 'extra' attributes\r\nto be sent with your certificate request\r\nA challenge password []: &lt;&lt; <strong>[ Enter ]<\/strong>\r\nAn optional company name []: &lt;&lt; <strong>[ Enter ]<\/strong>\r\n\r\n<\/pre>\n<p><strong># openssl x509 -req -days 365 -in dominio.com.br.csr -signkey dominio.com.br.key -out dominio.com.br.crt<br \/>\n# chmod 600 dominio*<\/strong><\/p>\n<p>2. Agora vamos ajustar o httpd.conf:<\/p>\n<p><strong># nano \/etc\/httpd\/conf\/httpd.conf<\/strong><\/p>\n<p>Ap\u00f3s a linha &#8220;Listen 80&#8221; adicione as seguintes linhas, ficando desta maneira:<\/p>\n<div class=\"codigo\">Listen 80<br \/>\n&lt;VirtualHost *:80&gt;<br \/>\nServerName dominio.com.br<br \/>\n<span class=\"comentario\"># Linha abaixo for\u00e7a a entrada da 80 para a 443 for\u00e7ando a https<\/span><br \/>\nRedirect permanent \/ https:\/\/192.168.0.1\/<br \/>\n&lt;\/VirtualHost&gt;<\/p>\n<p>&lt;VirtualHost *:443&gt;<br \/>\nServerName dominio.com.br<br \/>\nSSLCertificateFile \/etc\/httpd\/conf\/dominio.com.br.crt<br \/>\nSSLCertificateKeyFile \/etc\/httpd\/conf\/dominio.com.br.key<br \/>\nSSLEngine on<br \/>\nServerSignature On<br \/>\n&lt;FilesMatch &#8220;\\.(cgi|shtml|phtml|php)$&#8221;&gt;<br \/>\nSSLOptions +StdEnvVars<br \/>\n&lt;\/FilesMatch&gt;<br \/>\n&lt;Directory \/usr\/lib\/cgi-bin&gt;<br \/>\nSSLOptions +StdEnvVars<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;\/VirtualHost&gt;<\/p><\/div>\n<p>Retire o coment\u00e1rio da linha:<\/p>\n<p>#LoadModule ssl_module modules\/mod_ssl.so<\/p>\n<p>Ficando assim:<\/p>\n<div class=\"codigo\">LoadModule ssl_module modules\/mod_ssl.so<\/div>\n<p>3. Reinicie o servidor httpd:<\/p>\n<p><strong># systemctl restart httpd<\/strong><\/p>\n<p>Agora \u00e9 s\u00f3 acessar no seu browser &#8220;192.168.0.1&#8221; ou &#8220;localhost&#8221; que j\u00e1 ser\u00e1 redirecionado para a p\u00e1gina https.<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>APACHE &nbsp; Ambiente: Sistema:\u00a0Linux\u00a0arch 4.17.3-1-ARCH Dom\u00ednio: dominio.com.br Ip: 192.168.0.1 1. Update do sistema: # pacman -Syu 2. Instalando Apache: # pacman -S apache Habilitando e iniciando servidor Apache: # systemctl enable httpd # systemctl restart httpd<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[455,1082,1,730,830,51],"tags":[131,689,349,351,1202,260,1201,361,132],"class_list":["post-4498","post","type-post","status-publish","format-standard","hentry","category-apache2","category-centos-7-rhel-7","category-viazap","category-clusterweb","category-debian","category-linux-linuxrs","tag-apache","tag-arch-linux","tag-com","tag-e","tag-https","tag-instalando","tag-mariadb","tag-no","tag-php"],"_links":{"self":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4498"}],"version-history":[{"count":1,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4498\/revisions"}],"predecessor-version":[{"id":4499,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4498\/revisions\/4499"}],"wp:attachment":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}