MAMP - Document root wont work properly - apache

MAMP - Document root won't work properly It only display one of my other projects, even If I change the root directory to my current project it just displays the same project as before. I can't change it at all no matter what I do, I have reinstalled MAMP 4 and MAMP 3. No matter what I do there is the same problem? CAN ANYONE HELP!!

This not DocumentRoot issue it's Directory issue because of MAMP use Apache 2.2.32. Apache2.2 and Apache2.4 are different Vhost format. MAMP version history.
Apache 2.2 Vhost format:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/Applications/MAMP/Library/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
Apache 2.4 Vhost format:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/Applications/MAMP/Library/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
<Directory "/Applications/MAMP/Library/docs/dummy-host2.example.com">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
Apache Vhost format reference.
If you use MAMP your issue will not solve. Try Apache 2.4. If you are Windows user then use XAMPP or WAMP. If you are Mac user then use XAMPP.

Related

MAMP Apache Won't Start with Virtual Host for SimpleSAMLphp

I'm attempting to configure simpleSAMLphp within a MAMP/Apache environment on Windows 10 and below is my httpd-vhosts.conf file:
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/MAMP/htdocs
</VirtualHost>
<VirtualHost *:80>
ServerName simplesamlphp
DocumentRoot C:/MAMP/htdocs/pro-dashboard
Alias /simplesaml C:/MAMP/simplesamlphp/www
<Directory C:/MAMP/simplesamlphp/www>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And here is my /etc/hosts file:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# Virtual Hosts
127.0.0.1 simplesamlphp
Apache starts via MAMP totally fine without including this httpd-vhosts.conf file in my httpd.conf file, but as soon as its included, Apache will not start so the issue appears to be with httpd-vhosts.conf. No errors are shown in the apache_error.log file. My Apache version is 2.2 so I believe my Directory directives in my second VirtualHost are correct.
I've tried double quoting the DocumentRoot's, directory paths etc, and also tried backslashes over forward slashes. I spent most of yesterday trying to figure this out while scouring the web but nothing I found has made this work.
Any help is much appreciated!
Try this modified config
The path in Directory header same as DocumentRoot!
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/MAMP/htdocs
</VirtualHost>
<VirtualHost *:80>
ServerName simplesamlphp
DocumentRoot C:/MAMP/htdocs/pro-dashboard
Alias /simplesaml C:/MAMP/simplesamlphp/www
<Directory C:/MAMP/htdocs/pro-dashboard>
Order allow,deny
Allow from all
AllowOverride All
</Directory>
</VirtualHost>
So oddly enough, taking out what I had in httpd-vhosts.conf and simply putting it in my httpd.conf file makes Apache start back up.

virtual host for xampp on Mac

in my httpd-vhost.conf on macos 10.15.4,
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/theb/"
ServerName theb.localhost
ServerAlias www.theb.localhost
#DirectoryIndex index.html
<Directory "/Applications/XAMPP/xamppfiles/htdocs/theb">
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride none
</Directory>
ErrorLog "logs/theb.local-error_log"
</VirtualHost>
I have also included the virtual host in httpd.conf
Include etc/extra/httpd-vhosts.conf
Then in the host file, i have
127.0.0.1 localhost
127.0.0.1 www.theb.localhost
The issue im facing now with these configs is that whenever i browse the site in my browser,
http://www.theb.localhost, i will then be redirected to http://www.theb.localhost/dashboard ( which is the xampp default project folder). did i miss something out??
Restart Apache. Hopefully that will work.
If you have downloaded the VM version of Xampp (The one that gets mounted) then this wont work as it doesn't have access to your local files, get the non VM one here https://sourceforge.net/projects/xampp/files/XAMPP%20Mac%20OS%20X/7.4.6/xampp-osx-7.4.6-0-installer.dmg/download

Hosting another website on linux AMAZON EC2 intance running bitnami wordpress

I have an EC2 instance created with Bitnami wordpress, I am trying to host my other website on the same instance website.tld
I followed the steps on this guide
https://docs.bitnami.com/aws/components/apache/#how-to-create-a-virtual-host
Then I went to "/opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf" and changed it to
<VirtualHost *:80>
ServerName mywordpress.com
ServerAlias mywordpress.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
<VirtualHost *:80>
ServerName website.tld
ServerAlias www.website.tld
DocumentRoot "/opt/bitnami/apps/website/htdocs"
ErrorLog "logs/website-error_log"
CustomLog "logs/website-access_log" common
</VirtualHost>
<VirtualHost *:443>
ServerName mywordpress.com
ServerAlias www.mywordpress.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
SSLEngine on
SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
I created the empty folders "/opt/bitnami/apps/website/htdocs" for my new website then added an index.html inside htdocs
Then I restarted the apache server
sudo /opt/bitnami/ctlscript.sh restart apache
mywordpress.com works fine as before, but when i try to open website.tld I get this error
Forbidden
You don't have permission to access / on this server.
Am i doing it wrong? is there any other configurations i missed?
What is more confusing is there are httpd-vhosts.conf files inside the apache2 server and inside each folder in the apps/ folder, I am not sure which of all I should be adding my new domain tag into? Following the bitnami docs I edited the one inside apps/wordrpess/config
I am not a server side guy, is there a UI for the apache server that can help me setup the virtual host?
Thank you in advance.
You have to set the permissions for this directory in apache2.conf/ httpd.conf.
<Directory [your path]>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
And set the permissions with chmod 755

Apache VirtualHost not pointing to correct subdirectory

I am a newbie to apache and server setup. I am migrating several sites from GoDaddy to a DigitalOcean VPS droplet. I am moving my first site over (a Wordpress install) and am having some trouble with VirtualHost. Here is the configs:
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/html/domain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Heres the thing, I have a www alias set up in the domain name records, and www.domain.com points correctly to the site, but domain.com points to the root var/www/html, not the subdirectory where the site is. I've searched for far too long, but every tutorial and forum seems to provide the same code I currently have configured. What am I doing wrong? I want to make sure it all works correctly before I take the next step of installing an SSL, but I am spinning my wheels at the moment.
The correct way to set up a virtual host is:
<VirtualHost *:80>
ServerAdmin admin#domain.com
DocumentRoot /path/to/the/directory
DirectoryIndex index.html index.php
ServerName domain.com
ServerAlias www.domain.com
ErrorLog ${APACHE_LOG_DIR}/domain.com.error.log
CustomLog ${APACHE_LOG_DIR}/domain.com.access.log combined
<Directory /path/to/the/directory>
Options -Indexes
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

How to configure Apache to serve Drupal 6 Multisite configuration

I am trying to setup Apache to serve a Drupal 6 multi-site configuration, but I cannot seem to get it properly set up.
In my httpd.conf:
DocumentRoot "/Users/kevinyoung/Sites/drupal"
<Directory "/Users/kevinyoung/Sites/drupal">
Options FollowSymLinks Multiviews Indexes
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
DirectoryIndex index.html index.php
In httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot "/Users/kevinyoung/Sites/drupal"
ErrorLog "/private/var/log/apache2/error_log"
CustomLog "/private/var/log/apache2/access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerName drupal.local
ServerAlias *.drupal.local
DocumentRoot /Users/kevinyoung/Sites/drupal
ErrorLog "/private/var/log/apache2/error_log"
CustomLog "/private/var/log/apache2/access_log" common
</VirtualHost>
In /etc/hosts:
127.0.0.1 drupal.local
127.0.0.1 <site_name>.drupal.local
Navigating to http://localhost shows "It Works!".
Navigating to drupal.local takes me to the default site for my D6 multi-site setup.
Now lets say I have another site directory (site_A.drupal.local) as another site inside drupal/sites/. Now I go to site_A.drupal.local, but it still takes me to the default site. Why would this be happening?
Any ideas why I can't access any other site besides my default site in this Drupal 6 multi-site configuration?
I am running Apache 2.4 on Mac OSX 10.10 Yosemite with Drupal 6, mysql 5.1.73, and php 5.5.14.