Fast-swapping the public_html directory

Dizyart

Member
Jul 11, 2012
6
0
1
cPanel Access Level
Root Administrator
I have two versions of the site which I have to swap really fast, multiple times.

In my home directory, I have:

Code:
drwxr-x---  8 lorem  nobody      4096 Jul 12 20:50 public_html/
drwxr-x---  3 lorem  nobody      4096 Jul 13 12:59 public_html_3.0/
public_html holds the current website, public_html_3.0 holds the new website.

I wish to replace the two by doing:

Code:
//move the complete current site to another tmp location
mv public_html public_html_2.0 
//move the new site in place
mv public_html_3.0 public_html
After trying it on a test account, I get a Forbidden You don't have permission to access / on this server. error.

I have made sure that the public_html_* folders have identical permissions, but I guess it's a symlink issue? Am I trying to do something unthinkable and highly not recommended?

Using VPS WHM11.38.1/Cpanel11 with root privileges on CentOs 5.9.

Thanks!
 

Dizyart

Member
Jul 11, 2012
6
0
1
cPanel Access Level
Root Administrator
After some webreading, I have removed public_html (moved to temp) and sym-linked public_html -> public_html_3.0 resulting in:


Code:
drwxr-x---  3 lorem nobody      4096 Jul 13 12:59 public_html_2.0/
drwxr-x---  2 lorem nobody      4096 Jul 13 14:02 public_html_3.0/
lrwxrwxrwx  1 lorem nobody           15 Jul 13 14:11 public_html -> public_html_3.0/
lrwxrwxrwx  1 lorem lorem            11 Jul  9  2012 www -> public_html/
Still the same result.
 

quietFinn

Well-Known Member
Feb 4, 2006
2,041
551
493
Finland
cPanel Access Level
Root Administrator
I wish to replace the two by doing:

Code:
//move the complete current site to another tmp location
mv public_html public_html_2.0 
//move the new site in place
mv public_html_3.0 public_html
After trying it on a test account, I get a Forbidden You don't have permission to access / on this server. error.
That should work.

I tested in a test account and no problems at all.
 

Dizyart

Member
Jul 11, 2012
6
0
1
cPanel Access Level
Root Administrator
That should work.

I tested in a test account and no problems at all.
This was my guess too. But I figure it has something to do with Apache FollowSymlink configuration.

In WHM >> Service Conf. >> Apache Config. >> Global Configuration I have enabled:

Directory “/” Options:
Follow SymLink (checked)
SymLinksIfOwnerMatch (checked)

But I guess this might be overriden in a VHost file or something. :( :(

- - - Updated - - -

And here's the currently active httpd.conf (searched for Sym)

Code:
lorem@server [~] grep 'Sym' /usr/local/apache/conf/httpd.conf
Options ExecCGI FollowSymLinks IncludesNOEXEC SymLinksIfOwnerMatch
Options Includes Indexes FollowSymLinks
Actual except from file:

Code:
<Directory "/">
    Options ExecCGI FollowSymLinks IncludesNOEXEC SymLinksIfOwnerMatch
    AllowOverride All
</Directory>
Vhost definitions do not mention SymLinks...

--- edit ---

My Apache error logs mentions it, though:

Code:
Symbolic link not allowed or link target not accessible: /home/lorem/public_html
 
Last edited:

Dizyart

Member
Jul 11, 2012
6
0
1
cPanel Access Level
Root Administrator
OK, following up:

I figured my directory structure was way off.

My public_html_2.0 directory included another public_html folder... just a painful, wrongful unzip.

But another issue has come up:

Permission denied: /home/lorem/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

But here's the ls result:

Code:
lorem@server [~] ls -l public_html/
-rw-r--r--  1 lorem lorem  233 Feb  7 15:23 .htaccess
-rw-r--r--  1 lorem lorem 1412 Sep 26  2012 index.php

AND checking the symlinks:

lorem@server [~] ls -l 
lrwxrwxrwx  1 lorem  lorem           11 Jul  9  2012 www -> public_html/
lrwxrwxrwx  1 lorem  lorem           15 Jul 13 15:45 public_html -> public_html_2.3/
drwxr-x---  9 lorem  lorem         4096 Jul 13 15:56 public_html_2.3/
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello :)

I don't see a reason why symbolic links would be necessary. Instead, you should investigate the initial "Forbidden" error message when moving the new public_html directory in place. What permissions/ownership values did the new public_html directory have?

Thank you.