{"id":303,"date":"2012-12-19T22:56:34","date_gmt":"2012-12-19T22:56:34","guid":{"rendered":"http:\/\/eurotigroup.com.br\/blog\/?p=303"},"modified":"2012-12-19T22:56:34","modified_gmt":"2012-12-19T22:56:34","slug":"como-instalar-php-apache-mysql-phpmyadmin-no-centos-6","status":"publish","type":"post","link":"https:\/\/eurotigroup.com.br\/blog\/como-instalar-php-apache-mysql-phpmyadmin-no-centos-6.html","title":{"rendered":"Como instalar php apache mysql phpmyadmin no Centos 6"},"content":{"rendered":"<p>Ol\u00e1 pessoal, como voc\u00eas sabem somos fan\u00e1ticos pelo ambiente LAMP e agora iremos colocar para voc\u00eas um how to simples por\u00e9m funcional de como instalar o apache, mysql, php e phpmyadmin na plataforma CentOs 6.<\/p>\n<p>Vamos come\u00e7ar deixando tudo atualizado e corrigido:<\/p>\n<p><strong>[root@appunixlabs ~]# yum clean all &amp;&amp; yum update -y<\/strong><\/p>\n<p>Agora vamos instalar o mysql:<\/p>\n<p><strong>[root@appunixlabs ~]# yum install mysql mysql-server -y<\/strong><\/p>\n<p>Devemos dar pemriss\u00f5es para que o mysql (servi\u00e7o) carregue no momento do boot:<\/p>\n<p><strong>[root@appunixlabs ~]# chkconfig \u2013levels 235 mysqld on<\/strong><\/p>\n<p>E em seguida iniciar o sistema de banco de dados:<\/p>\n<p><strong>[root@appunixlabs ~]# \/etc\/init.d\/mysqld start<\/strong><\/p>\n<p>Para setarmos as senhas de mysql devemos usar o seguinte comando:<\/p>\n<p><strong>[root@appunixlabs ~]# mysql_secure_installation<\/strong><\/p>\n<p>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL<br \/>\nSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!<\/p>\n<p>In order to log into MySQL to secure it, we\u2019ll need the current<br \/>\npassword for the root user. If you\u2019ve just installed MySQL, and<br \/>\nyou haven\u2019t set the root password yet, the password will be blank,<br \/>\nso you should just press enter here.<\/p>\n<p>Enter current password for root (enter for none):<br \/>\nOK, successfully used password, moving on\u2026<\/p>\n<p>Setting the root password ensures that nobody can log into the MySQL<br \/>\nroot user without the proper authorisation.<\/p>\n<p>Set root password? [Y\/n] Enter para confirmar que quer mudar a senha de root<br \/>\nNew password: Coloque a nova senha de root<br \/>\nRe-enter new password: Confirme a nova senha de root<br \/>\nPassword updated successfully!<br \/>\nReloading privilege tables..<br \/>\n\u2026 Success!<\/p>\n<p>By default, a MySQL installation has an anonymous user, allowing anyone<br \/>\nto log into MySQL without having to have a user account created for<br \/>\nthem. This is intended only for testing, and to make the installation<br \/>\ngo a bit smoother. You should remove them before moving into a<br \/>\nproduction environment.<\/p>\n<p>Remove anonymous users? [Y\/n] Pressione Enter para invalidar acessos an\u00f4nimos<br \/>\n\u2026 Success!<\/p>\n<p>Normally, root should only be allowed to connect from \u2018localhost\u2019. This<br \/>\nensures that someone cannot guess at the root password from the network.<\/p>\n<p>Disallow root login remotely? [Y\/n] Pressione Enter para Remover o acesso remoto ao banco de dados<br \/>\n\u2026 Success!<\/p>\n<p>By default, MySQL comes with a database named \u2018test\u2019 that anyone can<br \/>\naccess. This is also intended only for testing, and should be removed<br \/>\nbefore moving into a production environment.<\/p>\n<p>Remove test database and access to it? [Y\/n] Pressione Enter para remover a base de dados de testes<br \/>\n&#8211; Dropping test database\u2026<br \/>\n\u2026 Success!<br \/>\n&#8211; Removing privileges on test database\u2026<br \/>\n\u2026 Success!<\/p>\n<p>Reloading the privilege tables will ensure that all changes made so far<br \/>\nwill take effect immediately.<\/p>\n<p>Reload privilege tables now? [Y\/n] Pressione enter para que o flushprivileges opere imediatamente e valide as mudan\u00e7as<br \/>\n\u2026 Success!<\/p>\n<p>Cleaning up\u2026<\/p>\n<p>All done! If you\u2019ve completed all of the above steps, your MySQL<br \/>\ninstallation should now be secure.<\/p>\n<p>Thanks for using MySQL!<\/p>\n<p><strong>[root@appunixlabs ~]#<\/strong><\/p>\n<p>Agora vamos instalar o apache com o seguinte comando:<\/p>\n<p><strong>[root@appunixlabs ~]# yum install httpd -y<\/strong><\/p>\n<p>Agora devemos deixar o apache com a mesma ess\u00eancia de servi\u00e7os do mysql, operando assim que o boot for realizado:<\/p>\n<p><strong>[root@appunixlabs ~]# chkconfig \u2013levels 235 httpd on<\/strong><\/p>\n<p>E para iniciarmos o bich\u00e3o (apache):<\/p>\n<p><strong>[root@appunixlabs ~]# \/etc\/init.d\/httpd start<\/strong><\/p>\n<p>Se quisermos acessar o server para garantir que o mesmo est\u00e1 operando fil\u00e9 em nosso sistema operacional, caso o server esteja em rede podemos acessa-lo atrav\u00e9s de seu respectivo ip. Pressupondo que o ip deste server seja 10.0.0.1, para que meu pc em rede confirme se o apache est\u00e1 fino podemos abrir nosso navegador e colocar o seguinte endere\u00e7o: http:\/\/10.0.0.1<br \/>\nUma p\u00e1gina do apache sob CentOs ser\u00e1 exibida mostrando que tudo est\u00e1 fil\u00e9.<\/p>\n<p>Vamos agora instalar o php<\/p>\n<p><strong>[root@appunixlabs ~]# yum install php<\/strong><\/p>\n<p>Devemos reiniciar o apache para garantir que a integra\u00e7\u00e3o do interpretador esteja 100% eficaz:<\/p>\n<p><strong>[root@appunixlabs ~]# \/etc\/init.d\/httpd restart<\/strong><\/p>\n<p>Aonde fica o danado do path do php em meu sistema operacional Centos???<br \/>\nCalma, fique tranquilo, tudo est\u00e1 situado em \/var\/www\/html, e para provar que sua instala\u00e7\u00e3o ficou fil\u00e9 fa\u00e7a o seguinte:<br \/>\nNessa pasta crie um arquivo chamado index.php, abra-o com o vim ou crie-o com echo e dentro dele coloque uma instru\u00e7\u00e3o, veja o passo a passo:<\/p>\n<blockquote><p><code><strong>[root@appunixlabs ~]# echo \"&lt;?php phpinfo(); ?&gt;\" &gt;&gt; index.php<\/strong><\/code><\/p><\/blockquote>\n<p>Pressupondo que o ip deste server seja 10.0.0.1, para que meu pc em rede confirme se o apache est\u00e1 fino podemos abrir nosso navegador e colocar o seguinte endere\u00e7o: http:\/\/10.0.0.1\/index.php<\/p>\n<p>Dever\u00e3o ser exibidas todas as extens\u00f5es e vari\u00e1veis globais predefinidas na instala\u00e7\u00e3o nesta p\u00e1gina acessada.<\/p>\n<p>Agora precisamos fazer com que o mysql esteja integrado com o php, para isso iremos rodar o seguinte comando:<\/p>\n<p><strong>[root@appunixlabs ~]# yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc -y<\/strong><\/p>\n<p>E para garantir que tudo est\u00e1 fil\u00e9 e com integra\u00e7\u00e3o perfeita com nosso container vamos rodar o seguinte:<\/p>\n<p><strong>[root@appunixlabs ~]# \/etc\/init.d\/httpd restart<\/strong><\/p>\n<p>Precisamos fechar com chave de ouro agora no ponto de instala\u00e7\u00e3o fo phpmyadmin.<br \/>\nPara isto devemos fazer o seguinte-&gt; Instalar o reposit\u00f3rio RPMForge que \u00e9 simplesmente punk e em seguida instalar os pacotes vindouros dele. Vamos por a m\u00e3o na massa?<\/p>\n<p><strong>[root@appunixlabs ~]# rpm \u2013import http:\/\/dag.wieers.com\/rpm\/packages\/RPM-GPG-KEY.dag.txt<\/strong><\/p>\n<p><strong>Se seu sistema for 64 bits rode:<\/strong><\/p>\n<p><strong>[root@appunixlabs ~]# yum install http:\/\/pkgs.repoforge.org\/rpmforge-release\/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm<\/strong><\/p>\n<p><strong>Se seu sistema for 32 bits rode:<\/strong><\/p>\n<p><strong>[root@appunixlabs ~]# yum install http:\/\/pkgs.repoforge.org\/rpmforge-release\/rpmforge-release-0.5.2-2.el6.rf.i686.rpm<\/strong><\/p>\n<p>Agora vamos instalar o phpmyadmin:<\/p>\n<p><strong>[root@appunixlabs ~]# yum install phpmyadmin -y<\/strong><\/p>\n<p>Precisamos agora criar aliases para que o phpmyadmin seja acess\u00edvel sem qualquer transtorno junto ao apache, para isto devemos mudar o seguinte conf-&gt;\u00a0<strong>\/etc\/httpd\/conf.d\/phpmyadmin.conf<\/strong>\u00a0e devemos mudar o seguinte, comentar as linhas abaixo (caso n\u00e3o estejam comentadas):<\/p>\n<blockquote>\n<pre>#&lt;Directory \"\/usr\/share\/phpmyadmin\"&gt;\r\n#  Order Deny,Allow\r\n#  Deny from all\r\n#  Allow from 127.0.0.1\r\n#&lt;\/Directory&gt;<\/pre>\n<\/blockquote>\n<p><code><br \/>\n<\/code><\/p>\n<p>E garantir que os aliases estejam conforme os abaixo dessa linha:<br \/>\n<code><br \/>\nAlias \/phpmyadmin \/usr\/share\/phpmyadmin<br \/>\nAlias \/phpMyAdmin \/usr\/share\/phpmyadmin<br \/>\nAlias \/mysqladmin \/usr\/share\/phpmyadmin<\/code><\/p>\n<p>Feito isso devemos garantir que nosso phpmyadmin fa\u00e7a valida\u00e7\u00e3o por HTTP e n\u00e3o por meio de cookies, devemos editar o seguinte conf<strong>\/usr\/share\/phpmyadmin\/config.inc.php<\/strong>\u00a0e mudar a seguinte linha:<\/p>\n<p>\/* Authentication type *\/<br \/>\n<strong>$cfg[&#8216;Servers&#8217;][$i][&#8216;auth_type&#8217;] = \u2018http\u2019;<\/strong><\/p>\n<p>Em http fica cookie, troque cookie por http para evitar dor de cabe\u00e7a.<\/p>\n<p>Depois de salvar o arquivo fa\u00e7a com que tudo esteja validado reiniciando o apache:<\/p>\n<p><strong>[root@appunixlabs ~]# \/etc\/init.d\/httpd restart<\/strong><\/p>\n<p>Pressupondo que o ip deste server seja 10.0.0.1, para que meu pc em rede confirme se o apache est\u00e1 fino podemos abrir nosso navegador e colocar o seguinte endere\u00e7o: http:\/\/10.0.0.1\/phpmyadmin<\/p>\n<p>Tudo ok?<\/p>\n<p>&nbsp;<\/p>\n<p>Fonte:\u00a0http:\/\/www.appunix.com.br\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ol\u00e1 pessoal, como voc\u00eas sabem somos fan\u00e1ticos pelo ambiente LAMP e agora iremos colocar para voc\u00eas um how to simples por\u00e9m funcional de como instalar o apache, mysql, php e phpmyadmin na&#8230;<\/p>\n","protected":false},"author":1,"featured_media":304,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-303","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server-dedicado-vps"],"_links":{"self":[{"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/posts\/303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/comments?post=303"}],"version-history":[{"count":2,"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/posts\/303\/revisions"}],"predecessor-version":[{"id":306,"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/posts\/303\/revisions\/306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/media\/304"}],"wp:attachment":[{"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/media?parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/categories?post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eurotigroup.com.br\/blog\/wp-json\/wp\/v2\/tags?post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}