I am new to Linux and Apache. I have tried to configure Apache2 to serve a website I develop on my local Linux Mint machine. I have not attepted to use PHP yet.
In spite of trying to follow all the instructions, I still got a 404 Not Found or 403 Forbidden.
The name of the directory that holds the website is Web and has permissions
drwxr-xr-x 4 www-data www-data 4096 May 15 18:46 Web
I also tried my own user group with no luck. All files inside Web have the usual r-x or r-- permissions for both Group and Others.
/etc/hosts is
127.0.0.1 localhost
/etc/apache2/ports.conf is
Listen 127.0.0.1:80
/etc/apache2/sites-available/Web.conf is
<VirtualHost 127.0.0.1:80>
ServerName Web
ServerAdmin webmaster#localhost
DocumentRoot /xxx/xxxx
</VirtualHost>
Note that /xxx is my custom partion on my local machine and xxxx is a directory in this partion.
/etc/apache2/sites-enabled is
lrwxrwxrwx 1 root root 27 May 23 13:04 Web.conf -> ../sites-available/Web.conf
Finally, the /etc/apache2/apache2.conf included this
<Directory /xxx/xxxx/Web/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
I finally did get localhost to work, but it was not as above. I simply made a link to the directory Web in /var/www/html.
/var/www/html is
-rw-r--r-- 1 root root 11321 Apr 14 15:11 index.html
lrwxrwxrwx 1 root root 17 May 22 16:54 Web -> /xxx/xxxx/Web
This worked with no chances in apache2.conf and I did not have to enable the site (make a link with a2ensite).
The url
localhost/Web
now works with no errors.
It works, but it can not be the right way. What am I doing wrong?
/xxx/xxxx also needs to be readable by www-data in order to work as document root. You'll also need the permissions defined in a directory block.
<Directory /xxx/xxxx/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Or set your DocumentRoot /xxx/xxxx/Web
Related
I got a Raspberry Pi yesterday and have mounted an additional hard drive on it. I'm planning to use it on a web server. However, I wish to host my files on the hard drive, not the small SD card where the OS is located.
I installed Apache and created a Virtual Host config file, specifying the DocumentRoot and the directory on the external HDD where the website is located. However, it gives a 403 error. The system log gives the following information:
Permission denied: [client 123.456.789.1250527] AH00035: access to / denied (filesystem path '/media/myusername/myHDD') because search permissions are missing on a component of the path
I've tried a number of different things: setting the DocumentRoot to /var/www/html but specifying the path to the HDD in the Directory tag, changing the DocumentRoot in the default site to the path to the HDD's directory that I want to serve, adding the line DocumentRoot "/media/myusername/myHDD" in the apache2.conf file. I changed the ownership of the /myHDD folder to the www-data user. I eventually deleted the /var/www/html folder and created a symlink to the HDD's directory with the name html, but that causeed this error:
AH00037: Symbolic link not allowed or link target not accessible: /var/www/html
What do I need to do to make Apache serve these websites that are on the HDD and not the system SD (only 16GB)? Here is my VirtualHost config:
<VirtualHost *:80>
ServerAdmin me#myemail.com
ServerName myurl.com
ServerAlias www.myurl.com
DocumentRoot "/var/www/html"
Alias "/webals" "/media/userName/MyHardDrive/public_html/myurl.com/"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/media/userName/MyHardDrive/public_html/myurl.com">
Require all granted
Order allow,deny
Allow from all
</Directory>
I'm not sure what is going on here. Haven't really used Apache much in the past - have preferred nginx.
Any help here would be good.
I want to prevent direct access to the server web root showing the Ubuntu home page at /var/www/html/index.html
I have changed the following:
/etc/apache2/sites-available/000-default.conf
DocumentRoot /var/www/websites
And restarted Apache but it's still going to /var/www/html if I visit my server directly.
Edit:
It appears this problem is only when I access the server on HTTPS. On HTTP it works fine.
You also need to change in /etc/apache2/apache2.conf. Find this:
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change to your desired directory
Few hours ago I upgraded ubuntu 13.10 to 14.04 LTS. I have 1 problem with chiliproject application wich running on Rails.
I got error 403 when I'm trying to access my chiliproject application. In apache2 error log i got:
Symbolic link not allowed or link target not accesibble /var/www/chili
In my apache2 conf i got:
<Directory /var/www/>
Options FollowSymLinks MultiViews SymLinksIfOwnerMatch
AllowOverride All
Require all granted
# Order allow,deny
# allow from all
</Directory>
RailsBaseURI /chili
<Directory /var/www/chili>
AllowOverride all
Options -MultiViews
Require all granted
# Order deny,allow
# Allow from all
</Directory>
I don't know why it's not running. Passenger is running and I'm stuck. Can somebody please help me ?
I tried to check users ownership in catalogs:
ls -ld /var/www/chili
lrwxrwxrwx 1 root root 41 gru 31 2013 /var/www/chili -> /var/www/chiliproject/chiliproject/public
And Target
drwxrwxrwx 4 chiliproject root 4096 gru 31 2013 chiliproject/
change the ownership of /var/www/chili using
sudo chown -R www-data: /var/www/chili
and preferably the ownership of parent dir /var/www as well.
Restart apache2
Apache will be able to read if the owner is www-data.
I am running a CentOS 6 server (on Digital Ocean) which has apache 2.2 installed.
I installed ProFTP and have set up a user called 'rator' with whom I can ftp in to the home directory at /home/rator/
I want this directory to be a working web development environment and have set up a further two sub dirs - dev and stage.
In the dev folder I have cloned my git repo and have ended up with the rather long path:
/home/rator/dev/rator/
I want to set up a vhost to this directory. I have set up my hosts file for rator.dev on my local machine, and have the following in the vhosts section of /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin me#email.com
DocumentRoot /home/rator/dev/rator
ServerName rator.dev
ErrorLog rator.dev-error_log
CustomLog logs/rator.dev-access_log common
<Directory /home/rator/dev/rator>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I try to view this in the browser - I get a 403 error. "You don't have permission to access / on this server."
If I chown apache:apache all of the dirs and files below /home/ then the site becomes visible however, I then cannot log in through ftp as the ftp home dir is then owned by apache and I'm logging in as 'rator'.
I have tried many variants on the Vhosts directory permissions but so far have not been able to solve the access problem.
Does anybody know what the correct vhosts should be here?
Ok, turned out to be pretty dumb....
sudo chmod o+rx /home/rator
Execute and read permissions were not set correctly on the home folder....
I have apache running on port 80. I have also created an additional conf file in conf.d that would open up a second port 8010 with a different directory but I am unable to get to subdirectories now of the document root of 8010
Listen 8010
<VirtualHost ip:8010>
DocumentRoot /var/www/boom
ServerName localhost
ErrorLog logs/dm-error_log
CustomLog logs/dm-access_log common
<Directory /var/www/boom>
AuthName "Protected Area"
AuthType Basic
AuthUserFile /var/www/secure/passwords
Require valid-user
</Directory>
</VirtualHost>
If I try to go to ip:8010/banq I get the following error
Forbidden You don't have permission to access /banq/ on this server.
I tried chmod 777 on banq with no luck
I had this all working great for few years and then lost all backups, had to recreate from scratch. I was able to move conf file from 1 server to another without setting any any chown and minor chmod commands. Is it possible to open all subdirectories of /var/www/boom to anyone who authenticates properly?
Two things I have encountered that could cause a similar error would be:
Apache can't access the document root of where the banq/ directory is found. Have you checked permissions on /var/www/boom? Setting the group to apache or nobody, or making the directory world readable would be a good test.
If there is no directory index in banq/ Apache may prevent you from viewing a directory listing. Try adding either an index.html page to the directory for testing, or add "Options +Indexes" to the config file.