How to personalize vhost with subdirectories

chelssi

Verified User
Joined
Aug 2, 2019
Messages
34
Hi,

I have installed apache_nginx and when I create a subdirectorie it crea a new virtual host in apache and nginx pointing to a folder with the same name but in my case this folder is different, example:

I create a subdomain images.mydomain.com then the virtual host point to /home/user/domains/public_html/images but I want it pointing to /home/user/domains/public_html/photos

I've changed this directly in apache an nginx settings but if I build again I lost the changes, where can I personalize that withouth lost the changes?

Thank you
 
Easiest solution?

Just symlink /home/user/domains/public_html/photos to /home/user/domains/public_html/images

ln -s /home/user/domains/public_html/images /home/user/domains/public_html/photos
 
Don't link to domain.com/images ?

I don't know if this would work, but you might consider creating this "subdomain" as a domain in your user panel.

This would create the DocumentRoot as

/home/user/domains/images.mydomain.com

Then delete that directory (/home/user/domains/images.mydomain.com) and replace it with a symlink to /home/user/domains/public_html/photos

ln -s /home/user/domains/public_html/photos /home/user/domains/images.mydomain.com
 
Hi sparek,

Finally I've decider to move the few files that I had in folder "/home/user/domains/public_html/images" and create the link to "/home/user/domains/public_html/photos"

Once do this a url like "https://domain.com/images/photo1.jpg" must load "https://domain.com/photos/photo1.jpg" but it doesn't, launch a 404 error.

I've used the instruction like you wrote: ln -s /home/user/domains/public_html/images /home/user/domains/public_html/photos

Is there something wrong or I don't know how do symbolic links works?

Thanks
 
Well... to start, are you copying exactly what I'm saying or are you inserting the correct DocumentRoots?

I mean... I may be wrong, but I suspect - /home/user/domains/public_html/images is suppose to be /home/user/domains/domain.com/public_html/images

And /home/user/domains/public_html/photos is suppose to be /home/user/domains/domain.com/public_html/photos

I didn't actually catch that until just now

If you are creating a subdomain - images.mydomain.com - then (I think) the DocumentRoot would be /home/user/domains/mydomain.com/public_html/images - but I may be wrong.

If you are creating - images.mydomain.com - as a "domain" then (I think) the DocumentRoot would be /home/user/domains/images.mydomain.com/public_html

If you're doing the symlink commands exactly as I have them, then they likely aren't using the correct DocumentRoots (I just copied and pasted what you had)

That would make the "subdomain" scenario:

ln -s /home/user/domains/mydomain.com/public_html/images /home/user/domains/mydomain.com/public_html/photos

And the "domain" scenario:

Remove the /home/user/domains/images.mydomain.com/public_html directory

and

ln -s /home/user/domains/mydomain.com/public_html/photos /home/user/domains/images.mydomain.com/public_html

The point isn't to necessarily copy and paste exactly what I have, but understand what is trying to be accomplished and adjust your commands and directories accordingly.
 
Well... to start, are you copying exactly what I'm saying or are you inserting the correct DocumentRoots?

I mean... I may be wrong, but I suspect - /home/user/domains/public_html/images is suppose to be /home/user/domains/domain.com/public_html/images

The path was wrong in this post mydomain.com was missing, I'm using the correct document root --> /home/user/domains/domain.com/public_html/images

And /home/user/domains/public_html/photos is suppose to be /home/user/domains/domain.com/public_html/photos

Yes, in this folder are the photos

I didn't actually catch that until just now

If you are creating a subdomain - images.mydomain.com - then (I think) the DocumentRoot would be /home/user/domains/mydomain.com/public_html/images - but I may be wrong.

Correct, DA create automatically the subdomain folder

If you are creating - images.mydomain.com - as a "domain" then (I think) the DocumentRoot would be /home/user/domains/images.mydomain.com/public_html

No, I'm creating a subdomain of mydomain.com, also is not permited user xxx.mydomain.com for creating a domain.

If you're doing the symlink commands exactly as I have them, then they likely aren't using the correct DocumentRoots (I just copied and pasted what you had)

No, my fail write bad, I'm using the correct path, it would give error if path is incorrect and when I run the instruction something do

That would make the "subdomain" scenario:

ln -s /home/user/domains/mydomain.com/public_html/images /home/user/domains/mydomain.com/public_html/photos

That instruction was what I ran -> ln -s /home/user/domains/mydomain.com/public_html/images /home/user/domains/mydomain.com/public_html/photos

If I run --> # ls -lR /home/user/domains/mydomain.com/public_html | grep ^l
I receive -> lrwxrwxrwx 1 root root 55 ago 31 18:22 images -> /home/user/domains/mydomain.com/public_html/images

But if I load https:/ /www.mydomain.com/images/1234.jpg (1234.jpg is in /home/user/domains/mydomain.com/public_html/photos) a receive 404 error, I thing it must load the photo, or not.


And the "domain" scenario:

Remove the /home/user/domains/images.mydomain.com/public_html directory

and

ln -s /home/user/domains/mydomain.com/public_html/photos /home/user/domains/images.mydomain.com/public_html

The point isn't to necessarily copy and paste exactly what I have, but understand what is trying to be accomplished and adjust your commands and directories accordingly.

Hi Sparek,

I answer by line in red.
 
Back
Top