In my last article, I revealed how to give a client a user/password to access ONLY Webalizer statistics and no other part of cPanel. I also mentioned that it WOULD NOT work for most WordPress installs due to the way WordPress uses Mod Rewrite in the .htaccess file.
So, today, I’m going to show you a way to work around this by first creating a subdomain and THEN creating a symlink from there. This will also work for non-WordPress folks as well, it’s just a little more unnecessarily complex if you don’t need it to be:
1. LOG IN to WHM as root. Using “List Accounts“, find the cPanel account for the user you are working with and click the cPanel icon to be transferred into that user’s cPanel screen.
2. Click the “Subdomains” icon and add one for (accept the default directory location):
3. Once, created, leave cPanel open and switch to your SSH program. LOG IN through SSH as ROOT.
2. Now, go to the user’s “stats” subdirectory under the public_html directory that you just created on the server:
3. Now, we’re going to make sure that Apache will follow system symlinks for this site. Let’s open the .htaccess file:
4. Within the file you just opened, add this line:
5. Save and Exit the .htaccess file.
6. Now, enter this command to create a symlink between the webalizer directory and a new “folder” we’ll call “webalizer” to keep it simple:
ln -s ../../tmp/webalizer webalizer
7. Now, change the owner of this link to the cPanel user this account belongs to (you must put the username twice with a colon in the middle as shown):
chown -h username:username webalizer
8. Next, let’s make the webalizer directory executable:
chmod 755 ../../tmp/webalizer
7. Go ahead and exit SSH now and Switch back over to the user’s cPanel account that you should still have open from step 1.
8. In the user’s cPanel, use the “Password Protect Directories” button, navigate to the “public_html/stats/webalizer” directory you just created, then password protect the directory and create a username and password that is DIFFERENT from the cPanel name and password. This will be the username and password that you will give to your end user.
That’s all there is to it! Now, your user will be able to surf to http://stats.mydomain.com/webalizer and log in with his own, separate user name and password and view his statistics to his heart’s content without you needing to worry about him messing up the rest of his site!
IMPORTANT NOTE: Be sure that the user goes to “stats.mydomain.com/webalizer“. Failure to specify the “/webalizer” will cause a 404 Not Found error to be returned.
I hope this was helpful – as always, if you have any suggestions or comments, please share them with all of us in the comments!