Installing LAMP


#1

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/mod_unique_id.so
  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
    <html>
    <title>Server test</title>
    <body>
    <p>Hello server</p>
    </body>
    </html>
  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/mod_mpm_event.so
  • add at the bottom of the file:
    • LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
    • LoadModule php7_module modules/libphp7.so
    • 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

#2

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


#3

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


#4