Setting custom php include path in .htaccess on mac os x - php

in
/Users/username/Sites/somesite/.htaccess
I have
AllowOverride All
php_value include_path ".:/Users/username/Sites/somesite/inludesFolder:/usr/lib/php"
I have also modified
/etc/apache2/httpd.conf
to
AllowOverride All
and restarted websharing, but it's not finding the additional include path. I'd like to avoid modifying the php.ini or setting this additional include path with the PHP

The AllowOverride within the .htaccess file itself isn't legal like that, and might be causing an error that stops further processing. Since the point of AllowOverride is to restrict what .htaccess files can do, it isn't usually useful within an .htaccess file. Try taking it out and see if it works.
Also, rather than modify /etc/apache2/httpd.conf, Mac OS X's configuration is set up so that you drop a file in /etc/apache2/users to configure your own directory. Files in there will persist across system updates and even upgrades!
For example, on my system, the file `/etc/apache2/mark' is:
<Directory "/Users/mark/Sites/">
Options Indexes MultiViews SymLinksIfOwnerMatch
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Related

Apache doesn't seem to be detecting my .htaccess file

I'm running an Apache server on my computer through MAMP, and I can't seem to get it to read my .htaccess file. All of the solutions I've looked at have said to make sure that my AllowOverride is set to All in httpd.conf, which it is, but this doesn't seem to resolve my issue. I know that .htaccess isn't being read since I've written some nonsense at the start of the file and no error is being produced. I have also restarted the Apache servers after changing httpd.conf. Maybe the problem is that I'm not completely sure where I'm supposed to place the .htaccess file.
My MAMP document root was formerly MAMP > htdocs, but I changed it to Library > WebServer > Documents, which is where all of my PHP files are located. The current project I'm working on is a subdirectory of this, say Library > WebServer > Documents > project. This is the folder that contains my .htaccess file. My httpd.conf file is in MAMP > conf > apache, and the relevant section of it is as follows:
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Do I need to change the directory from / to something else to get this working? Any help is really appreciated.
Edit: I added the following <VirtualHost> block to my httpd.conf following the comments below, but again, nothing seems to change:
<VirtualHost *:80>
ServerAdmin email#site.com
ServerName localhost:8890
DocumentRoot /
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Update (Solved): I was able to resolve the issue by reverting MAMP's DocumentRoot to its original MAMP > htdocs as opposed to my Library > WebServer > Documents. Apache is now reading the .htaccess file located in my MAMP > htdocs > project. Thanks everyone for the help.
First I would try to fix my VirtualHost to use the correct paths. I'm not super familiar with Mac, but if Library > WebServer > Documents > project corresponds to /Library/WebServer/Documents/project in your file system, then I would use that. Might be /home/your_username/Library/WebServer/Documents/project but as I said, I'm not a Mac guy. Next, I don't understand why you have directives for the same directory with opposite permissions, so I would try to remove the first Directory block or change the targetted directory to something else on one of the blocks. Note that you should never grant access to / with apache as it would be a very big security breach.
<VirtualHost *:80>
ServerAdmin email#site.com
ServerName localhost:8890
DocumentRoot /Library/WebServer/Documents/project
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory /Library/WebServer/Documents/project>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
If it still doesn't work, you might want to make sure that the filename Apache is looking for hasn't been changed to something else using the AccessFileName directive.
Also, you are not giving details on where you put the VirtualHost block, but if it is in a separate file. Make sure you are including that file somehow.
You don't specify your Apache version but since version 2.4, you should Require instead of Allow directives since this is deprecated. See https://httpd.apache.org/docs/2.4/en/howto/access.html
Try adding Listen 80 and Listen 443 to the top of the main config.
Check your httpd.conf. Via the AllowOverride (http://httpd.apache.org/docs/current/mod/core.html#allowoverride) and AllowOverrideList (http://httpd.apache.org/docs/current/mod/core.html#allowoverridelist) directives it can control whether or not .htaccess files are considered.
When this directive (i.e. AllowOverride) is set to None and AllowOverrideList is set to None, .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.
Please note that the default value is None for both, which cause exactly this behavior of not considering .htaccess files.

Laravel: no joy after MAMP upgrade from 3.4 to 4.1

As I am suffering a weird redirect problem and I read MAMP could be the cause I decided to upgrade it.
I have my virtual hosts set and they are enabled in the conf.
I set correct ports and set PHP version to 5.6.31 (it was 5.6.10).
What happens when I start the servers is I can open the welcome screen of the laravel project (project.dev) but then the routes don't work with error 404. Example project.dev/home or project.dev/login etc.
Any clue?
--- edit
I added this to my vhost and now it's working. Not sure if all the stuff there is needed as I just copied from the web. Strangely I didn't have anything of this in the past and it worked. Could it be apache was configured to allow mod_rewrite or something?
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
In your httpd.conf file set AllowOverride directive from None to All, for example:
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
The default in Apache 2.3.9 and later is None, previous versions is was All. From the online docs:
When this directive is set to None and AllowOverrideList is set to
None, .htaccess files are completely ignored. In this case, the server
will not even attempt to read .htaccess files in the filesystem.
When this directive is set to All, then any directive which has the
.htaccess Context is allowed in .htaccess files.

Trying to include the contents of htaccess in httpd.conf

I'm trying to include .htaccess inside httpd.conf for better performance.
I am following the instructions from the readme file here to improve site performance. I took the .htaccess and placed it in my website root folder C:/xampp/htdocs/apps then inside httpd.conf I've got the code below. then I restarted apache. The problem is i don't think the .htaccess rules are being applied
Is this the correct way of including .htaccess and am I including it in the correct directory?
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Include C:\xampp\htdocs\apps\.htaccess
</Directory>
If you want to "include" the contents manually in directory context with the Include directive, set AllowOverride to none, otherwise you are applying the same configuration twice, once in directory and another through AllowOverride method.
If you just want to have a .htaccess file (wouldn't figure why because you seem to have access to the main configuration), then AllowOverride all would be enough.
If you just want to .htaccess and make sure it is being applied you can just:
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
and add junk text in the .htaccess file inside this directory, if it is being read, Apache will responde with a 500 error, if it is not, chances are you are landing in another virtualhost where this directory is not set.
AllowOverride All
should already tell apache to let .htaccess override all settings. There is no need to include it manually i think.

Edit httpd.conf - Require/include no longer works

Running latest Zend Server on Windows 7x64, I was playing around with different ways to sync htdocs into dropbox and edited two lines of httpd.conf.
DocumentRoot "C:\Program Files (x86)\Zend\Apache2/htdocs"
<Directory "C:\Program Files (x86)\Zend\Apache2/htdocs">
with various symlinks, dropbox locations, etc.
Put it back to the way it was and php includes and require no longer work. I know the scripts are fine as the exact same scripts work on my desktop with the exact same development environment.
I put all my usernames/passwords/database names/etc in a php file that is generally stored outside the htdocs directory.
require_once('constants.php');
(In the same dir for purposes of troubleshooting, have tried everything from $_SERVER to dir.
Throws this error:
Warning: require_once(1): failed to open stream: No such file or directory in C:\Program Files (x86)\Zend\Apache2\htdocs\index.php on line 17
Fatal error: require_once(): Failed opening required '1' (include_path='.;C:\Program Files (x86)\Zend\ZendServer\share\ZendFramework\library') in C:\Program Files (x86)\Zend\Apache2\htdocs\index.php on line 17
Scripts are working fine on another machine with exact same software.
For the purposes of testing scripts, even require_once in same dir doesn't work.
Made a backup of httpd.conf before changing, put it back with no effect.
Copied httpd.conf off healthy machine, no change.
Completely re-installed the entire zend package twice, no change.
At a loss as to what could be causing this. Any ideas?
This is out of the box from the healthy machine, # removed:
DocumentRoot "C:\Program Files (x86)\Zend\Apache2/htdocs"
Each directory to which Apache has access can be configured with respect
to which services and features are allowed and/or disabled in that
directory (and its subdirectories).
First, we configure the "default" to be a very restrictive set of
features.
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
Note that from this point forward you must specifically allow
particular features to be enabled - so if something's not working as
you might expect, make sure that you have specifically enabled it
below.
This should be changed to whatever you set DocumentRoot to.
<Directory "C:\Program Files (x86)\Zend\Apache2/htdocs">
Possible values for the Options directive are "None", "All",
or any combination of:
Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
Note that "MultiViews" must be named *explicitly* --- "Options All"
doesn't give it to you.
The Options directive is both complicated and important. Please see
http://httpd.apache.org/docs/2.2/mod/core.html#options
for more information.
Options Indexes FollowSymLinks
AllowOverride controls what directives may be placed in .htaccess files.
It can be "All", "None", or any combination of the keywords:
Options FileInfo AuthConfig Limit
AllowOverride None
Controls who can get stuff from this server.
Order allow,deny
Allow from all
</Directory>
No quotes are used in Apache config IE:
ServerName yoursite.com
DocumentRoot C:\www\your_site
<Directory C:\www\your_site>
Options FollowSymLinks MultiViews
... rest of stuff
</Directory>
In addition your include may need the absolute path depending on you Apache settings .. IE
require_once('C:\www\your_site\outside_http_docs\constants.php');
Fixed it. Windows permissions requiring file outside the scope of htdocs.

In which directory i should keep my workspace or project

I have installed XAMPP in my machine(Windows XP OS). And I have Eclipse as IDE.
Now my question is, In which directory i should keep my workspace (or project).
Whether I should keep under the path "C:\xampp\php\www" OR under "C:\xampp\htdocs".
You need to change the DocumentRoot value in c:\xampp\apache\conf\httpd.conf from
DocumentRoot "C:\xampp\htdocs"
to
DocumentRoot "E:/MyProject/Source/Admin"
and configure permissions also.
<Directory "E:/MyProject/Source/Admin">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
and then restart the apache server(in xampp control panel). so from there onwards whenever you access http://localhost/ it will execute the files under E:/MyProject/Source/Admin
see for more info.
http://httpd.apache.org/docs/2.0/mod/core.html#documentroot
http://www.apachefriends.org/en/xampp-windows.html#529
Looking at the Where I change the start page? section of XAMP's FAQ (quoting) :
The DocumentRoot folder is
"\xampp\htdocs". There is the
index site (index.php) the real
start page which is loaded after
executing of "http://localhost/".
So, I'd say, in your case, you'll have to work in C:\xampp\htdocs.
Still, of course, you can change that by modifying Apache's configuration and/or creating new VirtualHosts.

Categories