Enable multiple webroot for apache2 on Ubuntu - apache

I'm using apache2 on my ubuntu 13.10 machine, I have added another config file named paul under /etc/apache2/sites-available directory to make my file under /home/paul/public_html/ accessible on internet:
root#localhost:/etc/apache2/sites-available# ls -ltr
-rw-r--r-- 1 root root 950 Feb 7 2012 default
-rw-r--r-- 1 root root 978 Jun 23 10:54 paul
After than changes, my files under /var/www is not accessible on URL anymore, unless I change DocumentRoot from /home/paul/public_html to /var/www , but that would disable accessibility for /home/paul/public_html/
/etc/apache2/sites-available/paul :
DocumentRoot /home/paul/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
Is there any way of configuration to enable /var/www and /home/paul/pubilc_html as webroot at the same time? Is it required any setting on /etc/apache2/apache2.conf ? Any ideas would be appreciated, thanks.

You can accomplish this easily with an alias directive. In /etc/apache2/sites-available/default just add an Alias for the URL.
<VirtualHost *:80>
ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/
Alias /paul /home/paul/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now the contents of /home/paul/public_html should be available at www.example.com/paul

Related

You don't have permission to access / on this server

I'm on linux mint and I want to configure a virtual host for my symfony 3 application.
this is my Vhost on /etc/apache2/sites-available/evaluation.conf :
<VirtualHost *:80>
ServerName evaluation.dev
ServerAlias www.evaluation.dev
DocumentRoot /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web
<Directory /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web>
AllowOverride All
Order Deny,Allow
Allow from All
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
I've added the host in /etc/hosts like that :
127.0.0.1 evaluation.dev
That's not wrking for me and it return this error :
Forbidden
You don't have permission to access / on this server.
Apache/2.4.18 (Ubuntu) Server at evaluation.dev Port 8
Maybe you need to grand files access rights
chown -R www-data:www-data /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web
chmod -R 755 /home/sahnoun/InternshipPFE/Dev/systeme_evaluation/web
and
move the VirtualHost file from /etc/apache2/sites-available/evaluation.conf to /etc/apache2/sites-enabled/evaluation.conf

FastCGI using apache - not a script or wrong permission?

I compiled my fcgi for apache like this:
g++ fcgistart.c -lfcgi
I got a a.out and configure it for apache using
a2enmod fastcgi
Now i read the manual
Any program assigned to the handler fcgid-script is processed using the FastCGI protocol;
Does that mean the binary is a script? Wreid! Anyway I place the a.out to /var/www/html.
Because the handler (/etc/apache2/mods-enabled/fastcgi.conf) binds to .fcgi I copy a.out to a.fcgi. Now i browse to http://localhost/a.fcgi and a 403-forbidden occourse.
xx#xx:/var/www/html$ ls -la
drwxr-xr-x 2 root root 4096 Feb 6 13:44 .
drwxr-xr-x 3 root root 4096 Feb 6 12:56 ..
-rwxr-xr-x 1 root root 8696 Feb 6 13:44 a.fcgi
-rwxr-xr-x 1 root root 8696 Feb 6 13:16 a.out
-rw-r--r-- 1 root root 11321 Feb 6 12:57 index.html
What is wrong?
I got it:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
is wrong, I had to add the ExecCGI option:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options +ExecCGI
</Directory>
</VirtualHost>

incorrect redmine installation

I am trying to install redmine 3.2.0 like in the following article.
The point 2.4 Test Redmine works fine, i.e. I am able to open redmine using http://MY_IP:3000.
After this, I did:
sudo chown -R www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
sudo ln -s /opt/redmine/redmine-3.2.2/public/ /var/www/html/redmine
Added Listen 89 into /etc/apache2/ports.conf.
Created the following sudo vim /etc/apache2/sites-available/redmine.conf:
<VirtualHost MY_IP:89>
ServerAdmin email#example
DocumentRoot /var/www/html/
<Location /redmine>
RailsEnv production
RackBaseURI /redmine
Options -MultiViews
</Location>
</VirtualHost>
Enabled redmine.conf: sudo a2ensite redmine.conf.
Added PassengerUser www-data into /etc/apache2/mods-available/passenger.conf. Now passenger.conf contains the following:
<IfModule mod_passenger.c>
PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
PassengerDefaultRuby /usr/bin/ruby
PassengerUser www-data
</IfModule>
And restarted apache: sudo service apache2 restart.
So /var/www/html/ contains:
drwxr-xr-x 2 root root 4096 Jan 25 09:32 .
drwxr-x--x 7 root root 4096 Jan 22 07:21 ..
-rw-r--r-- 1 root root 11104 Jan 22 02:57 index.html
lrwxrwxrwx 1 root root 34 Jan 25 09:32 redmine -> /opt/redmine/redmine-3.2.0/public/
Now if I am going to http://MY_IP:89 then /var/www/html/index.html is opened instead of redmine home page.
Could you please advise where I did an error?
Thanks in advance!
UPDATE:
If I use the following redmine.conf:
<VirtualHost MY_IP:89>
DocumentRoot /var/www/html/redmine
<Directory /var/www/html/redmine>
RailsBaseURI /
PassengerResolveSymlinksInDocumentRoot on
AllowOverride None
RailsEnv production
Options -MultiViews
</Directory>
</VirtualHost>
Redmine won't start, only shows index of (/var/www/html/redmine/).
I SOLVED THE ISSUE:
I did gem install passenger. And I use the following redmine.conf:
<VirtualHost MY_IP:89>
DocumentRoot /var/www/html/redmine
<Directory /var/www/html/redmine>
RailsBaseURI /
PassengerResolveSymlinksInDocumentRoot on
AllowOverride None
RailsEnv production
Options -MultiViews
</Directory>
</VirtualHost>
From passenger 5.2.0 which was released in January 2018 "PassengerResolveSymlinksInDocumentRoot on" is no longer supported
in your /etc/apache2/sites-available/xxx.conf
make the following changes:
# Not supported from passenger 5.2.0 on wards
# PassengerResolveSymlinksInDocumentRoot on
PassengerAppRoot /opt/redmine/redmine-3.2.0/public/
My redmine works on apache with this config.
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.21/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.21
PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p551/wrappers/ruby
</IfModule>
<VirtualHost redmine.domain:80>
ServerName redmine.domain
ServerAlias redmine
DocumentRoot /opt/redmine/redmine-3.2.0/public/
<Directory /opt/redmine/redmine-3.2.0/public/>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
allow from all
</Directory>

How to configure mod_wsgi so that RockMongo is accessible in a subdirectory (404 error)?

Desired Behaviour
I want to be able to access RockMongo at localhost/rockmongo.
Current Behaviour
I am getting:
Error: 404 Not Found
Sorry, the requested URL 'http://localhost/rockmongo' caused an error:
Not found: '/rockmongo'
Environment
Linux Mint 17 Cinnamon
Apache
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jul 22 2014 14:36:38
mod_wsgi
virtualenv
/etc/apache2/sites-available/000-default.conf
WSGIPythonHome /var/www/html/ENV
WSGIPythonPath /var/www/html:/var/www/html/ENV/lib/python2.7/site-packages:/var/www/html/wsgi
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIScriptAlias / /var/www/html/wsgi/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Directory Permissions
/var/www
drwxr-xr-x 3 root root 4096 Nov 23 08:58 www
/var/www/html
drwxr-xr-x 10 me me 4096 Nov 26 23:46 html
/var/www/html/rockmongo
drwxr-xr-x 5 me me 4096 Jun 6 23:04 rockmongo
Apache Error Log
There are no errors relating to this.
I got it working, but I'd love confirmation that this is the right way to do it and doesn't create any security issues for RockMongo or interfere with other aspects of mod_wsgi functionality.
I added the Alias line and the Directory block below.
/etc/apache2/sites-available/000-default.conf
WSGIPythonHome /var/www/html/ENV
WSGIPythonPath /var/www/html:/var/www/html/ENV/lib/python2.7/site-packages:/var/www/html/wsgi
<VirtualHost *:80>
# for all content in static folder - css, js, img, fonts
Alias /static/ /var/www/html/wsgi/static/
# for rockmongo
Alias /rockmongo /var/www/html/rockmongo
<Directory /var/www/html/rockmongo>
Order deny,allow
Allow from all
</Directory>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIScriptAlias / /var/www/html/wsgi/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Set DocumentRoot on local directory in apache

I got a local directory, which will need a DocumentRoot.
When I go to serverip/nivon-zuidholland I must have a DocumentRoot of public.
How would I manage this in apache2 config?
I inserted this in my apache2.conf. I tried to put this into my sites-available/nivon-zuidholland.conf but this doesn't work as well.
I can't restart apache2 because it returns DocumentRoot not allowed here.
<Directory "/var/www/html/nivon-zuidholland">
AllowOverride All
DocumentRoot /var/www/html/nivon-zuidholland/public
</Directory>
In your /etc/hosts add this:
127.0.0.1 nivon-zuidholland.local
Create a directory: /var/www/nivon-zuidholland (set group to www-data)
Create a Virtual host file: /etc/apache2/sites-available/nivon-zuidholland.conf
<VirtualHost *:80>
ServerName nivon-zuidholland.local
ServerAdmin webmaster#nivon-zuidholland.local
DocumentRoot /var/www/nivon-zuidholland
ErrorLog ${APACHE_LOG_DIR}/nivon-zuidholland_error.log
CustomLog ${APACHE_LOG_DIR}/nivon-zuidholland.log combined
</VirtualHost>
Place a symbolic link to this vhost conf file in sites-enabled directory
ln -s /etc/apache2/sites-available/nivon-zuidholland.conf /etc/apache2/sites-enabled/nivon-zuidholland.conf
Restart Apache server: sudo service apache2 restart
You should be able to access the site by going to: http://nivon-zuidholland.local/