Allow directory in subdomain but not the main domain - apache

I am currently running Ubuntu Server with phpMyAdmin installed.
My question is ...
How do I deny access from domain.com/phpmyadmin but allow it on sub.domain.com/phpmyadmin?
Much thanks!

In my experience with Debian I set a soft link (ln) to the phpmyadmin dir that's not in the html directory. If you are using virtual domains on your install, then the example.domain.com should have a different DocumentRoot than domain.com. If you point both domains to the same DocumentRoot, then both will have access to the link to phpmyadmin.
Hope that reads as I thought it.

Related

PHPmyadmin and Wordpress directories access denied

Running wordpress locally on a centOS 7 server running the latest apache, PHPmyadmin and mariadb-server.
IP/wordpress and IP/phpmyadmin on systems within the local network yields "403 forbidden" "you dont have permission to access (directory) on this server."
How can I fix this to allow the website to be seen on the public internet?
Could be a lot of things.
In your main Apache configuration file (e.g. /etc/httpd/conf/httpd.conf on Arch Linux), confirm your DocumentRoot path. The files you want to serve must reside there, or in sub-directories from there (If not, you might want to use an Alias to specify another path). Since you call IP/wordpress and IP/phpmyadmin, then you probably have directories called wordpress and phpmyadmin under your DocumentRoot path.
You also want to check the Directory groups in your Apache configuration file. Under those, the main culprit would be the Require directive set to all denied or something else too much restrictive like ip your_ip.
Finally, PHP can restrict path access with the open_basedir directive. Look for it in your php configuration file (e.g. /etc/php/php.ini on Arch Linux). If the line is commented, you're fine. But if a path is specified, your wordpress and phpmyadmin files must reside there.
Depending on your setup, any directive mentioned above could be in another Apache configuration file (e.g. /etc/httpd/conf/extra/* on Arch Linux).
Take a look at Apache and PHP online documentation for information about those directives.
Probably there is an issue with your directory privileges.
Use the follwing command to check it:
cd your_site_directory
ls -l
You can have a look to have a better understanding on directory privileges here.
As mentioned here apache runs under "apache" user.
Have a look at this post here to fix the issue.
All files should belong at least to apache group. To do it you can use
cd your_site_directory
chgrp -R apache ./*

How do I find out where my root URL is being served from in Apache?

I've recently got a VPS server and it came installed with CentOS, WHM and cPanel. I'm trying to find where the physical folder location the root URL of the server IP is being served. When I go to the root IP in a browser, I get a redirect to "/cgi-sys/defaultwebpage.cgi" with "SORRY!" and some error resolve details.
The server has a web-site running under "/cPanel" and also WHM runs on ":2083".
I'm trying take control of the content served directly at the /, and replace that defaultwebpage.cgi with an index.html.
I've tried httpd -V to check where the httpd.conf, is and then spotted a <VirtualHost *> in that config file, which points to a DocumentRoot of /use/local/apache/htdocs . But if I place index.html in this folder and try to hit it via /index.html, I still get routed to that defaultwebpage.cgi. Can anyone help me understand why its rerouting and not picking up that index.html?
Thanks.
You may want to try /var/www/html, at least that's in Ubuntu
If it's not it, then try going to /etc/apache2/apache2.conf and find the DocumentRoot option.
Hope this helps!

WAMP localhost and phpmyadmin setup

I have inherited a WAMP setup, but needed my http://localhost to point to a different directory "C:/Users/[user.name]/htdocs" due to many dependencies.
I made the following changes in httpd.conf
DocumentRoot "C:/Users/[user.name]/htdocs"
<Directory "C:/Users/[user.name]/htdocs">
where the original path was "c:/wamp/www/"
Now the WAMP default path for phpMyAdmin http://localhost/phpMyAdmin is not working anymore.
Is it possible to fix that via either C:\wamp\alias\phpmyadmin.conf or httpd-vhosts.conf somehow?
Can I suggest a better solution to your requirement to have a site running that does not live in the WAMPServer default location i.e. \wamp\www or \wamp\www\somefolder
If you revert all your httpd.conf changes to the out of the box state and then create a Virtual Host to run the site you have located in your \user.... folder.
Virtual Hosts are a standard Apache feature that allows you to run may sites from a single instance of Apache, a bit like a shared hosting package setup.
You would then have the benefits of the WAMPServer homepage running on localhost and all the other alias's tools as well.
You can then run your site using a nice url for example sitename.dev and the virtual host definition also allows you to setup any site specific requirements without effecting any other site you may want to run.
There is a HowTo Setup Virtual Hosts here on SO

apache phpmyadmin setup for vhost

I want to setup phpmyadmin for multi vhost users like.
example.tld_01/phpmyadmin
example.tld_02/phpmyadmin
NOTE: All apache vhost users and php script are chroot'ed for /var/www/html/[web_dir] through PHP-FPM + mod_proxy_fcgi
Try 01 => symbolic link:
ln -s /usr/share/phpmyadmin/* /var/www/html/[web_dir]/phpmyadmin
Problem 01:
Since php is chrooted users will not be able to access symbolic link of phpmyadmin
Try 02 => mount --bind:
mount --bind /usr/share/phpmyadmin/* /var/www/html/[web_dir]/phpmyadmin
Problem 02:
phpmyadmin has got some symbolic linked files in its libraries like "php-gettext/gettext.inc".
So getting this error.
Fatal error: require_once(): Failed opening required './libraries/php-gettext/gettext.inc' (include_path='.:/usr/share/php:/usr/share/pear')
Questions:
What is the best scenario in shared hosting to setup phpmyadmin for multi vhost and its users?
If you have used shared hosting, you wont see any folder like phpmyadmin in your account. But still you can access phpmyadmin. How is this possible?
About your overall problem, have you thought about using TCP/IP networking instead of sockets?
About your problem 02, that must be how your distribution has chosen to package their version of phpMyAdmin -- the official phpMyAdmin source does not have a symlink as you describe.
Try to use mod_alias
In this case for every VirtualHost you will be able to point to same directory like:
<Virtualhost tld1:80>
DocumentRoot /var/www/html/tld1/
Alias /phpmyadmin /usr/share/phpmyadmin
</virtualHost>
<Virtualhost tld2:80>
DocumentRoot /var/www/html/tld2/
Alias /phpmyadmin /usr/share/phpmyadmin
</virtualHost>
Should works good in your case. And it is an answer to both of your questions! :)

WAMP server not accessible from a different computer on the same network

I have on my laptop a WAMP server as my local server. On this server i am hosting a webpage just for local use.
I also have registered a free domain name for my server from dyndns.org. I'm using dynamic DNS by running a software from dyndns.org.
When i try to access my server and view the website which i am hosting on it using my browser, by typing localhost or my free domain name, it works just fine.
But the problem is that when a friend of mine sitting right next to me(on the same local network) tries to visit my webpage from his laptop, he gets an error message saying:
"You don't have permissions to access this server" .
I configure the httpd.conf file after i installed the WAMP server and changed only the DocumentRoot and the Directory to a folder of my choice inside the www folder.
Also i changed the ServerName to be my free domain name.
I don't think that the above are the problem. So , anyone has a clue of what might be wrong here ?
Did you try writing this:
<Directory yourdir>
Order Allow,Deny
Allow from all
</Directory>
Nope neither that worked. But after messing around with the httpd.conf file i found the solution. In the
< Directory yourdir >
Order Allow,Deny
Allow from all
# I had to put this line also
Require all granted
< /Directory>