Search code examples
phpnginxlaravel-valetcaddy

Laravel/Valet, how to run a project with php < 7


So I'm working on an old project which need php5.6 to work.

Since I'm tired of Homestead I've decided to swith to Laravel/Valet however Valet is running with PHP 7.

I've read from that discussion that a way of configure what I want is to use Caddy But when I look into ~/.valet folder I do not see any Caddy folder but instead I see Nginx.

So has Valet change his server configuration in this case shall I create a file in Nginx to specify my configuration OR do I have to install Caddy myself and if so How do I tell Valet to use Caddy?


Solution

  • I use sphp to switch PHP on macOS sierra like

    $ sphp 56
    
    $ sphp 70
    
    $ sphp 71
    

    To switch valet PHP just follow 3 steps

    1. valet stop

    2. sphp [56|70|71|72]

    3. valet start

    If you find an NGINX error, check the logs at:

    • /usr/local/var/log/php-fpm.log
    • /usr/local/var/log/nginx/error.log

    If PHP fpm quits, you must match your PHP version used to install valet, compare the version config with other. To compare 7.0 and 5.6:

    • /usr/local/etc/php/7.0/php-fpm.d/www.conf
    • /usr/local/etc/php/5.6/php-fpm.d/www.conf

    The important configs for valet are

    1. Unix user/group of processes

      user = _www
      group = _www
      
    2. The address on which to accept FastCGI requests.

      listen = /Users/[your_mac_user_name]/.valet/valet.sock
      
    3. Set permissions for unix socket

      listen.owner = _www
      listen.group = _www
      listen.mode = 0777