Issue
I run an AWS ElasicBeanstalk Apache server. There is a subdomain with a different DocumentRoot (see below). When I use eb deploy
and then ssh into the machine to manually change the /etc/http/conf/httpd.conf
file, everything works just fine.
If however I do eb deploy
again, the DocumentRoot
in the http.conf file changes from "/var/www/html/sub/"
to "/var/www/html/"
, the rest of the file remains unchanged.
I suppose eb deploy must somehow rewrite the httpd.conf file, but I am puzzled as to why only the document root changes.
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/html/"
</VirtualHost>
<VirtualHost *:80>
ServerName sub.example.com
DocumentRoot "/var/www/html/sub/"
</VirtualHost>
Does anyone have a clue how I can get my subdomains working?
Solution
By Elastic Beanstalk functionality, whatever changes we do on the instance(s) manually, it will be reflected only on that instance for temporarily. The changes will be vanished if you reboots/rebuilds the instance.
If you want the changes to be applied permanently on all the instances, then you need to make use of .ebextensions folder with appropriate .config files within the folder. You can specify the configuration changes to the server software (apache, php etc) using the .ebextensions feature.
The .ebextensions folder will be a part of your code .zip file all the times.
You can refer the following link to get more help on .ebextensions: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html
Answered By - Aress Support