Dificuldade: ★★☆☆☆
- Mesmo sendo um tutorial de baixa dificuldade, se realmente pretende fazer uso dessas ferramentas é melhor que se acostume a usar o terminal para ir se adaptando, pois haverá entre uma instalação e outra edições de arquivos para que tudo funcione a contento.
- Este tutorial orienta você na instalação e configuração do Apache, MySQL, PHP (LAMP) 2022
LAMP é o acrônimo de 'Linux, Apache, MySQL/MariaDB, PHP/Pearl/Phyton'
Testado no BigLinux | Manjaro (os dois)
Atualize o sistema
Execute o seguinte comando para isso:
sudo pacman -Syyu
Instale o Apache
Após atualizar, use o comando abaixo para instalar o Apache:
sudo pacman -S apache
Edite o arquivo /etc/httpd/conf/httpd.conf
kate /etc/httpd/conf/httpd.conf
Pesquise e comente a seguinte linha, se ainda não estiver comentada:
[...]
# LoadModule unique_id_module modules/mod_unique_id.so
[...]
Salve e feche o arquivo.
Habilite o serviço Apache para iniciar na inicialização e reinicie o serviço Apache usando os comandos:
sudo systemctl enable httpd
sudo systemctl restart httpd
Você pode verificar se o Apache está em execução ou não com o comando:
sudo systemctl status httpd
Saída de amostra:
httpd.service - Apache Web Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor
preset: disabled)
Active: active (running) since Tue 2016-02-16 13:00:18 IST; 7s ago
Main PID: 1067 (httpd)
Tasks: 82 (limit: 512)
CGroup: /system.slice/httpd.service
├─1067 /usr/bin/httpd -k start -DFOREGROUND
├─1070 /usr/bin/httpd -k start -DFOREGROUND
├─1071 /usr/bin/httpd -k start -DFOREGROUND
└─1072 /usr/bin/httpd -k start -DFOREGROUND
Feb 16 13:00:18 server systemd[1]: `Started Apache Web Server.`
Feb 16 13:00:18 server httpd[1067]: AH00558: httpd: Could not reliably
dete...ge
Hint: Some lines were ellipsized, use -l to show in full.
Apache server is ready to use.
Teste o Apache
Vamos criar uma página de amostra no diretório raiz do Apache, ou seja, /srv/http.
kate /srv/http/index.html
Adicione as seguintes linhas:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Welcome</title>
</head>
<body>
<h2>Welcome to my Web Server test page</h2>
</body>
</html>
Agora, abra seu navegador da web e navegue até:
http://localhost

Instale o MariaDB
sudo pacman -S mysql
Como você deve saber, o MariaDB agora é oficialmente a implementação padrão do MySQL no Arch Linux desde 2013. Assim, você será perguntado se deseja instalar o servidor MariaDB ou Percona, basta pressionar enter
e digitar y
e pressionar enter novamente. A seleção padrão, ou seja, MariaDB será instalada em seu BigLinux ou Manjaro.
- Exemplo abaixo do que será mostrado no terminal
[root@server ~]# pacman -S mysql
:: There are 2 providers available for mysql:
:: Repository extra
1) mariadb
:: Repository community
2) percona-server
Enter a number (default=1): `## Press Enter`
resolving dependencies...
looking for conflicting packages...
Packages (7) boost-libs-1.60.0-2 icu-56.1-2 jemalloc-4.0.4-1libmariadbclient-10.1.11-1 libxml2-2.9.3-1
mariadb-clients-10.1.11-1 mariadb-10.1.11-1
Total Download Size: 30.68 MiB
Total Installed Size: 218.10 MiB
:: Proceed with installation? [Y/n]
Você precisa inicializar o diretório de dados do MariaDB antes de iniciar o serviço. Para isso, execute:
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Em seguida, emita o seguinte comando para habilitar e iniciar o serviço MariaDB.
sudo systemctl enable mysqld
sudo systemctl start mysqld
Você pode verificar se o MariaDb está rodando ou não usando o comando:
sudo systemctl status mysqld
A saída mostra:
mysqld.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled;
vendor preset: disabled)
Active: active (running) since Tue 2016-02-16 13:19:50 IST; 44s ago
Process: 1406 ExecStartPost=/usr/bin/mysqld-post (code=exited,
status=0/SUCCESS)
Main PID: 1405 (mysqld)
Tasks: 26 (limit: 512)
CGroup: /system.slice/mysqld.service
└─1405 /usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid
Feb 16 13:19:49 server mysqld[1405]: 2016-02-16 13:19:49 139930931222400
[N...a.
Feb 16 13:19:49 server mysqld[1405]: 2016-02-16 13:19:49 139930931222400
[N...e.
Feb 16 13:19:49 server mysqld[1405]: 2016-02-16 13:19:49 139930931222400
[N...rt
Feb 16 13:19:49 server mysqld[1405]: 2016-02-16 13:19:49 139930931222400
[N...19
Feb 16 13:19:49 server mysqld[1405]: 2016-02-16 13:19:49 139930516817664
[N...ed
Feb 16 13:19:49 server mysqld[1405]: 2016-02-16 13:19:49 139930931222400
[N...d.
Feb 16 13:19:49 server mysqld[1405]: 2016-02-16 13:19:49 139930931222400
[N...'.
Feb 16 13:19:49 server mysqld[1405]: 2016-02-16 13:19:49 139930931222400
[N...s.
Feb 16 13:19:49 server mysqld[1405]: Version: '10.1.11-MariaDB-log'
socket...er
Feb 16 13:19:50 server systemd[1]: `Started MariaDB database server.`
Hint: Some lines were ellipsized, use -l to show in full.
Configurar senha do usuário root do MySQL/MariaDB
Como você deve saber, é recomendado configurar uma senha para o usuário root do banco de dados.
Execute o seguinte comando para configurar a senha do usuário root do MariaDB:
sudo mysql_secure_installation
Saída de amostra:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
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] `## Pressione Enter`
New password: `## Digite aqui senha`
Re-enter new password: `## Re-digite aqui senha`
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] `## Press 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] `## Press 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] `## Press 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] `## Press 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!
MariaDB has been installed and ready to use.
Intale o PHP
sudo pacman -S php php-apache
Após a instalação do PHP, precisamos configurar o módulo Apache PHP.
Para isso, edite o arquivo /etc/httpd/conf/httpd.conf
kate /etc/httpd/conf/httpd.conf
Encontre a seguinte linha e comente-a:
[...]
#LoadModule mpm_event_module modules/mod_mpm_event.so
[...]
Agora faça ao contrário descomente ou adicione a linha:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
Em seguida, adicione as seguintes linhas na parte inferior (onde não tiver mais nada no arquivo) do php8:
LoadModule php_module modules/libphp.so
AddHandler php-script php
Include conf/extra/php_module.conf
Salve e feche o arquivo.
- Teste o PHP
Agora crie um arquivo test.php
no diretório raiz do Apache
kate /srv/http/test.php
E nele coloque as seguintes linhas
<?php
phpinfo();
Reinicie o serviço httpd
sudo systemctl restart httpd
Abra novamente seu navegador e com o seguinte endereço http://localhost/test.php

*Final da primeira parte