Skip to content

Instantly share code, notes, and snippets.

@jsilverdev
Last active September 16, 2021 02:30
Show Gist options
  • Save jsilverdev/fd6dd7e61c4b975d8f403e5fb64f652d to your computer and use it in GitHub Desktop.
Save jsilverdev/fd6dd7e61c4b975d8f403e5fb64f652d to your computer and use it in GitHub Desktop.
Configurar LAMP + phpMyAdmin en Manjaro y cambiar ubicación de carpeta de Apache

Pasos para instalar LAMP + phpMyAdmin en Manjaro

  1. Actualizar manjaro
sudo pacman -Syu

Apache:

  1. Instalar Apache
sudo pacman -S apache
  1. Iniciar apache (httpd)
sudo systemctl start httpd
  1. Ir a el archivo httpd.conf
sudo nano /etc/httpd/conf/httpd.conf
  1. Buscar y comentar la siguiente línea. Guardar y cerrar
[...]
# LoadModule unique_id_module modules/mod_unique_id.so
[...]
  1. Reiniciar apache
sudo systemctl restart httpd
  1. (Opcional) Si quieres que apache se inicie al encender tu máquina usa el siguiente comando
sudo systemctl enable httpd
  1. Verifica si Apache se está ejecutando
$ sudo systemctl status httpd
httpd.service - Apache Web Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
     Active: active (running) since Wed 2021-09-15 15:33:40 -05; 1h 46min ago
   Main PID: 78033 (httpd)
      Tasks: 7 (limit: 19045)
     CGroup: /system.slice/httpd.service
             ├─78033 /usr/bin/httpd -k start -DFOREGROUND
             ├─78035 /usr/bin/httpd -k start -DFOREGROUND
             ├─78036 /usr/bin/httpd -k start -DFOREGROUND
             ├─78037 /usr/bin/httpd -k start -DFOREGROUND
             ├─78038 /usr/bin/httpd -k start -DFOREGROUND
             ├─78039 /usr/bin/httpd -k start -DFOREGROUND
             └─78043 /usr/bin/httpd -k start -DFOREGROUND

set 15 15:33:40 server systemd[1]: Started Apache Web Server.
set 15 15:33:40 server httpd[78033]: AH00558: httpd: Could not reliably determine the server's fully qua...
  • O tambien puedes usar:
$ sudo systemctl is-active httpd.service
active

MariaDB

  1. Instalar mariadb
sudo pacman -S mariadb
  1. Iniciar el directorio de datos de MariaDB, para poder iniciar el servicio
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
  1. Activa y ejecuta el servicio de MariaDB
sudo systemctl enable mariadb
sudo systemctl start mariadb
  1. Inicia la instalación
sudo mysql_secure_installation

PHP

  1. Instalar php y php-apache
sudo pacman -S php php-apache
  1. Ir a el archivo httpd.conf
sudo nano /etc/httpd/conf/httpd.conf
  • Luego buscar esta línea y comentarla
[...]
#LoadModule mpm_event_module modules/mod_mpm_event.so
[...]
  • Y descomentar o agregar esta otra línea
[...]
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
[...]
  1. Luego al final del archivo agregar estas líneas:
  • PHP 8:
LoadModule php_module modules/libphp.so
AddHandler php-script php
Include conf/extra/php_module.conf
  • PHP 7:
LoadModule php7_module modules/libphp7.so
AddHandler php7-script php
Include conf/extra/php7_module.conf

Guardar y cerrar el archivo

  1. Testear PHP
  • Crear un archivo test.php en el directorio /srv/http
sudo nano /srv/http/test.php
  • Copiar esto
<?php
phpinfo();
  • Reinicia Apache
sudo systemctl restart httpd

phpMyAdmin

  1. Instalar phpMyAdmin
sudo pacman -S phpmyadmin
  1. Editar el archivo php.ini
sudo nano /etc/php/php.ini
  • Revisar si estas lineas están comentadas y si es así descomentarlas
[...]
extension=bz2
[...]
extension=mysqli
[...]
  • Guarda y cierra el archivo
  1. Crear un archivo de config. para phpmyadmin
sudo nano /etc/httpd/conf/extra/phpmyadmin.conf
  • Agrega las siguientes líneas
Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
   DirectoryIndex index.php
   AllowOverride All
   Options FollowSymlinks
   Require all granted
</Directory>
  • Guarda y cierra el archivo
  1. Ve hacia el archivo de configuración de Apache
sudo nano /etc/httpd/conf/httpd.conf
  • Agrega la siguiente línea al final del archivo
Include conf/extra/phpmyadmin.conf
  • Guarda y cierra el archivo
  1. Reinicia Apache
sudo systemctl restart httpd
  1. Para suprimir el mensaje de error de blowfish_secret en la parte inferior ve al archivo de config. de phpmyadmin
sudo nano /etc/webapps/phpmyadmin/config.inc.php
  • Encuentra esta línea y rellena el campo vacío
$cfg['blowfish_secret'] = '`12345####***unt3xtomUyL@R$GO....`';
  • Guardar y cerrar
  1. Para suprimir el mensaje de error de TempDir ve hacia el archivo de configuración de phpmyadmin
sudo nano /etc/webapps/phpmyadmin/config.inc.php
  • Agregar esta línea al final del archivo
$cfg['TempDir'] = '/tmp/phpmyadmin';
  • Guardar y cerrar

Listo, ya tienes configurado LAMP en Manjaro

[Opcional] Cambiar carpeta por defecto (v-hosts)

Para cambiar la carpeta /srv/http por defecto por una que este en /home/<usuario>/www por ejemplo, debes hacer lo siguiente:

  1. Crear la carpeta
mkdir ~/www
  1. Cambiar el grupo de la carpeta al de http
sudo chown <usuario>:http ~/www
  1. Agregar al usuario http al grupo de tu usuario
sudo usermod -a -G <usuario> http
  1. Modificar los permisos de tu carpeta /home/<usuario>
sudo chmod 750 /home/<usuario>
  1. Ir al archivo de configuración de Apache
sudo nano /etc/httpd/conf/httpd.conf
  1. Buscar y descomentar la siguiente línea:
[...]
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
[...]
  1. Buscar y descomentar esta otra línea
[...]
LoadModule rewrite_module modules/mod_rewrite.so
[...]
  • Guardar y cerrar el archivo
  1. Ir hacia el archivo de http-vhost.conf
sudo nano /etc/httpd/conf/extra/httpd-vhosts.conf
  1. Comentar o remplazar el contenido del archivo con las siguientes líneas:
<VirtualHost *:80>
    ServerAdmin example@email.com
    DocumentRoot "/home/<usuario>/www"
    ServerName localhost
    ErrorLog "/var/log/httpd/server-error.log"
    CustomLog "/var/log/httpd/server-access.log" common
    <Directory /home/<usuario>/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    RewriteEngine on
</VirtualHost>
  • Guarda y cierra el archivo
  1. Comprobar que todo este correcto
apachectl configtest
  1. Reiniciar Apache
sudo systemctl restart httpd

Links:

https://forum.manjaro.org/t/howto-install-apache-mariadb-mysql-php-lamp/13000

https://gist.github.com/51LV3R258/fd6dd7e61c4b975d8f403e5fb64f652d

https://forum.manjaro.org/t/documentroot-403-forbidden/30023

https://wiki.archlinux.org/title/phpMyAdmin

https://linuxize.com/post/how-to-add-user-to-group-in-linux/

https://forum.manjaro.org/t/apache-virtual-host/46115

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-arch-linux

https://www.tecmint.com/forbidden-you-dont-have-permission-to-access-on-this-server-error/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment