How can i move Apache localhost from /var/www to my mount directory - apache

I am new in ubuntu(and Linux) and have simple-lamer question.
I have mounted directory /media/2A98EDD2ACA90087/WebProject/ and would like to move http:/localhost/ from var/www to /media/2A98EDD2ACA90087/WebProject/
I have change sites-enabled/000-default and /etc/apache2/sites-available
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /media/2A98EDD2ACA90087/WebProject
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /media/2A98EDD2ACA90087/WebProject>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
And have this apache message!
Forbidden
You don't have permission to access / on this server
When i have created "test" dir and move localhost from var/www to var/www/test - everything works. I suppose that problem with file permissions??!What should i do?
The problem has been solved. Thanks Patrick and Joh. Really need to give read access to index.html: chmod 644 /media/2A98EDD2ACA90087/WebProject/index.html
But i can't change access to my Ntfs mounted drive. I have to remount
why cant change permission ownership group of external hard drive on ubuntu

The apache server runs as a certain user -- probably "apache", you can run ps to see -- and that user must have permission to access the webroot. You can make it be owned by apache, or make it group-readable (and you'll probably want it group-writable) and either add apache to the group that owns it, or change the group to apache's group.
Assuming httpd runs as "apache" (group: apache) and you are "jdoe" (group: jdoe)
$ sudo chown -R jdoe:apache /media/2A98EDD2ACA90087/WebProject
$ sudo chmod -R 755 /media/2A98EDD2ACA90087/WebProject

Related

apache invalid command 'ScriptAlias'

I am trying to get apache2 running but no matter what I do, localhost comes up as 404 not found.
There has been so many errors that Debian doesn't even think Apache2 is installed, but it is functional, and running. But I cannot remove it with --purge or otherwise.
When I start apache I get
root#debian:/tmp# /etc/init.d/apache2 restart
Syntax error on line 16 of /etc/apache2/sites-enabled/000-default:
Invalid command 'ScriptAlias', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
failed!
Here is site file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I've tried various configurations. My goal is to utilize multiple IPs for different virtual hosts on port 80, but I haven't even gotten it to work after my last disaster and re installation.
ScriptAlias is provided by mod_alias. On debian based distributions, use a2enmod to make sure mod_alias is loaded:
sudo a2enmod alias

Forbidden You don't have permission to access / on this server. [Apache/2.2.22 (Debian)]

Tried all alternatives still couldn't resolve. The following error i'm getting:-
Forbidden You don't have permission to access / on this server. [Apache/2.2.22 (Debian)]
This is my default file placed under /etc/apache2/sites-enabled. The media folder is path to my remove-able disk drive named XYZ.
<VirtualHost *:80>
ServerAdmin webmaster#loclahost
DocumentRoot /media/XYZ/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /media/XYZ/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
default file in sites enabled directory is fine and working with virtualhost.It was permission related issue.Though permissions were granted but it was not being updated.
The problem was caused as filetype was ntfs and after formatting to ext4 format and giving permission to directory. problem got resolved.
Conclusion.
If facing such issue check file format and check permissions to directory are updated.Thanks.

Apache : client denied by server configuration for some local ressources

i have some troubles to install local website for development.
I have an "client denied by server configuration"' error for some local ressources like .png or .js
My website have following treepath :
website/files
website/app/local
website/app/share
My mainpage is in app/local and can access to files /files but i have 403 error for files in app/share.
I put "chmod -R 777 www-data" on full website directory so what's wrong ?
[SOLVING]I have another little problem : i can't access to my website with localhost/website but only with localhost/
I have reading some tutos and think my following configuration is right (my apache is 2.2) :
<VirtualHost *:80>
ServerName julien.quai13.com
DocumentRoot /home/julien-quai13/www
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin julien#andcotransport.com
ServerName julien.quai13.com/andcotransport
DocumentRoot /home/julien-quai13/www/andcotransport
#<Directory />
# Options FollowSymLinks
# AllowOverride All
#</Directory>
<Directory /home/julien-quai13/www/andcotransport>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And this my /etc/hosts :
127.0.0.1 localhost
127.0.0.1 julien.quai13.com
127.0.1.1 julien-quai13
192.126.0.34 julien.quai13.com
Not very important but annoying, i always have problems when i switch of Wamp to Linux.
Thanks for helping (promise i stay on Linux this time ;)
Well, when using vhosts, if apache doesn't match the URL with any server name, it will serve the first one it comes to, if this is the first one, then localhost will map straight to /home/julien-quai13/www/andcotransport
You should set up a virtualhost for default with DocumentRoot /home/julien-quai13/www and add a Directory directive for this directory, then localhost/andcotransport will work.
Not sure if this is what you meant to write: chmod -R 777 www-data but this is wrong, commands should be chmod -R 755 /home/julien-quai13/www/andcotransport and chown -R julien-quai13:www-data /home/julien-quai13/www/andcotransport
But permissions wouldn't give you a client denied by server configuration error, this is down to allow being set incorrectly.
Also you have defined julien.quai13.com twice in your hosts file.. one points to 127.0.0.1 and another points to 192.126.0.34.. this may be another problem..
Otherwise i'd consider restructuring your vhosts.
Judging by your vhost:
<VirtualHost *:80>
ServerName julien.quai13.com
DocumentRoot /home/julien-quai13/www
<Directory /home/julien-quai13/www>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
You don't actually need the second vhost unless its under a different domaing, like andcotransport.julien.quai13.com so, just use the default domain and pass everything to /andcotransport, if thats how you want to do it...
but make sure all your resources are going to /andcotransport/files and /andcotransport/app/share then this should work, unless you have an overriding ACL somewhere which is blocking directories.

mod_rewrite wasn't working so while fixing it getting 403 forbidden

On ubuntu 13.10 I am using apache 2.4.x . I was having problem with mod_rewrite. I enabled that module and and restarted the server but .htaccess file wasn't still working so I after some search, I read an answer from stackoverflow pointing towards: http://smarttips.in/htaccess-redirect-not-working-apache/
I was missing point 2 in the above link. So I put that code in my 000-default.conf file.
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
As I am using apache2.4+ so as told here: http://httpd.apache.org/docs/current/upgrading.html
Order allow, deny
Allow from all
to
Require all granted
Here is code in my 000-default.conf file:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
But after entering that code from that link, now server is giving 403 forbidden, saying:
You don't have permission to access /mysite/ on this server.
Apache/2.4.6 (Ubuntu) Server at localhost Port 80
So not sure if that mod_rewrite problem is solved or not but also getting now permissions error.
Let me know if I need to put .htaccess code here too.
So any idea what am I doing wrong ?
I simply removed:
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
and put this instead:
DocumentRoot /var/www
<Directory /var/www>
AllowOverride All
</Directory>
And now that permission error is gone and mod_rewrite is working as expected.
Adding this to <Directory /var/www/html>
Options +SymLinksIfOwnerMatch
helped me.

More than one virtual host in Apache2 Ubuntu

I have tried to configure a new virtual host in apache. I have copied the default. Updated the paths. The conf looks like this
<VirtualHost *:8081>
ServerAdmin webmaster#localhost
DocumentRoot /home/ubuntu/video
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/ubuntu/video>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/ubuntu/video/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/ubuntu/video/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I ran the command
sudo a2ensite video
which gave messaage that virtual host successfully added and will run upon reload. But i am not able to access the same. I have checked the path /home/ubuntu/video where error.log, access.log files are also created. I am not able to find the solution as well as problem. I searched in the internet if anyone have same problem.
The following blog post: Adding virtual hosts to Ubuntu Apache, says in its update the we cannot create more than one virtual host. I have already a virtual host installed. Does this mean 2nd virtual host cannot be configured in Ubuntu for apache?
Read these instructions.
If you try using <VirtualHost name:port> without the NameVirtualHost name:port or you try to use the Listen directive, your configuration will not work.
So make sure you have these directives outside the <VirtualHost> tag:
Listen 8081
NameVirtualHost *:8081
You can also add:
ServerName www.example.com
to your VirtualHost section.