I currently have a site that I am redoing with the roots development workflow. I used roots for a previous site and it worked great.
I was able to use a subdomain to load the roots production site on before I wanted to make it completely live (on plain domain name).
EXAMPLE:
website url: mysite.com (points to live site not roots production site)
subdomain: demo.mysite.com (points to Digital Ocean droplet running roots production site)
I was able to achieve this the first time I used roots but it seems that the stack has been updated pretty heavily since I made my first site.
I have the following serving block running on the Digital Ocean droplet that is running the roots stack:
# Ansible managed
server {
listen 80;
server_name demo.mysite.com ;
access_log /srv/www/mysite/logs/access.log main;
error_log /srv/www/mysite/logs/error.log;
root /srv/www/mysite.com/current/web;
index index.php index.htm index.html;
add_header Fastcgi-Cache $upstream_cache_status;
charset utf-8;
# Set the max body size equal to PHP's max POST size.
client_max_body_size 25m;
include acme-challenge-location.conf;
include includes.d/mysite.com/*.conf;
# Prevent PHP scripts from being executed inside the uploads folder.
location ~* /app/uploads/.*\.php$ {
deny all;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
include h5bp/directive-only/x-ua-compatible.conf;
include h5bp/directive-only/extra-security.conf;
include h5bp/location/cross-domain-fonts.conf;
include h5bp/location/protect-system-files.conf;
location ~ \.php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_pass unix:/var/run/php-fpm-wordpress.sock;
}
}
It is basically the exact file that trellis makes but it’s name is demo.mysite.com not mysite.com. This is also the only file in /etc/nginx/sites-enabled
directory.
I have an A
record in my DO network settings that points demo.mysite.com to the the roots production site Droplet.
However when I load demo.mysite.com it routes to mysite.com.
If I change the demo.mysite.com nginx server block file and put minimal configs:
server {
listen 80;
listen [::]:80;
root /var/www/test.com/html;
index index.html index.htm index.nginx-debian.html;
server_name demo.mysite.com
location / {
try_files $uri $uri/ =404;
}
}
I get a 403 forbidden error.
One last thing all of the configurations in the trellis yaml files are for mysite.com not demo.mysite.com if that matters.