In attempting to replicate our production servers on my local machine I have created a 'Directory Alias' in Homestead's VirtualHost conf. However, regardles of the many settings I try from various Stackoverflow posts, I keep getting the same 404 not found response in the browser. Hoping someone can help me troubleshoot this?
In Homestead I have swapped Nginx for Apache and restructured the location of the server root and project files to match our production servers. Here is my Homestead.yaml file:
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /Users/johno/vhosts/homestead.client1.co.uk
to: /srv/www/vhosts/homestead.client1.co.uk
sites:
- map: homestead.client1.co.uk
to: /srv/www/vhosts/homestead.client1.co.uk/public
type: apache
databases:
- project_two
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
And here is my vhosts file:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName homestead.client1.co.uk
ServerAlias www.homestead.client1.co.uk
DocumentRoot /srv/www/vhosts/homestead.client1.co.uk/public
<Directory /srv/www/vhosts/homestead.client1.co.uk/public>
AllowOverride All
Require all granted
</Directory>
# code added
Alias /project-one /srv/www/vhosts/homestead.client1.co.uk/project-one/public
<Directory "/srv/www/vhosts/homestead.client1.co.uk/project-one/public">
Options None
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
# code added
<IfModule mod_fastcgi.c>
AddHandler php7.3-fcgi .php
Action php7.3-fcgi /php7.3-fcgi
Alias /php7.3-fcgi /usr/lib/cgi-bin/php7.3
FastCgiExternalServer /usr/lib/cgi-bin/php7.3 -socket /var/run/php/php7.3-fpm.sock -pass-header Authorization
</IfModule>
<IfModule !mod_fastcgi.c>
<IfModule mod_proxy_fcgi.c>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/var/run/php/php7.3-fpm.sock|fcgi://localhost"
</FilesMatch>
</IfModule>
</IfModule>
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/homestead.client1.co.uk-error.log
CustomLog ${APACHE_LOG_DIR}/homestead.client1.co.uk-access.log combined
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
The only amend I have made to the vhost is the addtion of code between # code added
.
I've placed an index.php
file in the server root displaying phpinfo();
:
vagrant@homestead:~$ ls -la /srv/www/vhosts/homestead.client1.co.uk/public/
total 4
drwxr-xr-x 1 vagrant vagrant 96 Sep 8 05:14 .
drwxr-xr-x 1 vagrant vagrant 160 Sep 8 05:07 ..
-rw-r--r-- 1 vagrant vagrant 17 Sep 7 05:10 index.php
In the browser I can visit http://homestead.client1.co.uk/index.php
and successfully see the output of this, so the server is working fine.
However, if I request the 'Alias' directory using http://homestead.client1.co.uk/project-one/index.php
I recieve a 404 not found response.
I can confirm the project files are in the location specified in the vhost alias and the permissions are set correctly:
vagrant@homestead:~$ ls -la /srv/www/vhosts/homestead.client1.co.uk/project-one/public/
total 28
drwxr-xr-x 1 vagrant vagrant 192 Sep 7 06:41 .
drwxr-xr-x 1 vagrant vagrant 96 Sep 7 06:40 ..
drwxr-xr-x 1 vagrant vagrant 96 Sep 7 06:41 css
drwxr-xr-x 1 vagrant vagrant 480 Sep 7 06:41 images
-rw-r--r-- 1 vagrant vagrant 24679 Sep 7 06:40 index.php
drwxr-xr-x 1 vagrant vagrant 96 Sep 7 06:40 libs
As you can see , 'project-one' is NOT a laravel framework, it is a simple static landing page for testing purposes.
Any help troubleshooting would be great, thanks.
Does error log show anything?
Can you try adding Require All Granted
under project-one alias like below:
Alias /project-one /srv/www/vhosts/homestead.client1.co.uk/project-one/public
<Directory "/srv/www/vhosts/homestead.client1.co.uk/project-one/public">
Options None
AllowOverride All
Order Deny,Allow
Allow from all
Require all granted
</Directory>