Installing and configuring php on arch linux

Posted on Sun 28 August 2016 in posts

Installing and configuring php on arch linux

  • Install php sudo pacman -S php php-fpm php-mcrypt
  • Configure timezone in /etc/php/php.ini with date.timezone = America/Denver
  • Install and configure mariaDB
sudo pacman -S mariadb
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

# uncomment the following lines from /etc/php/php.ini
  • install composer with sudo pacman -S composer
  • install valet
composer global require jmarcher/valet-linux
  • add composer bin to path by adding the following line to ~/.zshrc export PATH=~/.config/composer/vendor/bin:$PATH

Issues with installing valet on arch linux

  1. dnsmasq does not work correctly ( with an error for ERR_ICANN_NAME_COLLISION create the file /etc/resolv.conf.head and add nameserver then remake the resolv.conf file by running sudo resolvconf -u

  2. enable the dnsmasq service

sudo systemctl start dnsmasq.service
sudo systemctl enable dnsmasq.service
  1. valet-linux config has incorrect values for php, fpm, and fpm caddy file should look like(~/.config/composer/vendor/jmarcher/valet-linux/config) :
function get_config($value)
    $config = [
        // PHP binary path
        'php-bin' => '/usr/bin/php',

        // Latest PHP
        'php-latest'  => 'php',
        'fpm-service' => 'php-fpm',
        'fpm-config'  => '/etc/php/php-fpm.d/www.conf',

        // Caddy/Systemd
        'systemd-caddy'     => '/lib/systemd/system/caddy.service',
        'systemd-caddy-fpm' => '/var/run/php-fpm.sock',

        // PHP 5.6
        'php-56'        => 'php5.6',
        'fpm56-service' => 'php5.6-fpm',
        'fpm56-config'  => '/etc/php/5.6/php-fpm.conf',

        // PHP 5.5
        'php-55'        => 'php5.5',
        'fpm55-service' => 'php5.5-fpm',
        'fpm55-config'  => '/etc/php/5.5/php-fpm.conf',

    return $config[$value];
  • install valet valet install and after it completes update the Caddyfile at ~/.valet/Caddyfile to make sure that it is loooking for the correct php-fpm sock (this was missing the php-fpm directory)
import /home/username/.valet/Caddy/*

:80 {
    fastcgi / /var/run/php-fpm/php-fpm.sock php {
        index server.php

    rewrite {
        to /server.php?{query}
  • install laravel composer global require "laravel/installer"

  • create new laravel project laravel new project_name

  • enable the php-fpm service

  • link the project with valet valet link project_name

Now you can visit to see the site

setting up homestead

sudo pacman -S vagrant virtualbox virtualbox-host-modules-arch
vagrant box add laravel/homestead
git clone Homestead
sudo pacman -S net-tools # fixes port forwarding

add host to hosts file "" >> /etc/hosts

install composer sudo pacman -S composer composer install within project directory artisan migrate copy example.env to .env artisan key:generate