Skip to content

Local Dev with LAMP setup

Aidin Niavarani edited this page Feb 4, 2021 · 1 revision

Piecewise installation of all the individual programs needed to run the Tapestry local development server on Arch Linux:

MariaDB

MariaDB is the 'drop-in' replacement for mySQL on Linux. It's open source and is far better maintained for the platform. Reference

  1. Install mariadb from the official repositories with pacman -S mariadb
  2. Run initial table setup with mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
  3. Enable and start mariadb.service with systemctl enable mariadb && systemctl start mariadb
  4. Login to the database service with the default root account (no password) mysql -u root -p
  5. Create a user for use with Wordpress with:
CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpresspass';
GRANT ALL PRIVILEGES ON mysql.* TO 'wordpress'@'localhost';
FLUSH PRIVILEGES;

Apache

Apache is the industry standard for web-servers and is the robust core of the local dev environment. Reference

  1. Install apache from the official repositories with pacman -S apache
  2. Enable and start the apache httpd.service with systemctl enable httpd && systemctl start httpd
  3. Verify the service is running correctly by loading localhost in your web browser and checking for the basic index page

By default, Apache will serve the files stored in the srv/http/ directory

PHP-FPM

A PHP process manager that allows Apache to process and serve PHP files. Reference

  1. Install php-fpm from the official repositories with pacman -S php-fpm
  2. Navigate to your Apache configuration file httpd.conf (located at /etc/httpd/conf/httpd.conf by default) and place the following lines at the top
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
Include conf/extra/php-fpm.conf
  1. Navigate to the extra configuration file directory extra (located at /etc/httpd/conf/extra/ by default) and create a new file php-fpm.conf with the content:
DirectoryIndex index.php index.html
<FilesMatch \.php$>
    SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
</FilesMatch>
  1. Edit the php.ini file (located at /etc/php/php.ini by default) to allow connection to mySQL (MariaDB) by uncommenting the lines (At line 923 and 927 for PHP 7):
extension=mysqli
extension=pdo_mysql
  1. Enable and start the PHP-FPM service with systemctl enable php-fpm && systemctl start php-fpm
  2. Restart the Apache httpd.service with systemctl restart httpd

Wordpress

  1. Download the Wordpress source from the official website
  2. Make a directory named wordpress at /srv/http/
  3. Extract the source zip to /srv/http/wordpress/
  4. Begin the Wordpress setup by navigating to http://localhost/wordpress in your web browser
  5. Using the information from the MariaDB setup, fill in form with:
Database Name: mysql
Username: wordpress
Password: wordpresspass
  1. Follow remaining instructions to setup Wordpress as usual
  2. After Wordpress is setup, we should increase the file upload size limit in default PHP. Edit the following lines in your php.ini: upload_max_filesize = 512M and post_max_size = 128M

proFTPd

proFTPd allows the use of FTP to connect to your locally hosted fileserver, aka your computer. Wordpress uses this to make file modifications to its own directory. Reference

  1. Install proFTPd from the AUR using your helper of choice (yay, aura etc)
  2. Run the proFTPd setup with sudo proftpd
  3. Enable and start the service with systemctl enable proftpd && systemctl start proftpd
  4. You can test your connection by running the default ftp tool and entering your local user and password

Wordpress Setup

  1. Clone the tapestry-wp repository into /srv/http/wordpress/wp-contents/plugins/
  2. Follow setup instructions in tapestry-wp/templates/vue/README
  3. Enter the Wordpress dashboard, open the plugins menu on the side and press 'Activate' on the Tapestry plugin
  4. From the plugins menu, press 'Add New' at the top and search the store for H5P, download, install and activate it
  5. Get the GravityForms and GF-Image-Choice zip files and API keys from Asana
  6. From the 'Add New Plugins' Menu, press 'Upload Plugins' and install each ZIP individually
  7. When prompted, enter your ftp credentials (local user and password)
  8. If you get an 'Uploads Directory' permission error, navigate to /srv/http/wordpress/wp-content/ and run
mkdir uploads
chmod 664 uploads
  1. Enter the API keys on the Plugins menu
  2. The last Wordpress setting that requires a change is the Post URL scheme. To change this and allow us to browse to posts, we need to create a .htaccess file in the wordpress directory and give it the proper permissions such that the wp-admin settings panel can make changes to it. Navigate to /srv/http/wordpress/ and enter
touch .htaccess
chmod 664 .htaccess
  1. Enable the mod_rewrite module in your Apache httpd.conf by uncommenting the line LoadModule rewrite_module modules/mod_rewrite.so
  2. Allow url override by the .htaccess file by replacing all instances of AllowOverride none with AllowOverride all, all default instances are within <Directory /> ... </ Directory> tags
  3. Go to the Wordpress admin dashboard, go to Settings > Hyperlinks and pick the "postname" option, then save

General Debugging Tips

  1. If a change doesn't appear to be having an effect, make sure you've restarted all related services with systemctl. Sometimes the restart command doesn't work as intended, and you should try systemctl stop and systemctl start
  2. There are well documented issues with Apache and permissions, I recommend reading this StackOverflow post for reference if you run into any such issues
  3. There are alternatives for a lot of the technologies used and listed here, such as a number of good mySQL replacements, FTP packages and PHP workarounds for Apache. If one technology is posing a lot of issues, reach the Arch wiki for suitable replacements and try that.

External Links Setup

Follow the steps here.