Localhost Permissions denied after upgrade to Mavericks - permissions

Upgraded to Mavericks and edited httpd.conf to enable php and virtual hosts. That's the only change made. Now when I try to access localhost I get the error: Forbidden - you don't have permission to access xxxxx
Any ideas how to fix this?

The problem results from php not being executed any more, try to call e.g. the index.php directly and you will very likely see the sourcecode of your file.
go to /etc/apache2/httpd.conf and uncomment:
LoadModule php5_module libexec/apache2/libphp5.so
you have to restart your apache afterwards, so execute on command line:
sudo apachectl -k restart

Following steps made it work for me:
Add an error_log path to your misbehaving vhost entries, so you can
track the problem more closely
<VirtualHost *>
...
ErrorLog "/accessible/path/to/error_log"
</VirtualHost>
Restore all your previous apache settings, to be found at /etc/apache2/httpd.conf~previous
Make sure your chmod and chown rights are up to date
Alter documentRoot settings if necessery (adding + did the trick for me)
<Directory "/path/to/webroot">
Options +Indexes +FollowSymLinks +SymLinksIfOwnerMatch +MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Optionally, add following entry to your .htaccess file
Options +Indexes +FollowSymLinks +SymLinksIfOwnerMatch +MultiViews
Extra hint
Incase you are using php, restore your ini file by copying php.ini-5.2-previous to php.ini
$ cd /private/etc/
$ sudo cp php.ini-5.2-previous php.ini
Sources
http://brianflove.com/2013/10/23/os-x-mavericks-and-apache/
http://jason.pureconcepts.net/2012/10/install-apache-php-mysql-mac-os-x/
Options FollowSymLinks or SymLinksIfOwnerMatch is off

Related

Apache : how to make multiple subdomains and reverse proxy work together? [duplicate]

Once again, I have a problem with my apache virtual host configuration. (The default configuration is used instead of my specific one).
The problem is not really the misconfiguration but how to solve it.
Does anyone has good advices to do resolve this kind of problem quickly?
Some more informations.
The default conf file is this one:
NameVirtualHost *
<VirtualHost *>
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 /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
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 the virtual host config that doesn't apply is this one:
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://ip.ip.ip.ip:8088/
ProxyPassReverse / http://ip.ip.ip.ip:8088/
ServerName wiki.mydomain.com
</VirtualHost>
Syntax check
To check configuration files for syntax errors:
# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -t
# Debian-based (Ubuntu)
apache2ctl -t
# MacOS
apachectl -t
List virtual hosts
To list all virtual hosts, and their locations:
# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -S
# Debian-based (Ubuntu)
apache2ctl -S
# MacOS
apachectl -S
Here's a command I think could be of some help :
apachectl -t -D DUMP_VHOSTS
You'll get a list of all the vhosts, you'll know which one is the default one and you'll make sure that your syntax is correct (same as apachectl configtest suggested by yojimbo87).
You'll also know where each vhost is declared. It can be handy if your config files are a mess. ;)
If you are trying to debug your virtual host configuration, you may find the Apache -S command line switch useful. That is, type the following command:
httpd -S
This command will dump out a description of how Apache parsed the configuration file. Careful examination of the IP addresses and server names may help uncover configuration mistakes. (See the docs for the httpd program for other command line options).
First check out config files for syntax errors with apachectl configtest and then look into apache error logs.
I had a new VirtualHost configuration file that was not showing when using the apachectl -S command. After much head scratching I realised that my file did not have suffix ".conf". Once I renamed the file with that suffix my Vhost started showing and working!
I recently had some issues with a VirtualHost. I used a2ensite to enable a host but before running a restart (which would kill the server on fail) I ran
apache2ctl -S
Which gives you some info about what's going on with your virtual hosts. It's not perfect, but it helps.
I found my own mistake, I did not add log file name:
ErrorLog /var/log/apache2
And this path:
Directory "/usr/share/doc/"
Did not contain website sources.
After I changed these two, all worked.
Interestingly, apache did not issue any errors, just did not open my website silently on my Mac OS Sierra.
a very important tool is
apachectl -t -D DUMP_INCLUDES
it showed me that the file that i was fixing and mending
was in fact included by a file that was itself not included.
thank everybody

htaccess works in localhost but doesn't work in EC2 instance

My htaccess file works on localhost but doesn't work when i deploy it to EC2 instance.
I'm using Macbook and in finder i cannot see the htaccess file, i thought that perhaps it didn't get copied to EC2 instance but i don't think this is the problem because when i copy the project i can see the htaccess file in my editor.
Is there something enabling mod rewrite in EC2 linux instance? If there is, i didn't do it or it enables mod rewrite as default?
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
I pieced together some info from various posts so I thought I'd put up an answer.
As Paul commented, If you're running Amazon EC2 Linux, you're probably running httpd instead of Apache. The file is therefore in /etc/httpd/conf/httpd.conf
You have to change the file as root user. (from ssh access) Do this: sudo vim /etc/httpd/conf/httpd.conf (How to edit httpd.conf file in AMAZON EC2)
DocumentRoot "/var/www/html" was listed in two places for me. I had to change the subsequent AllowOverride None to AllowOverride All in those two places.
Restart apache. I restarted my whole ec2 instance (i have apache configured to start automatically) although just restarting apache should work. But I see the change is working.
I was trying to make the same changes in a .htaccess file (removing the index.php from urls in a code igniter application). Hope it helps!
By default EC2 doesn't have .htaccess enabled, you must edit your httpd.config to allow for it.
In /etc/apache/sites-available/default change AllowOverRide = None to AllowOverRide = All.
Its a three step process
Configure apache mod_rewrite,run in terminal.
sudo a2enmod rewrite
add the following code to /etc/apache2/sites-available/default
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>
3.Restart apache
/etc/init.d/apache2 restart
There are three steps
Configure apache mod_rewrite,run in terminal. sudo a2enmod rewrite
Add this code in this file after closing VirtualHost tag /etc/apache2/sites-available/000-default.conf
DocumentRoot /var/www
Options FollowSymLinks
AllowOverride All
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Restart apache server by command
sudo service apache2 restart
When you using the apache2 server
Go to the following directory.
cd /etc/apache2/sites-available
If you use LS command here you will see the following file.
000-default.conf
That's the file with default apache configuration which are applied to your sites in /var/www/html folder.
Open this file for editing.
sudo nano 000-default.conf
Add following lines after DocumentRoot /var/www/html line.
Options FollowSymLinks AllowOverride All Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all
Save the file and restart the apache.
sudo service apache2 restart
that's it and now your .htaccess file will work
On Linux enviroment
1 - cd /etc/apache2/sites-available
2 - sudo nano 000-default.conf
and paste this code:
<Directory "/var/www/html">
Order allow,deny
Allow from all
Options None
AllowOverride All
</Directory>
This worked on AWS instance.
In my case, I am not running httpd, but only Apache.
I followed this website and it works.
Step 1: Enable mod_rewrite module in Apache
sudo a2enmod rewrite
Then restart the Apache HTTP server with service command with sudo:
sudo service apache2 restart
or using the systemctl command with sudo:
sudo systemctl restart apache2
Now that we have mod_rewrite enabled, we can proceed further to configure it.
Step 2: Enable the usage of the .htaccess file
sudo nano /etc/apache2/apache2.conf
Find the following section in /etc/apache2/apache2.conf. You should see the code like this:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change, from AllowOverride None to AllowOverride All
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

How do I create the project outside the /var/www/ directory?

I've a Ubuntu server with static IP for testing purpose, I'd like to create a project (for example hello-world) outside the /var/www/ directory, let's say in this location(/home/username/webroot/hello-world/). It should be accessible via browser like this http://xxx.xxx.xxx.xxx/hello-world/ How do I do this?
I would use an Alias:
Alias /hello-world /home/www/foo
<Directory "/home/www/foo">
Options -MultiViews -FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride all
</Directory>
Enable FollowSymlinks in your Apache-config and make a symbolic link on your file system.
ln -s /path/to/your/project /var/www/projectname
And replacing the content is easy, without having to reload the server
rm /var/www/projectname
ln -s /path/to/your/project-v2 /var/www/projectname
you configure a virtual host in the configuration file of your apache: apache2.conf or httpd.conf:
<VirtualHost *:80>
ServerPath /hello-world
DocumentRoot /home/username/webroot/hello-world
</VirtualHost>

Disable directory listing on apache; but access to individual files should be allowed

I do not want to use .htaccess. How should I change my Directory attributes?
<VirtualHost *:80>
ServerName abc.com
DocumentRoot /usr/share/uploads
<Directory " /usr/share/uploads">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
If you are using Debian/Ubuntu, just go to terminal and type
sudo a2dismod autoindex
sudo service apache2 restart
If you are using Centos/Fedora, just do:
mv /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/autoindex.bkp
/etc/init.d/httpd restart
And similarly in other OS or distros...
This should disable the apache module that makes those fancy (normally useless and a security problem) directory listings. Also, as a bonus, you earn a bit of performance :-)
I really couldnt find a direct answer on internet ; even on apache documentation. Finally, could find the solution through few iterations; we need to use Options and the value should NOT contain Indexes.
<Directory "/usr/share/uploads">
Options Includes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
The #Deepak solution did not worked for me. This one did:
In the main apace configuration /etc/apache2/httpd.conf just add:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
And it will work for all of you domains and subdomains. Without .htaccess file.
All done above, but the directory info is still coming up?
If you use index.php, rather than index.html, Check the following:
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
on my AWS ec2, i did this and it worked for me.
First open /etc/httpd/conf/httpd.conf file.
modify/add
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
The easiest way would be to put an empty index.html (or whatever you apache is configured to deliver by default) inside that directory.
This is not a real solution but a very simple workaround. The user browsing that directory would just see a blank white page.
Further you could use a script (like index.php) wich emulates the directory-listing and only shows some special files.

How to debug an apache virtual host configuration?

Once again, I have a problem with my apache virtual host configuration. (The default configuration is used instead of my specific one).
The problem is not really the misconfiguration but how to solve it.
Does anyone has good advices to do resolve this kind of problem quickly?
Some more informations.
The default conf file is this one:
NameVirtualHost *
<VirtualHost *>
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 /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
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 the virtual host config that doesn't apply is this one:
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://ip.ip.ip.ip:8088/
ProxyPassReverse / http://ip.ip.ip.ip:8088/
ServerName wiki.mydomain.com
</VirtualHost>
Syntax check
To check configuration files for syntax errors:
# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -t
# Debian-based (Ubuntu)
apache2ctl -t
# MacOS
apachectl -t
List virtual hosts
To list all virtual hosts, and their locations:
# Red Hat-based (Fedora, CentOS), Arch-based and OSX
httpd -S
# Debian-based (Ubuntu)
apache2ctl -S
# MacOS
apachectl -S
Here's a command I think could be of some help :
apachectl -t -D DUMP_VHOSTS
You'll get a list of all the vhosts, you'll know which one is the default one and you'll make sure that your syntax is correct (same as apachectl configtest suggested by yojimbo87).
You'll also know where each vhost is declared. It can be handy if your config files are a mess. ;)
If you are trying to debug your virtual host configuration, you may find the Apache -S command line switch useful. That is, type the following command:
httpd -S
This command will dump out a description of how Apache parsed the configuration file. Careful examination of the IP addresses and server names may help uncover configuration mistakes. (See the docs for the httpd program for other command line options).
First check out config files for syntax errors with apachectl configtest and then look into apache error logs.
I had a new VirtualHost configuration file that was not showing when using the apachectl -S command. After much head scratching I realised that my file did not have suffix ".conf". Once I renamed the file with that suffix my Vhost started showing and working!
I recently had some issues with a VirtualHost. I used a2ensite to enable a host but before running a restart (which would kill the server on fail) I ran
apache2ctl -S
Which gives you some info about what's going on with your virtual hosts. It's not perfect, but it helps.
I found my own mistake, I did not add log file name:
ErrorLog /var/log/apache2
And this path:
Directory "/usr/share/doc/"
Did not contain website sources.
After I changed these two, all worked.
Interestingly, apache did not issue any errors, just did not open my website silently on my Mac OS Sierra.
a very important tool is
apachectl -t -D DUMP_INCLUDES
it showed me that the file that i was fixing and mending
was in fact included by a file that was itself not included.
thank everybody