Correctly setting with the working path (CentOS)

113 views
Skip to first unread message

Goodbytes

unread,
Apr 25, 2014, 4:35:37 AM4/25/14
to vagra...@googlegroups.com
Hi,

I'm having trouble working out how to correctly set the working path. I use CentOS to mimic my production web server, i use cPanel which throws everything in /home

So in my vagrant file i've added the line:

config.vm.synced_folder ".", "/home"

Which sets the current (host) directory to the /home on guest directory. This sort of works, if i cd into /home and touch a file it shows up on the guest.

However, every time i run vagrant up i receive the following error:

Could not chdir to home directory /home/vagrant: No such file or directory

Why is it trying to go to /home/vagrant ?

Also, apache standard document root is /var/www/html/ - what is the quickest way to change this, am i required to edit httpd.conf every time i fire up a new instance?

Id love to be able to automate the process so that upon firing up the vm i am sat in the home directory and it's already configured to serve pages from there instead of /var/www/html/ is this at all possible? and now do i get rid of the /home/vagrant error? While it's not causing any major problems it's clear something is not setup correctly.

thanks

Alvaro Miranda Aguilera

unread,
Apr 25, 2014, 5:21:19 AM4/25/14
to vagra...@googlegroups.com
hello,

for the first issue, it's permissions, by default the permissions won't be very user friendly..

in the host, create one dir per user, and mount that as the /home/<user>

if the user is already created check the documentation and use the user group

if the user is not created, use gid/uid like this:

config.vm.synced_folder "12cR1", "/media/sf_12cR1", :mount_options => ["dmode=775","fmode=775","uid=54320","gid=54321"]

For the 2nd problem, What will be quicker for you? mount say  host www as /var/www ?

other way, is you can use sed, and modify DocumentRoot in /etc/httpd/httpd.conf and then do a restart. you can execute this with a shell script from Vagrantfile


Let me know if you have questions, or need something a bit more detailed.

Alvaro.


--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Goodbytes

unread,
Apr 25, 2014, 6:15:44 AM4/25/14
to vagra...@googlegroups.com
Thanks for the tip, i looked up the sed command and came up with this little beast:

sudo rm -rf /var/www
sudo ln -fs /home /var/www
sudo sed -i 's@var/www/html@home@' /etc/httpd/conf/httpd.conf

Just left with "Could not chdir to home directory /home/vagrant: No such file or directory" error but it is not causing any issues so not a worry

Alvaro Miranda Aguilera

unread,
Apr 25, 2014, 11:09:00 PM4/25/14
to vagra...@googlegroups.com

On Fri, Apr 25, 2014 at 10:15 PM, Goodbytes <for...@gmail.com> wrote:
"Could not chdir to home directory /home/vagrant: No such file or directory"

when that error happen?

If there is at boot? when machine start?

or after the machine boots, say one of the scripts?

can you paste where you see that error?

Goodbytes

unread,
Apr 26, 2014, 1:33:11 PM4/26/14
to vagra...@googlegroups.com
On boot, its basically just the OS trying to cd into the user directory, which should be /home/vagrant and currently doesn't exist, easily fixed by adding a vagrant dir... although would be much nicer if we could change the home directory for a user

Alvaro Miranda Aguilera

unread,
Apr 27, 2014, 12:05:47 AM4/27/14
to vagra...@googlegroups.com
can you paste the logs and the vagrant file?

the home should exists otherwise the machine wont work (as vagrant use the vagrant user)

What I think it is, is the permissions... if you are mouting /home in the vm, that usually will use root as user/password and vagrant wont have permissions to cd into that.. that's why the chdir error.


Thats why I suggested use /home/user and not /home as a whole.. and mount each /home/user with guid/uid

home is a particular directory in unix that require the user to own it..

I won't suggest mount /home as 777 as is waaay bad practice..

Alvaro.


--
Reply all
Reply to author
Forward
0 new messages