.htaccess access parent folder - .htaccess

I just installed Apaxy for a better and customizable folders views.
It works perfectly, but not in my virtualhost.
Folder (localhost) :
Virtualhost (local.dev.conf, access with local.dev):
<VirtualHost *:80>
ServerName local.dev
DocumentRoot /var/www/local.dev
</VirtualHost>
Unfortunately, in the virtualhost (local.dev) apaxy doesn't work.
I assume it's normal because the server try to find files in local.dev/themes/...
Or my 'themes' folder is in the parent folder, so it is possible to resolve this ?
Here is the .htaccess :
https://justpaste.it/t8yp

 Problem
Apache serves file from the directory /var/www/local.dev.
Solution
Moving the directory /var/www/theme into /var/www/local.dev would work. Nevertheless if, for any reason, you do not want to move theme you can link it using the command ln -s /path/to/theme /path/to/local.dev/theme.
IMHO
Moving the directory would be a better solution as linking it, would force the configuration to enable follow-symlink, as it can be considered as a security issue.

Related

Apache DirectoryRoot configuration?

I have apache running on Ubuntu, my initial directory structure was like :
var/www/html/myproject,
Now I had cloned a git repository in html folder above now my directory structure becomes :
1] var/www/html/myproject this is intact,
2] var/www/html/my_repo/myproject this is newly created after cloning,
Now I want apache to deploy this newly created 2nd dir as root, hence I made the change in file located at /etc/apache2/sites-available/000-deafult.conf with following changes :
DocumentRoot var/www/html/my_repo/myproject
Then restarted the apache but somehow, server is still loading pages from var/www/html/myproject instead of var/www/html/my_repo/myproject.
So is there any extra config changes that I have missed OR Do I need some permissions to be given to cloned repository files ? How do I resolve this issue.
Did you change your original DocumentRoot in apache configuration file? If you didn't, change it, if you did, just reset browser cache by Ctrl+F5 or open page in Private Mode.
I figured it out it was /etc/apache2/sites-enabled where the seperate cofiguration file only for myproject named myproject.config in which I made following changes :
DocumentRoot var/www/html/my_repo/myproject & also
<Directory var/www/html/my_repo/myproject>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Now server is taking new directory as root.

Configure httpd.conf to add new site on Apache Red Hat Linux

I have linux server (Red Hat Enterprise Linux Server release 5.3 (Tikanga)) with apache installed. It is already used for browsing some documents. Now I would like to add a new Directory (with a html page), so whenever the directory is browsed it can display the html page.
But I am not sure of where all to edit the httpd.conf file
Existing httpd.conf:
When I hit the url "http://servername/eng" it displays list of folders.
Now, I want to add a website to this existing, so when user hit the url "http://servername/builds" it should display a html page in the browser.I have added my "index.html" page in location "/var/www/html/builds/"
For this I added the below code to httpd.conf file
Please let me know what all modifications are required in the conf file
You can do it in a few different ways.
Putting index.html in /build
This requires you to have this setting:
DirectoryIndex index.html
(it should be there by default on most platform.)
Also for this to work, rather than putting new <Directory>, you should put the build/ directory in the directory that holds your http://example.com/ files. For instance:
/var/www/example.com/public_html/eng/
/var/www/example.com/public_html/builds/
/var/www/example.com/public_html/builds/index.html
Storing build/ in folder completely unrelated to example.com, but still be able to reach it via example.com/builds
For this, you need to rewrite the URLs so that example.com/builds redirects the user to the final URL. This is most easily achieved through mod_rewrite. You enable mod_rewrite module in your Apache's configuration, make sure that example.com can have .htaccess files through ensuring proper AllowOverride entry in example.com's <Directory> configuration, create /var/www//example.com/public_html/.htaccess (or similar) file, and fill it RewriteEngine On and RewriteRules you need. More on mod_rewrite in the Internet and in the documentation.
Completely separate virtual server, for example builds.example.com/
In this case, what you're looking for are virtual servers. These are not defined in httpd.conf or configuration itself, but usually have dedicated directory.
For example, to add builds.example.com that works for port 80, you'd need to create following entry:
<VirtualHost *:80>
ServerName builds.example.com
DocumentRoot /var/www/builds.example.com/public_html/
</VirtualHost>
Where to put this? Well, it depends on the platform. For Debian, you put this in a new file in /etc/apache2/sites-available/, e.g. /etc/apache2/sites-available/example.com, and symlink to it in /etc/apache2/sites-available (on Debian, you can do this easily with a2ensite <NAME_OF_FILE>. On your platform this procedure might be different, so look it up ("adding virtual servers on " would be a start). After adding virtual servers, you need to reload your Apache configuration.
Please let me know if this satisfies your question, if not, I'll edit the answer accordingly.

Disabled PHP for Single Directory with HTACCESS (PHP-FPM)

I want to disable the parsing of PHP files in a specific directory, and found out how to do that here. The problem is that my server uses PHP-FPM, and I get Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration when I try to use php_flag in my httpd.conf file.
How can I disable parsing of PHP files in a given web-accessible directory with an htaccess/httpd.conf file that is located above web root on a server using PHP-FPM?
Since Fedora 27 switched to php-fpm recently, I, too, ran into this problem. Unfortunately, the old ways of doing things with mod_php do not apply to php-fpm.
I did find another question here that definitely seemed more relevant:
Apache: Disable php in a directory
The gist of it was was to use a <directory> and <filesmatch> block in your config file, and use SetHandler ! for every directory you didn't want PHP code interpreted.
e.g.:
<Directory "/path/to/no/phpfiles">
<Files "*.*">
SetHandler !
</Files>
</Directory>
This is tested and working on Fedora 27, PHP-FPM 7.1.12.
Unlike using the fpm configs directly, this technique works recursively, so placing it at the top level of a tree of stuff you don't want PHP interpreting works as expected.
I disable .htaccess files in my configurations, but this technique should still work. However, <directory> is not valid inside a .htaccess file. Hopefully just removing it, and leaving:
<Files "*.*">
SetHandler !
</Files>
Should be sufficient.
How can I disable parsing of PHP files in a given web-accessible
directory with an htaccess/httpd.conf file that is located above web
root on a server using PHP-FPM?
You can't persay the way you're trying it without mod_php (which you don't want) which is why you're getting that error. PHP-FPM is not an Apache module. It runs independent of Apache. That's actually it's purpose to be used on heavily loaded sites and it can control all the PHP processes.
One way you might be able to achieve this is to specify the exact path you want to run PHP, in your virtualhost file with the Directory directive. Instead of just having the PHP handler stuff, enclose it with the Directory directive with the actual path you want it to run. Here is an example.
<VirtualHost *:80>
ServerAdmin webmaster#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html/
ErrorLog /var/www/example.com/error.log
CustomLog /var/www/example.com/access.log combined
<Directory /path/to/php/only/folder/>
#then you PHP handler stuff
<IfModule mod_fastcgi.c>
AddType application/x-httpd-fastphp5 .php
Action application/x-httpd-fastphp5 /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi_example.com
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi_example.com -socket /var/run/php5-fpm_example.com.sock -pass-header Authorization
</IfModule>
</Directory>
</VirtualHost>
Then restart Apache. This should limit it to that directory. You might have to remove the php handler info from the other config so it's not overwritten.
Note I have not tested this solution.

Set virtual directory as root in apache

In my linux server my www root of apache server is /var/www/html, I have a folder called blog in the above mentioned path. I have to access the the website in the blog folder by specifying http://myDomain/blog/. My question is I want to be able to access the website by specifying http://myDomain in the browser(without having to move the contents of the blog folder to www root). Is there any parameter which I can set in the config file so as to be able to achieve the mentioned objective.
Thanks.
Edited /etc/httpd/conf/httpd.conf file and search for DocumentRoot and change from
/var/www/html
TO
/var/www/html/blog
In your Apache httpd.conf file, just set the DocumentRoot as being /var/www/html/blog.

Apache DocumentRoot won't change

I am trying to change the DocumentRoot in httpd.conf from /var/www to /var/www/shop just so I can be organized. But even when I do that after restarting apache and httpd, I go to localhost and it still points to /var/www. My httpd.conf is basically the same as this file here:
http://www.devside.net/guides/config/linux/httpd-conf
I am running this on Debian.
Any ideas? Thanks
Debian uses various include files and a "site" concept, so httpd.conf isn't normally changed at all (the includes are). You likely changed the value before the "default" site changes it back to /var/www.

Resources