Installing LAMP

It’s always been a pain in the neck for me to install and configure Apache, MySQL, PHP stack but today I found an easy way to do it. Could be useful to someone else. It’s the install plus configuring your home directory to serve html and php files.

Step by step guide

  1. Install Apache: sudo pacman -S apache
  2. Configure Apache:
  • sudo nano /etc/httpd/conf/httpd.conf
  • uncomment #LoadModule unique_id_module modules/
  1. Start Apache: sudo systemctl start httpd
  2. Check if Apache is running: sudo systemctl status httpd
  3. Create a test HTML file:
    sudo nano /srv/http/index.html
    <title>Server test</title>
    <p>Hello server</p>
  4. Load it: http://localhost/
  5. Install MySQL: sudo pacman -S mysql
  6. Enter 1 for mariadb
  7. Start MySQL: sudo systemctl mysql
  8. Run MySQL secure installation: sudo mysql_secure_installation
  9. Configure MySQL: sudo mysql -u root -p
  10. Install PHP: sudo pacman -S php php-apache
  11. Enable PHP: sudo nano /etc/httpd/conf/httpd.conf
  • comment out #LoadModule mpm_event_module modules/
  • add at the bottom of the file:
    • LoadModule mpm_prefork_module modules/
    • LoadModule php7_module modules/
    • AddHandler php7-script php
    • Include conf/extra/php7_module.conf
  1. Test PHP:
    sudo nano /srv/http/test.php
    <?php phpinfo(); ?>
  2. Restart Apache: sudo systemctl restart httpd
  3. Load test.php: http://localhost/test.php
  4. Create ~/public_html directory in your home directory: mkdir public_html
  5. Set permissions to allow Apache access:
  • chmod o+x ~
  • chmod o+x ~/public_html
  • chmod -R o+r ~/public_html
  1. Restart Apache: sudo systemctl restart httpd
  2. You can load HTML and PHP files now from http://localhost/~user

Thx for the tuto in there @gorki , might be useful to other members !

1 Like

Good tip, this will definitely help! :+1:

1 Like