Problems setting up roundcube virtualhost for every subscription on server - apache

Im trying to finish the set up of roundcube by adding a virtualhost so every subscription on server will use the webmail.servername.com to access it.
I have uploaded this roundcube.conf file with the code:
<VirtualHost ip-one:7080 \ ip-two:7080 \ local-ip:7080>
ServerName roundcube.webmail
ServerAlias roundcube.webmail.*
ServerAdmin "fdmatte#gmail.com"
DocumentRoot "/var/www/roundcube/"
<Directory "/var/www/roundcube/">
Options +FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
</IfModule>
# This is needed to parse /var/lib/roundcube/.htaccess. See its
# content before setting AllowOverride to None.
AllowOverride All
order allow,deny
allow from all
</Directory>
The issues im having are the following:
Using this file when i access my a website like http://www.mywebiste.com it gets routed to http://mywebsite.com
When i access webmail.mywebsite.com roundcube gets loaded but it cant find included files like css and js
It only works correctly if i access the ip-one:7080, then it works fine load up all css and js and i can login, check and send emails.
Is there something wrong with my settings?
Im using a plesk 11.5.30

Redirect http://www.mywebiste.com -> http://mywebsite.com can be switched off in Domain's hosting setting it's "Preferred domain" dropdown
Second issue can appears if you have wildcard subdomain *.mywebiste.com, this is well know plesk 11.5 bug so you can just ask Paralles support for solution. (You can workaround it by youself via customizing virtual hosting templates, but you should know how all this plesk backend works).
It's works for ip-one:7080 because Plesk 11.5 don't configure nginx webmail's config for every domain, just for wildcard webmail.*. So, nginx choose "wrong" virtual server and point it to virtual server of this wildcard subdomain which has location "/internal-nginx-static-location/" where static files will be looking by nginx(he know that is is static files because Plesk apache module mod_aclr2 provide such info for him ), but this location point to vhost folder of subdomain.
It's maybe something else, but I can't say more accurate just by your description.

Related

apache xampp virtual host makes error 403 windows

I simply want to enable the test.php file to be accessible via a virtualhost so I added just 127.0.0.1 test.localhost in the windows host file and
<VirtualHost *:80>
DocumentRoot "D:/Programmordner/test"
ServerName test.localhost
<Directory "D:/Programmordner/test">
require all granted
#<FilesMatch "^((test|test2).testdateiendung1|.+.testdateiendung2)$">
<FilesMatch "^(test.php)$">
Allow from All
</FilesMatch>
in httpd-vhosts.conf
Now if I add the second, it seems I even cannot open the default documentation website by clicking the admin-button on the apache interface, which should not be affected? If I erase the second the alterations in the windows host file doesnt affect anything and I can access all files in standard htdocs. I switched different versions like allow from all, access denied access granted but nothing changed
If somebody knows there is already which solves my problem, I will not grudge him however I looked for it and it did not help
I made several fixes and changed to Port 80 (without httpS :( ) and everything is running now.

Domain is redirected to another domain in same droplet

Well, I am new on Debian, Built server on Digital Ocean with Debian OS.
I successfully added two domains into one droplet:
mysite.com
anothersite.com
Created new dir:
/home/user/www/mysite.com/public_html
and copied files to public_html
The config file inside /etc/apache2/sites-available is:
DocumentRoot /home/user/www/mysite.com/public_html
<Directory /home/user/www/mysite.com/public_html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/myproject-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/myproject-access.log combined
Of Course, I enabled the site.
I haven't edited apache2.conf file and haven't configured 2nd domain (anothersite.com). Just added this 2nd domain to droplet, that's all.
when I enter to the site mysite.com it works perfect. But I wondered that why 2nd domain (anothersite.com) is redirected to 1st (mysite.com) domain?
By the way, I use Apache 2.4
If hostname (e.g. anothersite.com) point to the apache webserver but haven't explicitely configured a section that matches that hostname, then apache will deliver a "best match" (the first ).
so if only have a single in apache config and multiple hostnames (mysite.com and anothersite.com) point to the same machine, all of these names will display the same virtual host

WAMP virtualhost wont redirect

Ok I had to move my web to a new host. However new one is running Win 7 ultimate instead of 2008 R2.
To make sure i wont forget something moved over the existing WAMP Apache/PHP versions (bin folders).
It all works fine, except that virtualhosts simply wont redirect to the new documentroot.
it includes the virtualhosts conf file.
NameVirtualHost 88.159.116.217:90 should redirect to
C:/wamp/www/update/ but instead still directs to C:/wamp/www/
This setup worked fine on the 2008 R2. But now its simply ignoring everything defined in the included vhost.conf.
No errors (except that if my software connects to 88.159.116.217:90 - the files are not found since its root folder instead of update).
Code:
ServerAdmin hidden
ServerName hidden
DocumentRoot "C:/wamp/www/update/"
CustomLog logs/rfpatch.log combined
ErrorLog logs/rfpatch_err.log
<Directory "C:/wamp/www/update/">
Options -Indexes MultiViews FollowSymLinks IncludesNoExec
AllowOverride None
AddOutputFilter Includes html
Order allow,deny
Allow from all
AddType application/zip .tmp
AddType application/zip .cab
<Files update.dll>
AddType application/x-httpd-php .dll
</Files>
</Directory>
I don't need a hosts file - I'm not using domains.
There is no admin access problem (uac is also disabled).
the included vhost conf file is loaded - but vhost definitions are ignored.
The Apache version is the same as it was in the 2008 R2 server.
I can only think of two things...
You've not restarted Apache. It needs to be restarted for configuration changes to take effect.
Your Browser is caching the old page... Close all browser windows and tabs, then open the page and press CTRL-F5 to do a hard refresh. Also try clearing the browser cache data, it sometime "remembers" redirects and uses them over and over.

Apache local configuration to resolve files correctly

I have just configured Apache and PHP to work on my local Mac OS X computer. Now PHP works fine, except when I try to load the files for my live sites. The live sites have separate directories and are sorted by client name etc.
I've created symlinks in the default root for the local web server documents. My issue is that Apache doesn't seem to want to load any of the relative paths that are found in the HTML pages. For example, I have src="/css/main.css" but Apache doesn't load the file, similarly for images, it just resolves as a file not found 404 error. I then thought it might be the symlinks so I copied the full directory into the Apache document root, and still had the same result.
I would really love to setup my local development environment to run Apache, PHP, MySQL to develop locally then publish when ready. I also tried the MAMP installation, and had the same issues.
First you might want to try using src="./css/main.css".
When dealing with multiple live sites I like to setup a single configuration file for each site with apache and then load them all together in the httpd.conf file.
for my setup it looks like this:
in
/etc/apache2/httpd.conf
I have:
# Begin virtual host directives.
Include conf/bortreb.conf
Include conf/rlmcintyre.conf
Include conf/laserkard.conf
Include conf/judyates.conf
and then in
/etc/apache2/conf/judyates.conf
I have:
<VirtualHost *:80>
#localhost site
ServerAdmin email#example.com
DocumentRoot "/home/r/Desktop/web/judyates"
ServerName localhost
ServerAlias judyates.localhost
ErrorLog "/home/r/Desktop/web/judyates/log/error_log.log"
ScriptAlias /cgi-bin/ "/home/r/Desktop/web/judyates/cgi-bin/"
<Directory "/home/r/Desktop/web/judyates">
Options Indexes FollowSymLinks
Options +ExecCGI
AddHandler cgi-script cgi pl py
AllowOverride Options
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
#live site
ServerAdmin email#example.com
DocumentRoot "/home/r/Desktop/web/judyates"
ServerName judyates.com
ServerAlias *.judyates.com
ErrorLog "/home/r/Desktop/web/judyates/log/error_log.log"
ScriptAlias /cgi-bin/ "/home/r/Desktop/web/judyates/cgi-bin/"
<Directory "/home/r/Desktop/web/judyates">
Options Indexes FollowSymLinks
Options +ExecCGI
AddHandler cgi-script cgi pl py
AllowOverride Options
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This way works really well, because you can set the subdomain yoursite.localhost
to loop back to your home ip address.
With this setup, when I work on judyates.com on my computer and want to test anythig, I just go to judyates.localhost in my web browser.
I have about 5 other sites all set up this way in their own *.conf file, so they can each live in their own directories on my computer that exactly match the directories they'll be in on the server.
The key is to use virtual hosts to go to different sites based on the subdomain.
You can learn how to configure subdomains that point to yourself here:
http://digitalpbk.blogspot.com/2007/01/making-subdomains-on-localhost.html
My setup goes even one step further because I setup the server too. Whenever I want to update I load both the webfiles AND the apache config files, and that way the server exactly mirrors my local setup. The only difference is that the real judyates.com points to the server and not my home computer, so when people try to visit the site they get everything from the server.
Have you tried src="css/main.css"? That is, without the leading slash? If you have a leading slash there your files would have to be in a directory named css that was in the root directory of the webserver, and if I understand you correctly that's not the case.
EDIT: OK, from reading your comments it seems like you are not quite clear on how relative urls work. "/css/main.css" is not relative to the page's location in the directory tree. It means a file named "main.css" in a directory named "css" in the root directory of the webserver. When you put your files on the deployment server your css directory is at the webserver's root directory. But it sounds like you are currently putting the css directory in a subdirectory named for the client... so your css file is now living at "/clientname/css/main.css".
If I understand you correctly, you can do what you want by using relative urls. If your html file is in the same directory as the css directory you would need "css/main.css". If it's in a subdirectory of the directory that contains the css directory you would need "../css/main.css"- the ".." means the parent directory of the current directory. If you use relative urls they will continue to work as long as the relationship between the files doesn't change.
Here's a page on the subject that explains it adequately, I think: http://www.webreference.com/html/tutorial2/3.html. Was pretty much the first thing I found in Google though, so there are likely better explanations out there.
There are a number of Apache directives that you could use to do this, but if using relative urls would work for you (and if I understand you correctly it would) then that's likely to be a lot simpler and less likely to cause you further trouble.

How do I conditionally add a line to Apache .htaccess based on the domain?

My local development PC is set up to use PHP5 by default, my client's host (1and1.co.uk) is set up to use PHP4 by default.
To enable PHP5 on a 1and1 account, you must add the following line to your .htaccess file:
AddType x-mapp-php5 .php
If I add this line to my local .htaccess file, it breaks my PHP.
How do I add this line conditionally based on the domain (or some other parameter?) so it is only executed by the live site and not my dev site?
I'd like to be able to just upload (FTP) my entire source tree without worrying about having to remember to edit the .htaccess on the server ever time.
e.g.
<IfDomain www.example.com>
AddType x-mapp-php5 .php
</IfDomain>
... rest of .htaccess
Is this possible?
I don't have access to the server config file, only .htaccess
Thanks in advance.
To others looking at this, and using a local server with virtualhost directives: took me a while, and none of the methods found online worked (probably because my MAMP apache version is not 2.4 yet or something), but this one did.
Forget about adding 'conditional' lines to your .htaccess file: you can define which .htaccess file to use in your virtualhost setting!
So just create a file .htaccess_dev, and add this line to your virtualhost definition on your local / dev machine:
AccessFileName .htaccess_dev
So it becomes something like this:
<virtualhost>
ServerName www.example.local
DirectoryRoot /var/www/www.example.local
AccessFileName .htaccess_dev
</virtualhost>
Try this. I have no idea whether it'll work. The terminology used in the documentation suggests that it should, but since no one ever does what you're trying to do, it's a little up in the air.
<Location http://www.example.com/>
AddType x-mapp-php5 .php
</Location>
I know that you can do server-specific commands in httpd.conf using the VirtualHost tag. (http://httpd.apache.org/docs/1.3/vhosts/ip-based.html)
While I'm not 100% sure that you can use this in a .htaccess file, I would suggest trying the following:
<VirtualHost www.example.com>
AddType x-mapp-php5 .php
</VirtualHost>
You can use the VirtualHost directive to accomplish this. I just did the same when I wanted django with mod_python to run only at a subdomain
<VirtualHost *:80>
DocumentRoot /www/docs/path
ServerName www.example.com
....
AddType x-mapp-php5 .php
</VirtualHost>