segunda-feira, 22 de abril de 2013

Como instalar php apache mysql phpmyadmin no CentOs 6

Como instalar php apache mysql phpmyadmin no CentOs 6

Este tutorial irá explicar passo a passo para vocês como instalar
o apache, mysql, php e phpmyadmin na plataforma Linux CentOs 6.

1) Vamos deixar primeiramente tudo atualizado e corrigido:

[root@beagleleo ~]# yum clean all && yum update -y

2) instalando o mysql:

[root@beagleleo ~]# yum install mysql mysql-server -y

3) Devemos aplicar pemrissões para que o mysql (serviço) carregue e inicie no momento do boot:

[root@beagleleo ~]# chkconfig --levels 235 mysqld on

4) E iniciar o sistema de banco de dados:

[root@appunixlabs ~]# /etc/init.d/mysqld start

5) Para ajustar as senhas do mysql devemos usar o seguinte comando:

[root@beagleleo ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Enter para confirmar que quer mudar a senha de root

New password: Coloque a nova senha de root

Re-enter new password: Confirme a nova senha de root
Password updated successfully!

Reloading privilege tables..
… Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Pressione Enter para invalidar acessos anônimos
… Success!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Pressione Enter para Remover o acesso remoto ao banco de dados
… Success!

By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Pressione Enter para remover a base de dados de testes
- Dropping test database…
… Success!

- Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Pressione enter para que o flushprivileges opere imediatamente
e valide as mudanças
… Success!

Cleaning up…
All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

6) Agora iremos instalar o apache com o seguinte comando:

[root@beagleleo ~]# yum install httpd -y

7) Devemos deixar o apache com a mesma configuração de serviços do mysql,
iniciando assim que o boot for concluido:

[root@beagleleo ~]# chkconfig –-levels 235 httpd on

8) E para iniciarmos o serviço (apache):

[root@beagleleo ~]# /etc/init.d/httpd start

Para acessar o servidor para garantir que o mesmo está operando 100% em
nosso sistema operacional, caso o servidor esteja em rede podemos acessa-lo através de seu
respectivo ip. Supondo que o ip deste server seja 192.168.0.1, para que meu desktop em rede
confirme se o apache está ok podemos abrir o navegador e colocar o seguinte endereço: http://192.168.0.1
Uma página do apache sob CentOs será exibida mostrando que tudo está bem.

9) Vamos instalar o php

[root@beagleleo ~]# yum install php

10) Devemos reiniciar o apache para garantir que a integração do interpretador esteja ok:

[root@beagleleo ~]# /etc/init.d/httpd restart

11) Nessa pasta (/var/www/html) crie um arquivo chamado index.php, abra-o com o "vim" ou crie-o com echo e
    dentro dele coloque uma instrução, veja o passo a passo:

[root@beagleleo ~]# echo "<?php phpinfo(); ?>" >> index.php

12) Supondo que o ip deste servidor seja 192.168.0.1, para que meu desktop em rede confirme se o apache
    está ok, podemos abrir o navegador e colocar o seguinte endereço: http://192.168.0.1/index.php
    Deverão ser exibidas todas as extensões e variáveis globais predefinidas na instalação nesta página
    acessada.

13) Agora precisamos fazer com que o mysql seja integrado com o php, para isso iremos executar o seguinte comando:

[root@beagleleo ~]# yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc
php-pear php-xml php-xmlrpc -y

14) E para garantir que tudo está ok e com a integração perfeita com o nosso container vamos
executar o seguinte:

[root@beagleleo ~]# /etc/init.d/httpd restart

15) Agora a instalação do phpmyadmin.

Para isto iremos fazer o seguinte: Instalar o repositório RPMForge que é
melhor para este fim e em seguida instalar os pacotes dele.

[root@beagleleo ~]# rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

16) Se seu sistema for 64 bits execute:

[root@beagleleo ~]# yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

17) Se seu sistema for 32 bits execute:

[root@beagleleo ~]# yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

18) Agora sim, vamos instalar o phpmyadmin:

[root@beagleleo ~]# yum install phpmyadmin -y

19) Precisamos agora criar aliases para que o phpmyadmin seja acessível sem qualquer
    problema junto ao apache, para isto iremos mudar o seguinte configuração:
 
/etc/httpd/conf.d/phpmyadmin.conf

20) e iremos mudar o seguinte: Comentar as linhas abaixo (caso não estejam comentadas):

#<Directory "/usr/share/phpmyadmin">
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#</Directory>

21) E garantir que os aliases estejam conforme o exemplo abaixo:

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

22) Feito isso devemos garantir que nosso phpmyadmin faça validação por HTTP e não
    por meio de cookies, devemos editar o seguinte conf:

/usr/share/phpmyadmin/config.inc.php e mudar a seguinte linha:

/* Authentication type */

$cfg['Servers'][$i]['auth_type'] = ‘http’;

23) Em http fica cookie, troque cookie por http para evitar dor de cabeça.
    Depois de salvar o arquivo faça com que tudo esteja validado reiniciando o apache:

[root@beagleleo ~]# /etc/init.d/httpd restart

Supondo que o ip deste server seja 192.168.0.1, para que meu desktop em rede confirme se o
apache está ok e podemos abrir o navegador e colocar o seguinte endereço:

http://192.168.0.1/phpmyadmin

Tudo funcionando?


Fontes:
Centos: http://centos.org/
Apache: http://apache.org
Mysql: http://mysql.com/
PhpMyadmin: http://www.phpmyadmin.net/home_page/index.php
PHP: http://www.php.net/
Linux: http://en.wikipedia.org/wiki/Linux
RPMForge: http://rpmrepo.net/RPMforge
How to forge: http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-centos-6.0-lamp
Tutorial: http://www.appunix.com.br/howto/linux/como-instalar-php-apache-mysql-phpmyadmin-no-centos-6/



Nenhum comentário:

Postar um comentário