apache phpmyadmin setup for vhost - apache

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! :)

Related

How to configure phabricator with a bare domain url?

I'm trying to run phabricator on my home server. The last thing I struggle with is to use phabricator with a bare url. I've set up a virtual host (apache 2.4) using a seperate port for phabricator and added the required rewrite rules:
<VirtualHost *:81>
DocumentRoot /var/www/html/phabricator/phabricator/webroot
RewriteEngine on
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
<Directory "/var/www/html/phabricator/phabricator/webroot">
Require all granted
</Directory>
</VirtualHost>
Unfortunately, phabricator demands a non-root url. Any ideas?
I get the following error message:
User moodboom found a solution but did not post the answer at how-to-configure-phabricator-with-a-non-root-url.
It doesn't look like it demands a non-root URL from the post you pointed to. It looks like the reverse, it demands a root URL. As quoted in the answer you mentioned:
You can either install Phabricator on a subdomain (like
phabricator.example.com) or an entire domain, but you can not install
it in some subdirectory of an existing website.
Since there wasn't any easy way to solve this, I hat to set up a local DNS server (dnsmasq) to get rid of this problem. Manually changing the host file on every single client is possible but too tedious and error prone. Dnsmasq on the other hand was easy to setup on ubuntu 16.04 and will keep my local network a bit more organized.
Cheers,
O.Schmitz

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!

Allow directory in subdomain but not the main domain

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.

404 with VirtualHost and Subdirectories with Apache (httpd)

Note: apparently there's a collision on the ServerName in my virtualhost entries and I need to make some changes to my /etc/hosts files. Looking into this but any insight is appreciated. Thanks
=======================================
(note I replaced http:// with hxxp:// to allow stackoverflow to let me post this)
I have a server, 10.1.1.1 that I am going to host multiple WordPress installations on in subdirectories. Specs on the server:
OS: RHEL 6.2 Santiago
Apache version: Apache/2.2.15 (Unix)
PHP version: 5.3.9
MySQL version 5.5.20
The first WordPress Installation I want to run from the virtual directory site_one (i.e. hxxp://10.1.1.1/site_one) -- the code for this site is to reside in /var/www/sites/site_one
The second WordPress Installation I want to run from the virtual directory site_two (i.e. hxxp://10.1.1.1/site_two) -- the code for this site is to reside in /var/www/sites/site_two
I have also dropped a dummy hello world index.html file in /var/www/sites
--
I have made the following changes to my httpd.conf:
DocumentRoot for the entire site is set to /var/www/sites i.e.:
DocumentRoot "/var/www/sites"
at the very bottom of httpd.conf I have the following VirtualHost directives (I replaced < and > with [ ] because I couldn't get stack overflow to output < blocks >:
NameVirtualHost *:80
[VirtualHost *:80]
ServerName 10.1.1.1
DocumentRoot /var/www/sites/site_one
Alias /site_one /var/www/sites/site_one/
[/VirtualHost]
[VirtualHost *:80]
ServerName 10.1.1.1
DocumentRoot /var/www/sites/site_two
Alias /site_two /var/www/sites/site_two/
[/VirtualHost]
I check the syntax of httpd (httpd -t) and the sytax is OK
I restart httpd
--
If I try to access hxxp://10.1.1.1/site_two it gives me a 404 and the error_log reports that it is looking in /var/www/sites/sites_one/site_two/ for the file... Obviously I want it to not look there but in /var/www/sites/site_two/ ... what am I doing wrong? Thanks for any and all help!
See the Apache documentation. http://httpd.apache.org/docs/2.2/vhosts/name-based.html
You are trying to use Name Based Virtual Host because you only have one IP address. This is fine but you are missing the DNS part of how this works. From the documentation: "you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames."
The first listed virtual host is always the default host. That is why your site_one will behave the way you "think" it is supposed to, however when you try to access site_two, it falls under the default virtual host.
You have the wrong idea about how Virtual Hosts work. What you are trying to do can be accomplished using aliases, however if anywhere in your code you refer to document root, you have to follow it up with which site you are referring to.
E.g. in PHP code something like this:
require($_SERVER['DOCUMENT_ROOT']."/site_one/directory/to/wherever

Multiple domains on apache server

First a quick disclaimer, I'm not a 'server guy' or a 'unix pro' or anything like that, I'm a web programmer who got stuck doing server works since I ran linux (ubuntu) on my netbook.
I'm trying to set up an apache server running on Debian to automagically serve multiple domains, each domain needs to have its own directory in /var/www.
Since this is the last thing I do for this company I really need it to be easy for my successor (who is even more a beginner at servers than I am), to create more domains without having to muck around with ssh or /etc/apache2/sites-available, so what I'm looking for is basically any magic mumbo-jumbo in default (or apt-get, or conf.d) that makes the server start serving any domain that has a matching folder in /var/www they will ofcourse have to initiate domain transfers the usual way.
I have no problem setting up domains individually.
Ick... hope the above makes sense to someone.
To serve multiple domains from Apache, you'll need Apache Virtual Hosts. You can start serving any domain that has a matching folder in /var/www" with Apache Virtual Hosts using mod_vhost_alias.
The following configuration will take the fully-qualified domain name (like www.example.org) and use it as the variable '%0'. So, to serve out 'www.example.org', you create a directory at /var/www/www.example.org/docs , and place your HTML content there. Your Cgi script will go in /var/www/www.example.org/cgi-bin/
<VirtualHost 192.168.1.100:80>
# get the server name from the Host: header
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/docs
VirtualScriptAlias /var/www/%0/cgi-bin
</VirtualHost>
Then, point 'www.example.org' to '192.168.1.100', and Apache will happily serve that Virtual Host.
Untested Code with flavor of Ubuntu
sudo a2enmod rewrite
vi /etc/apache/sites-enabled/000-default
NameVirtualHost *
<VirtualHost *>
DocumentRoot /var/www/
RewriteEngine On
RewriteRule ^(.*)$ %{HTTP_HOST}/$1
</VirtualHost>
sudo /etc/inid.d/apache2 restart