Como instalar (LAMP) no CentOS 7

LAMP é a abreviação de Linux, Apache, Mysql, Php, esses são programas livres, geralmente usados para a hospedagem de sites dinâmicos.

Importante: Recomendamos que faça um backup da maquina antes de instalar os pacotes LAMP.

Adicione o repositório EPEL para instalar a versão mais recente do phpMyAdmin:

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release

Instale o editor de texto nano (Opcional):

yum -y install nano

Instalando o MariaDB

yum -y install mariadb-server mariadb

Crie links de inicialização para garantir que o software inicie ao ligar o sistema:

systemctl start mariadb.service (inicia o MariaDB)
systemctl enable mariadb.service (Cria um link de inicialização)

Para definir a senha da conta raiz do MySql, execute:

mysql_secure_installation

Ao executar o comando a cima será mostrada a seguinte linha:

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, 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): <– Pressione enter
OK, successfully used password, moving on…

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

Set root password? [Y/n]
New password: <–Insira a senha para acesso
Re-enter new password: <–Insira a senha para acesso
Password updated successfully!
Reloading privilege tables..
… Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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
… 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
… Success!

By default, MariaDB 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
– 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 
… Success!

Cleaning up…

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

Thanks for using MariaDB!

Instalando o apache no CentOS:

yum -y install httpd

Crie links de inicialização para o software iniciar junto com o sistema

systemctl start httpd.service
systemctl enable httpd.service

Para acessar o servidor é necessário liberar as portas 80 e 443.

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

Para testar se o servidor apache está funcionando, em seu navegador digite http://endereço-de-ip-do-servidor

Instalando o PHP

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Instale o yum-utils:

yum -y install yum-utils

Execute o comando:

yum update

Escolha qual versão do PHP deseja instalar e execute os comandos necessários.

PHP 5.4

yum -y install php

PHP 7.0

yum-config-manager --enable remi-php70
yum -y install php php-opcache

PHP 7.1

yum-config-manager --enable remi-php71
yum -y install php php-opcache

PHP 7.2

yum-config-manager --enable remi-php72
yum -y install php php-opcache

PHP 7.3

yum-config-manager --enable remi-php73
yum -y install php php-opcache

Ao final da instalação execute o comando a seguir para reiniciar o serviço apache:

systemctl restart httpd.service

Para testar se o PHP esta funcionando corretamente, acesse o arquivo info.php com o comando “nano /var/www/html/info.php” e insira a seguinte informação:

<?php phpinfo(); ?>

Salve o arquivo.

No navegador acesse http://ip-do-servidor/info.php

Obtendo suporte MySql em PHP.
Execute:

yum search php
yum -y install php-mysqlnd php-pdo

Instale os módulos php comuns exigido pelo CMS (opcional)

yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel

Reinicie o servidor Apache:

systemctl restart httpd.service

Recarregue a pagina http://ip-do-servidor/info.php para ver os modulo PHP.

Instalando o PhpMyadmin

yum -y install phpMyAdmin

Agora configure o PhpMyAdmin:

nano /etc/httpd/conf.d/phpMyAdmin.conf

Modifique o arquivo acrescentando “#” nas seguintes linhas

[…]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8

<IfModule mod_authz_core.c>
# Apache 2.4
# <RequireAny>             <—
# Require ip 127.0.0.1    <—
# Require ip ::1                <—
# </RequireAny>           <—
Require all granted         <— acrescente essa linha
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/>
Options none
AllowOverride Limit
Require all granted
</Directory>

[…]

Reinicie o serviço Apache

systemctl restart httpd.service

O PhpMyAdmim pode ser acessado pelo endereço http://ip-do-servidor/phpmyadmin/

Pronto o LAMP foi instalado e configurado!

Importante:Os repositorios do sistema não são de responsabilidade da Inetweb, os mesmos podem apresentar indisponibilidade ou serem alterados pelo responsaveis.

Fonte: https://www.howtoforge.com/tutorial/centos-lamp-server-apache-mysql-php/

Caso deseje conhecer mais a respeito de Clud Computing. Acesse inetweb.com.br/atendimento e entre em contato conosco ou acesse inetweb.com.br/cloud-servers

Essa Base de conhecimento é útil? Útil Não Útil 0 de 0 pessoas disseram que esse artigo foi útil.