cannot find apache conf.d file in mac - apache

I am using MAMP on MAC OSX.
I am trying to create a virtual host using the code. It is in a file named LaravelTest.conf. However I will need to place this file in apache's conf.d directory (I believe).
<VirtualHost 127.0.0.2>
DocumentRoot "/Applications/MAMP/htdocs/l4/project/public"
ServerName LaravelTest
<Directory "/path/to/laravel/project/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
</Directory>
</VirtualHost>
Where do I find the conf.d directory ? It is not present in /etc/apache2

Since you are using mamp, you could find the Apache configuration file at
/Applications/MAMP/conf/apache/httpd.conf
To be able to include your vhost file, you should add the following on the config
Include /path/of/LaravelTest.conf
Or you can just add an additional VirtualHost on your apache config file.

Related

Directory 'static' gives 404 error

On a Windows machine running XAMPP I have a folder in my web root called 'static'. It and everything in it return a 404 error even though the folder is there.
If I change the name of the folder, e.g. 'statics', all is well. I have other servers (Ubuntu) running Apache and I do not have this problem.
The site is a copy of one of the sites on one of our Linux servers. What can I do or change to allow the directory to work as named?
EDIT vhosts.conf
<VirtualHost *:8080>
ServerAdmin jablanchard#foo.com
DocumentRoot "C:/xampp/htdocs/home/app/gateway"
ServerName localhost
ServerAlias 127.0.0.*
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
</VirtualHost>
<Directory C:/xampp/htdocs/home/app/gateway/>
# allow .htaccess overrides to work
AllowOverride All
DirectoryIndex login.html index.html index.php
</Directory>
# this matches a link to any project directory to the physical webui directory
AliasMatch ^/projects/([-\w]*)/(.*)$ /home/src/gateway/webui/$2
<Directory /home/src/gateway/webui>
DirectoryIndex home.html
Options All
AllowOverride All
Require all granted
</Directory>
I was getting ready to re-install XAMPP but made one last pass through the config files for Apache. I found the problem was this bit of code in the httpd.conf file -
Alias "/static" "C:/xampp/htdocs/static"
<Directory "C:/xampp/htdocs/static">
AllowOverride All
Require all granted
</Directory>
I am not sure if this is part of the XAMPP install as all of the edits I have made to this installation are in the vhosts file. Once commented out the static directory, as I have defined it, works properly now.

How come Apache retrieves files from the `html` subdirectory when only `/var/www` is specified in `<Directory>` path

I have the following (default) <Directory> directive in my apache2.conf configuration file:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and the /var/www directory contains only an html directory with an index.html file inside and no .htaccess (neither near or in the html directory). What default configuration value makes Apache give me files fro the html directory? I would have expected that the DocumentRoot (if nowhere provided) is the Directory path.
I am not sure which OS and distro you are using, but my Mint/Ubuntu has /etc/apache2/sites-available/000-default.conf which DocumentRoot is /var/www/html
Please check if you have the same VirtualHost

Apache directory listing

I am unable to stop apache from creating directory listings when using the server IP address. I have tried editing the relevant site-available files as follows;
<VirtualHost *:80>
JkMount /* default
ServerName example.co.uk
ServerAlias www.example.co.uk
ServerAdmin me#example.co.uk
DocumentRoot /var/www/example.co.uk/public_html
ErrorLog /var/www/example.co.uk/logs/error.log
CustomLog /var/www/example.co.uk/logs/access.log combined
<Directory /var/www/example.co.uk/public_html>
Options -Indexes
</Directory>
</VirtualHost>
...but the public_html folder contents are being listed if I access the server using a url of this format;
http://192.168.1.99/example.co.uk/public_html
I have also tried to amend the apache config file at /etc/apache2/apache.conf to include the following;
<Directory />
Options -Indexes
</Directory>
..but no joy.
I am using Tomcat, and I need my WEB-INF folder to deny access. It doesn't, and so any .class files can be downloaded.
Does anyone know how I can fix this?
thanks
This sounds a little weird. Do you have an Apache HTTPD in front of an Apache Tomcat Server?
In this case the Apache HTTPD must not point to a directory where the Apache Tomcat files reside! The communication between both can be seen more as a proxy rather than a plugin.
We have some good experience using mod_proxy_ajp for this purpose. But if you are able to download .class files and (panic mode on) the web.xml (panic mode off) something is terribly wrong.
This means that it will not reach your VirtualHost settings, but default virtual host settings.
You have 2 options (at least):
1, put .htaccess file to your directory for which you want to restrict listing
2, Setup you IP based virtual host with similar settings as your name-based vhosts
You said that you put
<Directory />
Options -Indexes
</Directory>
You should have Location instead of Directory there
What if you add /* to the end?
<Directory /var/www/example.co.uk/public_html/*>
Options -Indexes
</Directory>
Update:
Or try to add the entry outside the VirtualHost directive.

How do I create a VirtualHost on Zend Server?

I am using zend server and I added one VirtualHost into the extra/httpd-vhosts.conf file and removed # from the httpd.conf file.
This is what I added into the extra/httpd-vhosts.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName quickstart.local
DocumentRoot D:/quickstart/Code
<Directory D:/quickstart/Code>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I access quickstart.local it is working fine, but it also affects localhost (i.e when I try to load http://localhost/, I see the same site I do for http://quickstart.local/.
How do I resolve this issue? I want both localhost (I use this for another project) and quickstart.local to be separate.
I have the same problem. Try to add a host to zend.conf or
add
Include conf/extra/httpd-vhosts.conf
to htppd.conf
You can add a new vhost by adding the directives to a new file:
/path/to/zend/etc/sites.d/vhost_[my-site].conf
Replace [my-site] with whatever you want (no spaces).
Then, be sure you restart apache:
sudo /path/to/zend/bin/apachectl restart
I had similar issue when trying to add own sites. Solution for me was to comment both vhost examples in vhosts file and also uncomment or add the
127.0.0.1 localhost
into hosts file in %windir%/system32/drivers/etc folder
... ofcourse if you need to uncomment vhost_alias module and include for httpd-vhosts file..
[FILE PATH] \xampp\apache\conf\extra\httpd-vhosts.conf or, if you are
using Apache 2.4 or above:
<VirtualHost *:80>
ServerName dev.zendapp
DocumentRoot "G:/xampp/htdocs/io2018/zend2018/zendApps"
SetEnv APPLICATION_ENV "development"
<Directory "G:/xampp/htdocs/io2018/zend2018/zendApps">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
After change. C:\Windows\System32\drivers\etc\hosts
127.0.0.1 dev.zendapp
Restart Your xampp Server

Local sub-domains on httpd apache

I have on my machine wampp server installed that I use to run php applications.
There are many folder in the htdocs with inside my projects and I can see those in the browser at this url: localhost/folder-name/.
I'd like to see every project in a custom url like: dev.name-folder.com
With IIS is very easy to do that, can someone explain how do that with Apache, using wampp server?
Thanks.
You can change your C:\Windows\System32\drivers\etc\hosts file to map domain names like dev.name-folder.com to your local system. (Otherwise you'll have to use a DNS server).
To configure a vhost in apache create a file for each domain/project you'd like to serve:
<VirtualHost *:80>
ServerAdmin email#domain.tld
ServerName domain.tld
DocumentRoot /var/www/htdocs/domain.tld/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/htdocs/domain.tld/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
ServerName is the domain name you'd like to serve your files under. DocumentRoot must be set to the absolute path to your files (here taken from a linux system).