Apache Stopped Following Symlinks - apache

Yesterday, I had a fistful of sites running locally with no problem. Today, nothing opens and I have a log full of this:
Symbolic link not allowed or link target not accessible: /var/www
I have no idea what I did (I didn't open/change my httpd.conf file in any way), but clearly it was something bad. I run virtual hosts and the root directories are located in ~/Developer/www. In order to share the config files across multiple Macs with different home directories, I've created a symlink, /var/www which points to ~/Developer/www.
All of the virtualhost config files point their DocumentRoot to /var/www/project_directory and its own root directory has the FollowSymLinks option:
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost.local localhost.dev
DocumentRoot /var/www/_localhost
<Directory /var/www/_localhost>
Options FollowSymLinks Indexes
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
My main httpd.conf file, similarly, has the FollowSymLinks option enabled for /:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
Any idea what I could have done to stop Apache from understanding symlinks or, better yet, what I can do to get it back on track?
Thanks.
UPDATE:
I should add that all of the directories in the "stack" are executable by all users and that this is the native Apache install on OS X Lion.

I guess I made an assumption that I shouldn't have. I had verified every relevant permission except the one that evidently mattered. Apache didn't have execute permissions on my top level home directory. I checked, re-checked and triple checked everything under that, but having never changed anything in that directory itself, I just didn't anticipate it being the issue.

Related

Xampp apache virtualhost

I have two "htdocs" folder for two websites. I named the folders "website1" and "website2".
As you can see, both folders are inside C:/xampp.
When I type "website1.com" on my browser, I want xampp to serve the files on folder "website1" and its subfolders/subfiles as needed.
When I type "website2.com" on my browser, I want xampp to serve the files on folder "website2" and its subfolders/subfiles as needed.
For simplicity, let's say the landing page is index.php (think of sign-in page). This is the page called when I type "website1.com" or "website2.com".
Then after I hit submit button on index.php, it will call main.php.
I edited two files.
For hosts file, I add the host name that I wanted to be resolved into my localhost. Since I want to serve both website1 and website2 on my local computer via xampp, I added the following lines on hosts file located on C:/Windows/System32/drivers/etc
127.0.0.1 website1.com
127.0.0.1 website2.com
I also edited the apache config file which is httpd.conf
I added the following after the line: Listen localhost:80
<VirtualHost website1.com:80>
DocumentRoot "C:\xampp\website1"
ServerName website1.com
<Directory "C:\xampp\website1">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
<VirtualHost website2.com:80>
DocumentRoot "C:\xampp\website2"
ServerName website2.com
<Directory "C:\xampp\website2">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
The current behavior with these configs is that:
Typing "website1.com" or "website2.com" directs me/loads the page properly. For simplicity, the index.php of website1 has just different text compared to website2.
The problem is, once I hit submit button and it tries to load main.php (DIFFERENT folder locations depending if website1 or website2 but SAME file name), I get the following error:
Any help would be appreciated. I am new to web development.
I am also new to this topic (virtual hosts). I happen to search for this because I am getting tired of renaming my htdocs folder. RIght now, when I want to test website1, I rename website1 folder to htdocs. I am thinking that if what I am trying is possible, it may save me time in the long run.

Apache2 Alias Prerequisites

I have four Web development systems, two with Windows 10 and two with Ubuntu Linux and have set up Alias folders on three without a problem but am currently traveling and having trouble with the fourth. It is running Ubuntu with Apache2. A sample of one of the VirtualHost entries is below.
<VirtualHost devsite.dev:80>
DocumentRoot /var/www/html/devsite.dev
ServerName devsite.dev
Alias /common/ /var/www/html/devsite.dev/common/
<Directory "/var/www/html/devsite.dev">
AllowOverride None
Options FollowSymLinks Indexes
Require all granted
</Directory>
Options FollowSymLinks
</VirtualHost>
The above does not work so what did I miss? All site folders including the common folder are in /var/www/html/ and I must have missed something as the alias is not working. In other words, each site has its own sitename.dev folder so http://devsite.dev/ pulls up the site but there is no physical folder within the site folder for http://devsite.dev/common/ to work so needs an Alias. Not sure if trailing slashes are needed or not and can't recall what my other systems have but either way it doesn't seem matter here.
When I say it doesn't work, I mean that the aliased folder does not show up in the PC's file manager as it does on all my other systems and the site cannot find it using the browser in order to load files from it as I showed above in the sample URLs.
Perhaps I was not too clear that common is not within /var/www/html/devsite.dev. Instead it is at /var/www/html/common and it does require an Alias to work. Also, there is already a DocumentRoot /var/www/html line in the Apache 000-default.conf file.
I was under the mistaken impression that the Alias path was telling the system where the alias should appear but I was obviously wrong so here's the answer for others to see. Still not sure of the trailing slashes but, as it is working with them, I'll leave them in.
<VirtualHost devsite.dev:80>
DocumentRoot /var/www/html/devsite.dev
ServerName devsite.dev
Alias /common/ /var/www/html/common/
<Directory "/var/www/html/devsite.dev">
AllowOverride None
Options FollowSymLinks Indexes
Require all granted
</Directory>
Options FollowSymLinks
</VirtualHost>

Local website not working

I'm having a lot of trouble setting up a local website that I need to do some work on.
I have 2 local sites: "first_training" and "resus_skills"
The former, first_training, works. I have it set up that first_training.loc/ takes me to the local site. resus_skills is set up in the exact same way, but when I try to access resus_skills.loc/ all I get is:
Here are the details of my setup, as well as some screenshots of it:
/etc/apache2/sites-available/resus_skills.conf :
<VirtualHost *:80>
ServerName resus_skills.loc
ServerAlias www.resus_skills.loc
DocumentRoot "/var/www/resus_skills"
<Directory "/var/www/resus_skills">
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I made sure to enable it with sudo a2ensite resus_skills.conf and have confirmed that it's symlink is present in ``/etc/apache2/sites-enabled`
I've made sure my apache server is running:
and I've run apachectl -S to get this result:
I am able to reach first_training.loc/ with no issues, but cannot reach resus_skills.loc/.
I'm unsure how to troubleshoot this - the apache error.log isn't showing me anything.
Before anyone points out what an idiot I've been - I never updated the /etc/hosts file, which was the only missing step.

Change the DocumentRoot folder in apache cause permission issue

I installed a LAMP in my AWS EC2 instance. The DocumentRoot folder is in /var/www/html. What I did is to copy the html folder into my /home/ec2-user and rename it to www. Then the DocumentRoot is changed to /home/ec2-user/www. Of course the https.conf is changed accordingly. Here it is:
#DocumentRoot "/var/www/html"
DocumentRoot "/home/ec2-user/www"
<Directory />
#Options FollowSymLinks
#AllowOverride None
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
#<Directory "/var/www/html">
<Directory "/home/ec2-user/www">
The problem is I got the following error message after I restart the https service.
You don't have permission to access / on this server.
The owner and the permission is the same for both folder. Here are the screenshots:
I searched in stack overflow and found some similar issues. But none of them work for me. Can anybody help? Thanks
the issue is the user apache runs as, is not ec2-user.
You could change it, but putting your doc root inside of the ec2-user's home directory is probably not a good idea. More then likely everything you do on your instance is as the ec2-user (who is a sudoer and has access to pretty much everything), so if someone was to compromise a script that apache is running, they would literally have full control over your instance.

Setting root directory in a development environment

I have a linux server that I do all of my web development on. I cant find an example of a virtual host.
I need a way to set virtual hosts (i think) so that even when i am running http://dev.example.com/blah i need that URL to be treated as a different site.
I know that i cannot use sub domains because to access the server I have to navigate through a sub domain.
If you need any clarifications please ask.
Virtual hosts are set using a <VirtualHost> section in apache configuration file(s) generally being httpd.conf,apache2.conf.It looks like
<VirtualHost *:80>
ServerAdmin webmaster#dev.example.com
ServerName dev.example.com
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>
</VirtualHost>
You can change DocumentRoot as per your convenience.
In few versions of distros such different sections of main trivial configuration file httpd.conf are segregated to separate files.
For example apache2 on latest ubuntu has separate files per virtual host located at /etc/apache2/sites-enabled/
You may find 000-default already in this directory which sets the default host(localhost)
You may copy it and start editing to define a new virtual host.With above snippet you will be configuring new host. Key point is setting DocumentRoot to a different directory for dev.example.com to configure as a different site.
I assume your dev machine is able to resolve what is set for ServerName else you may want to configure it too in /etc/hosts on debian based linux.