SparkTwo LAMP Stack Installation

Installing a local web server for ease of development with WebGL / Three.js / Collada / GLTF / Blender etc. projects. I will be following this blog article.

https://www.ubuntumint.com/install-lamp-archlinux/

Install Apache

$ yay -Syu

Update the system.

Here I used the yay pacman wrapper since it is the default on this system. This is in part due to dependence on NVidia driver version control for compatability with NVidia GTX GeForce Titan X cards. For the rest of this installation, that convention will be assumed.

$ yay -Syu apache

Next the status of the Apache server daemon must be enabled, started and status returned.

$ sudo systemctl start httpd
$ sudo systemctl enable httpd
$ sudo systemctl status httpd

Install PHP

The following command installs PHP and its Apache module.

$ yay -S php php-apache

Install MySQL

You then install MySQL package using the package manager, like so:

$ yay -S mysql

In SparkTwo’s case, the required package is already installed. Start and enable the mysqld service.

$ sudo systemctl start mysqld
$ sudo systemctl enable mysqld
$ sudo systemctl status mysqld

As mentioned in the article cited above, errors were encountered while attempting to enable and start the mysql daemon. The procedure follows:

$ su
# cd /var/lib/mysql
# rm -r *
# mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Secure MySQL

Secure your MySQL installation by running the following security script.

$ sudo mysql_secure_installation

Connect to your MySQL database as the root user.

$ mysql -u root -p

Configure Apache

Open the configuration file.

$ sudo gvim /etc/httpd/conf/httpd.conf

Search for the lines starting with LoadModule mpm_prefork_ and uncomment it. Also, make sure to comment out:

#LoadModule mpm_event_module modules/mod_mpm_event.so

Also, at the bottom of the file, add the following lines:

LoadModule php_module modules/libphp.so
AddHandler php-script php
Include conf/extra/php_module.conf

Restart Apache webserver to apply configuration changes.

$ sudo systemctl restart httpd

Testing Apache

The counterpart to public_html on the local file system is now:

/srv/http

Just create a basic index.html file in this directory and navigate on your browser to localhost

To test if Apache serves PHP scripts, create and edit the following file:

$ sudo gvim /srv/http/test.php

And add the following PHP code.

<?php
phpinfo()
?>

Install PhpMyAdmin

PhpMyAdmin is an open-source web-based database management tool for MySQL/MariaDB.

$ yay -S phpmyadmin

Open the file /etc/php/php.ini and uncomment the lines extension=mysqli, extension=pdo_mysql and extension=iconv by removing the semicolon ; preceding them.

$ sudo gvim /etc/php/php.ini

Now set up Apache to work with phpmyadmin by creating phpmyadmin’s main configuration file.

$ sudo gvim /etc/httpd/conf/extra/phpmyadmin.conf

Populate the file with content like so:

Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
  DirectoryIndex  index.php
  AllowOverride All
  Options FollowSymlinks
  Require all granted
</Directory>

Next include the path to this configurtaion file on Apache’s main configuration file.

$ sudo gvim /etc/httpd/conf/httpd.conf

Add the following line at the bottom.

Include conf/extra/phpmyadmin.conf

Then restart the Apache web service.

$ sudo systemctl restart httpd

Now access the PhpMyAdmin from the browser.

http://localhost/phpmyadmin

References

  1. http://ubuntumint.com/install-lamp-archlinux/ – Source article for SparkTwo installation

Leave a Reply

Your email address will not be published. Required fields are marked *