So i have a public network VM set up with Vagrant and PuPHPet to get an apache web server up and running. I'm using Laravel as my framework of choice. I can access my site in my browser by visiting the following:
http://192.168.1.14/public/index.php/
Using PuPHPet i configured my vhost to use "phptest.dev" as the Server Name.
I'm a little stuck on how i should set a vhost to prettify my url. I'm not sure where the "phptest.dev" server name comes into play. I can't ping phptest.dev and get anything back.
What is the proper way to set this up? I'd like to visit "phptest.dev" in my browser to see my site. I think i need to add an .htaccess file to route all requests through the 'public/index.php` file so i can get that out of the url but i'm not sure.
Don't know PuPHPet but I can answer in a generic way.
You can use /etc/hosts file to do name resolution, as long as you haven't changed /etc/nsswitch.conf.
For example in /etc/hosts, add
192.168.1.14 phptest.dev
You should be able to ping the hostname from within the VM.
Suppose you are using Debian/Ubuntu, the sites configuration file is in /etc/apache2/sites-available/phptest.dev.conf
NOTE: don't forget to create a symbolic link in sites-enabled
<VirtualHost *:80>
ServerAdmin EMAIL
DocumentRoot /path/to/php
ServerName phptest.dev
ServerAlias www.phptest.dev
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /path/to/php>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/phptest.dev-error_log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/phptest.dev-access_log combined
</VirtualHost>
Do a service apache2 reload or restart and see if you can access by using phptest.dev
I can't respond directly to Terry Wang, but he's mostly right.
Ignore everything past his 4th line, though, because PuPHPet takes care of setting up the vhost in your VM for you.
You simply need to tell your local machine (your Mac or your Windows or maybe your Linux machine) that the domain phptest.dev is located at ip address 192.168.1.14.
That's why you need to edit your hosts file.
Related
Every http site in my newly installed WampServer 3.1.0 64-bit is automatically redirecting simple index.html files with no .htaccess to the https version of the site.
I can see no .htaccess file in C:\wamp64\www or C:\wamp64\www\example.
If I uninstall WampServer, and install XAMPPserver, the same thing occurs.
Help appreciated.
httpd-vhosts.conf:
<VirtualHost www.superiorit.dev:80>
ServerAdmin steve.doig#superiorit.com.au
DocumentRoot "C:/xampp/htdocs/superiorit"
ServerName www.superiorit.dev
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
httpd-ssl.conf: is the standard default file.
The only change I have made to httpd.conf is:
Listen 172.18.1.106:80
I noticed the Chrome icon in the Windows task bar looks different to the normal Chrome icon:
If I load the site in Edge, the redirection does not occur.
Within a Virtual Host definition you also need tell Apache it is allowed to access the directories that hold the site code i.e. a <Directory>
I also learned recently that Google owns the .dev tLD so you should consider using something else instead, specially if you are using Chrome browser as google could add anything in there to pick up the use of .dev and, well, do anything.
I now find out that as of V63 Chrome does in fact force a redirection of .dev
This will also be happening to FF and other browsers
You also dont need to specify the domain name on the <VirtualHost www.superiorit.dev:80> line. The * is fine.
So try this an see if things improve.
<VirtualHost *:80>
ServerName superiorit.local
ServerAlias www.superiorit.local
DocumentRoot C:/xampp/htdocs/superiorit
<Directory "C:/xampp/htdocs/superiorit/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
ErrorLog "logs/superiorit.local-error.log"
CustomLog "logs/superiorit.local-access.log" common
</VirtualHost>
Also have a look at Why all *.dev domains target to my localhost?
AND https://tech.slashdot.org/story/17/09/18/192227/chrome-to-force-domains-ending-with-dev-and-foo-to-https-via-preloaded-hsts
Your problem is your .dev URLs, like RiggsFolly suggested. Thats why it works in other browsers like Edge. This is a new feature coming with Chrome 63. See articles below:
https://superuser.com/questions/1276048/starting-with-chrome-63-urls-containing-app-redirects-to-https
https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/
I'm trying to publish a locally installed WordPress website - publically.
Had to reformat my laptop, so now running Windows 10 from my laptop at home.
I can already RDP to it from e.g. work PC, externally, etc.
I used to have Windows 8, WAMP installed and used to publish websites to my domain - www.site01.co.uk
site01.co.uk has been pointing to my fixed IP since I had Windows 8 and still is pointing. The fixed IP address hasn't changed.
I now opened up XAMPP httpd.conf and placed below "code" at the bottom:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\wp"
servername http://www.site01.co.uk
<Directory "C:\xampp\htdocs\wp">
Allow from all
Require all granted
Options Indexes
</Directory>
</VirtualHost>
This didn't work .
WordPress is installed in htdocs\wp folder.
You have a couple of problems with your Virtual Hosts definition. Virtual Hosts is definitely the way to go though.
When you create a Virtual Host Apache ignores the default definition of localhost in your httpd.conf file so its always a good idea to include a VH definition for that as the first VH defined, with access limited to Require local this helps stop drive-by ip address access attempts as the Require local will return an Access denied if you/they just use your WAN ip to try and see whats on your web server.
This should go in the \xampp\apache\conf\extra\httpd-vhosts.conf file. Remove all the example stuff from that file when you add this definition.
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
<Directory "C:\xampp\htdocs">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\wp"
ServerName site01.co.uk
ServerAlias www.site01.co.uk
<Directory "C:\xampp\htdocs\wp">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
Apache 2.4 uses the Require parameter and not the Allow/Deny which was Apache 2.2 syntax.
You now edit the httpd.conf file and find the
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
and remove the # comment like so
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Then make sure that the Port Forwarding on your router is forwarding port 80 to the correct ip address for your PC.
I am posting this because I recently had a lot of trouble setting up a Virtual Host with a MAMP stack, due to Apple's throttling of the useable PHP version on Mac OS 10.8's default Apache2 installation.
This is a very quick guide on what to do and I owe the solution to this question on Stack Overflow:
Information Source
You can think of this as a compilation of what worked for me, as the accepted answers had no effect, but rather those with a significantly lower score.
Similarly, every guide I have seen fails to mention some points which users answered with on the sourced question.
Step 1: Install and configure Apache.
Make sure you specify what port you want to listen on, for me I specified 8080. This will be the case for this series of instructions.
Listen 8080 - Default is 80
Step 2: Edit your /etc/hosts file to spoof your loopback address, 127.0.0.1
127.0.0.1 localhost
127.0.0.1 some.example # domain-name.domain-TLD
127.0.0.1 www.some.example # The same as the above line, but with www. prefixed
You should really add a handle for subdomains on your web server, Apache or Nginx (or whatever else you use. Something that routes www to non-www.
Step 3: Enable the Virtual Hosts import on Apache.
Open your httpd.conf file located within Apache2's subdirectories. Usually within /conf
Uncomment the line that resembles this: Include conf/extra/httpd-vhosts.conf
Also uncomment this module import: LoadModule log_config_module modules/mod_log_config.so
Step 4: Configure your Virtual Hosts file
Find your Virtual Hosts config, httpd-vhosts.conf, you can comment out the two example Virtual Hosts in the file. Usually within /conf/extra
Copy your own Virtual Host into the file from this template:
<VirtualHost *:80> # Change the 80 to the number Apache2 "Listen"s on. In my case, 8080
ServerName SERVER-ADDRESS # E.g. mywebsite.local
ServerAlias WWW.SERVER-ADDRESS # E.g. www.mywebsite.local
DocumentRoot " SERVER-FILE-ROOT " # E.g. "Users/user-name/Sites"
<Directory /> # This should be a full path, though
Require all granted # Required for permission errors
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride none
</Directory>
</VirtualHost>
You're Done!
Once your Virtual Host has been edited to your liking you are done, just restart Apache and enjoy.
This guide already includes the fixes implemented, but in-case you still get permission errors:
You MUST make sure that your DocumentRoot is not inside any documents your user explicitly owns. If it needs to be, give "Read Only" access to "Everyone" on Mac for that particular folder, E.g. "Documents" or "Movies" etc....
Although the above answer is much explanatory, the following 2 things are most important when you are migrating virtual hosts to apache 2.4
Go to wamp/bin/apache/apache2.4.x/conf/httpd.conf find #Include conf/extra/httpd-vhosts.conf and uncomment to Include conf/extra/httpd-vhosts.conf
Add the virtual hosts in wamp/bin/apache/apache2.4.x/conf/extra/httpd-vhosts.conf as
<VirtualHost *:80>
ServerAdmin admin#localhost.com
DocumentRoot "H:/Wamp/www/mysite"
ServerName mysite
ServerAlias mysite
<Directory />
Require all granted
</Directory>
</VirtualHost>
Note: <Directory **/**> the / is important
I am trying to set up a virtualhost on my apple mac on localhost. The server is provided by XAMPP, which bundles Apache/MySQL/PHP in one bundle.
Here is what I have done so far:
Edited /private/etc/hosts to include 127.0.0.1 to point to test.myserver.local
127.0.0.1 test.myserver.local
Edited /Applications/XAMPP/etc/extra/httpd-vhosts.conf to inlcude my vhosts details
<VirtualHost *:80>
DocumentRoot /Users/???/Documents/workspace/trunk/htdocs
ServerName test.myserver.local
<Directory "/Users/???/Documents/workspace/trunk/htdocs">
AllowOverride All
</Directory>
</VirtualHost>
Placed a simple index.html in there with the word test in it.
I have restarted the server, and then browse to the test url to be greeted with Apache's default page instead of my test page.
The vhosts file works for another virtual host, the code is copied with the respective bits changed (i.e. folder paths), the hosts file works, as when Apache is turned off, my browser says server not found.
Why is Apache refusing to show up my test code? Are there any other files I need to change? I cant think of any others, its usually just those on linux/windows.
On xampp you need to edit 3 files to setup virtual hosts
the /etc/hosts and /Applications/XAMPP/etc/extra/httpd-vhosts.conf as you did.
But also you need to edit /Applications/XAMPP/xamppfiles/etc/httpd.conf to include the http-vhosts.conf
make sure you have uncommented this line
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
EDIT
Have you tried to add this lines
Order allow,deny
Allow from all
Just before the
AllowOverride All
Try leaving the the setting for "localhost" at the end of the file "httpd-vhosts.conf",
i.e.:
#
# Virtual Hosts
#
...
# others vhost
<VirtualHost *:80>
...
</VirtualHost>
# localhost
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
#end of httpd-vhosts.conf file
Worked for me, greetings!
Have you told Apache to actually use name-based virtual hosting?
# Use name-based virtual hosting.
#
NameVirtualHost *:80
I don't believe it's enabled by default in Xampp on Mac.
I am running XAMPP 1.7.3 on windows 7. My problem is that when I try to access my server (localhost) from another computer, the server does not respond. For example, [on my computer] when I type in 'http://localhost', my pages come up. However, when I try accessing 'http://192.168.0.102' from my computer, nothing happens. When I type in my external IP, nothing shows up, but when add HTTPS to the external IP, my Linksys WRT54GS config page shows up, asking for a password. I have already tried port forwarding and a local "static IP", and no luck, other than my local IP never changing. Can anyone help me?
Here's how I have my XAMPP installation configured. Maybe it will work for you.
Open C:\xampp\apache\conf\extra\httpd-vhosts.conf
Add a VirtualHost block for each site you are running:
Apache config
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot C:/path/to/website/files
ServerName exampledomain.dev
<Directory "C:/path/to/website/files">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Add a line to your hosts
127.0.0.1 exampledomain.dev
On the connecting computer's host file:
192.168.0.102 exampledomain.dev
You can easily access your hosts file by using ctrl+r and running
notepad %SYSTEMROOT%\system32\drivers\etc\hosts