MAMP multiple virtualhosts not working - wordpress

Somehow my virtualhosts won't work and give me The requested URL / was not found on this server. I have tried multiple things, but can't get it to work. My MAMP root folder is set to the Projects folder
I have the following folder structure:
-Projects
-website1
-websites
-public
-system
-website2
What I want is website1 to work on a different URL than website 2. What I have:
<VirtualHost *:8888>
VirtualDocumentRoot "/Users/myname/Documents/Projects/websites/system/%-3"
ServerAlias *.system.test
</VirtualHost>
<VirtualHost *:8888>
VirtualDocumentRoot "/Users/myname/Documents/Projects/websites/public/%-3"
ServerAlias *.public.test
</VirtualHost>
<VirtualHost *:8888>
VirtualDocumentRoot "/Users/myname/Documents/Projects/website1"
ServerAlias test.nl
</VirtualHost>
the hosts file:
127.0.0.1 website2.system.test
127.0.0.1 test.nl
I have also tried:
<VirtualHost *:8888>
VirtualDocumentRoot "/Users/myname/Documents/Projects/%-3"
ServerAlias *.test.nl
</VirtualHost>
Nothing seems to work to get website1 (wordpress website) working under test.nl any ideas? The reason why I have that folder structure is because "websites" is for work and the root for private projects. BTW whenever I put website1 in the system folder and add : website1.public.test to the hosts file it works, however when I put it in the public folder it doesnt, it looks like the only virtualhost read is the top one?

I finally found a fix: Apache 2 only serves first virtual host

Related

WAMP server - How to host more Wordpress websites?

I want to host more WP sites on WAMP server at the same time.
How to do that?
I would recommend you to download XAMPP. Basically WordPress is built on PHP and XAMPP has support for PHP. First download it and configure it then go to the installation directory and go to xampp>htdocs> then make a new folder 'project' and then unzip the WordPress files in that folder. After that read the manual provided ant xampp's website and follow it. Basically you can build your WordPress website on Xampp.
EDIT
Oh sorry for not understanding the question properly.
Now do this.
step 1: host the different websites in htdocs/ folder in xampp. You can host many websites as you want.
step 2: Then go to xampp/apache/conf/httpd.conf and uncomment the line which says this. For uncomment delete the '#' character.
Include conf/extra/httpd-vhosts.conf
step 3: Go to xampp/apache/conf/extra/httpd-vhosts.conf
Create the setup like this
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/xampp"
ServerName xampp
#ServerAlias
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/site1"
ServerName site1.com
ServerAlias www.site1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/site2"
ServerName site2.com
ServerAlias www.site2.com
</VirtualHost>
YES. You can make sub-folders in www and make different WP websites. But be careful with the database configuration. Installing WP does nothing but coping some PHP files to that specific folder. All the data is saved in database and inside that specific folder itself (E.g. config php files).

Home Page Wordpress on Free MAMP does not work

I have installed MAMP (free version) on my Mac and I see the Start Page but I have a problem:
I deployed wordpress but browser say unable to connect (basically I cannot see wordpress page in browser).
In Document Root if I put a static html file I am able to see it in the browser. I am also able to see wordpress administrative pages and all other pages but home page. I have 8888 and 8889 for php and mysql ports. I do not know how to debug the issues. php, apache and mysql do not report any particular problems.
I configured virtual hosts following this guide:
http://foundationphp.com/tutorials/vhosts_mamp.php
The strange thing when I put http://localhost:8888/mywebsite in the browser it is redirected to localhost/mywebsite.
In /etc/hosts I have:
127.0.0.1 localhost
In httpd.conf I activated:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
and in this file I have:
NameVirtualHost *:8888
<VirtualHost *:8888>
ServerAdmin myuser#gmail.com
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
ErrorLog "logs/mywebsite-error_log"
CustomLog "logs/mywebsite-access_log" common
</VirtualHost>
Hope someone could help.
I found the solution. After several debugging I found that this guide is correct: http://foundationphp.com/tutorials/vhosts_mamp.php
You need: 1. In /etc/hosts add your virtual hosts like:
127.0.0.1 localhost
127.0.0.1 mywebsite
before I only used localhost because I hoped to use this host in browser but I found it's required to define a new host like mywebsite.
In httpd.conf I activated:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
In this file I have:
ServerAdmin myuser#gmail.com
DocumentRoot "/Applications/MAMP/htdocs"
ServerName mywebsite
ErrorLog "logs/mywebsite-error_log"
CustomLog "logs/mywebsite-access_log" common

I cannot get Vhost to host multiple wordpress websites on centos 6.8

Issue: I cannot make the webserver host multiple websites.
Solutions I have tried:
I made two different Vhost.conf for the different websites(named differently according the website name but with the .conf extension. I then targeted different document roots linked to the websites within these config files. – Failed, displayed “connection refused”
I then went to the second website directory I created and change the file permissions to 755 (and 777 just incase) to check if that was conflicting and creating the issue, this also failed and made the same error.
Also all files have “chown -R root:root dir/ “ on.
I then went on to open port 8080 in iptables and changed the targeted port in the vhost of the second website to 8080, this also failed with the same error.
I tried finding the second website using “ip:8080, ip/secondwebsitedirectory, ip:80/secondwebsitedirectory” none of these worked. I followed each step of multiple tutorials online and none of these worked.
When I tested just making a directory and displaying the <?php phpinfo; ?> in index.php within the directory, then targeting that with the document root of the first virtual host block, this worked but did not display the second block’s website (I used the domain to link the alias to this and forwarded the domain to the servers ip).
My current vhost.conf file looks like this **NOTE: I removed ip’s and domains on clients request. They do work and have been tested so that isn’t an issue. Anything with “testsite” was originally the clients domain. **
I have made it two separate VirtualHost blocks previously and had the same result as I am having currently, I have had <VirtualHost *:80> on both blocks too.
<VirtualHost *>
ServerAdmin webmaster#testsite.org
ServerName ea
ServerAlias *server ip was here*
DocumentRoot /var/www/html/ea
ErrorLog /var/www/html/ea/logs/error.log
CustomLog /var/www/html/ea/logs/access.log combined
ServerAdmin webmaster#testsite.org
ServerName testsite
ServerAlias www.testsite.co.uk
DocumentRoot /var/www/html/testsite/public_html
ErrorLog /var/www/html/testsite/logs/error.log
CustomLog /var/www/html/testsite/logs/access.log combined
</VirtualHost>
The end result I want to come to is to be able to host multiple sites on my cloud server, these website are using Wordpress as that is the development platform I have been instructed to use and the server is running Centos 6.8 with all php and apache2 installed and working on one website.
As to a conclusion to this, I am stumped and need your help.
You need one statment for each site you want
<VirtualHost ea.mydomain.com:80>
ServerAdmin webmaster#testsite.org
ServerName ea.mydomain.com
ServerAlias ea
DocumentRoot /var/www/html/ea
<Directory "/var/www/html/ea/">
Options FollowSymLinks Indexes
AllowOverride None
# Use require all granted for apache 2.4
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/www/html/ea/logs/error.log
CustomLog /var/www/html/ea/logs/access.log combined
</VirtualHost>
<VirtualHost testsite.mydomain:80>
ServerAdmin webmaster#testsite.org
ServerName testsite.mydomain
ServerAlias testsite.mydomain testsite
DocumentRoot /var/www/html/testsite/public_html
<Directory "/var/www/html/testsite/public_html">
Options FollowSymLinks Indexes
AllowOverride None
# Use require all granted for apache 2.4
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/www/html/testsite/logs/error.log
CustomLog /var/www/html/testsite/logs/access.log combined
</VirtualHost>

How to configure apache to serve directory for custom domain

Currently, I have configured a domain I bought through GoDaddy to point to the elastic ip address of my personal ec2 instance. I'm having issues finding the correct solution to configure my httpd.conf such that my custom domain, example.com points to a specific subdirectory var/www/Example. Further, I want to be able to still access my other projects and sites by simply typing in the elastic ip and subdirectory.
I have tried the using a virtual host with the following configuration..
<VirtualHost *:80>
ServerAdmin webmaster#example.com
DocumentRoot "/var/www/html/Example/wordpress"
ServerName fitnessfifteen.com
ErrorLog "logs/example.com-error_log"
CustomLog "logs/example.com-access_log" common
</VirtualHost>
When I do this, I can access the correct content by going to www.example.com however, I'm unable to access my other files and projects via 11.11.111.111/OtherProjectDirectory (I get that default internal server error page). I'm completely new to this sort of stuff so many this isn't possible and I have a fundamental misunderstanding.
Add another virtual host to http.conf as below and restart apache.
<VirtualHost *:80>
ServerAdmin webmaster#example.com
DocumentRoot "/var/www/html/Example/wordpress/OtherProjectDirectory"
ServerName 11.11.111.111
ErrorLog "logs/example.com-error_log"
CustomLog "logs/example.com-access_log" common
</VirtualHost>

how to rename your localhost/myfolder in htdocs to some domain name

So we all know that to access your site inside htdocs you have to type "localhost/yoursite folder" right? but i have managed to change that by some help of my friend. now my friend is gone so i cant ask him to change it back. Instead of "localhost/yoursite" i can access it through "mysite.test" it has something to do with host.txt in system32. Now the problem is im installing a new drupal site in htdocs again and i cant access it since my localhost is always pointing to my first drupal site. how do i configure this?
HERE'S MY HOST.TXT
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 activate.adobe.com
127.0.0.1 drupal6.test
127.0.0.1 belmark.test
drupal 6 is my previous site. and belmark.test is the site i want the localhost to direct to which is not working. even if i omit the drupal6.test line localhost still directs to drupal6.test
and here's my httpd-vhost.conf
<VirtualHost *:80>
ServerAdmin cadaybelmark#gmail.com
DocumentRoot "C:/xampp/htdocs/drupal6"
ServerName drupal6.test
ServerAlias drupal6.test
ErrorLog "logs/drupal6.test-error.log"
CustomLog "logs/drupal6.test-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin cadaybelmark#gmail.com
DocumentRoot "C:/xampp/htdocs/drupal7"
ServerName belmark.test
ServerAlias belmark.test
ErrorLog "logs/drupal.test-error.log"
CustomLog "logs/drupal.test-access.log" combined
</VirtualHost>
You need to configure apache (via xampp) with additional vhosts, one for each site.
A vhost configuration maps a ServerName with a DocumentRoot. For example,
ServerName localhost
DocumentRoot /path/to/my/drupal
If you want a new, second site, you will need a second vhost for it. If you simply want to replace the original site with a new Drupal installation, your original vhost can stay the same (as long as you put in the exact same place as the original, which it sounds like you did not, since the old site is still loading).
See the XAMPP documentation for how to add/edit vhost entries.
not sure if i understood your problem right
create a subfolder in htdocs and install it there.
127.0.0.1/subfolder/yoursite
My god the answer is so simple. Apache just needs to be restarted. OK! thanks for the efforts guys.

Resources