Php change server name

PHP Web Server — Change localhost to custom domain name?

On Windows systems there are two additional ways to map names to IP addresses: a WINS server and the LMHOSTS.SAM file; these are mostly relics of old times when Windows networking didn’t use DNS name resolution, but they still work. dDonot forget to put domain names in host file in your computer.

PHP Web Server — Change localhost to custom domain name?

I am currently creating a Laravel project and need to store cookies in a http://localhost:8000 address, of course, I have found out that to set a cookie through JavaScript, the domain must have two or more periods (.) in.

Obviously, with the address set to localhost:8000, cookies fail to be stored. I need to be able to fake my host to point something like http://dev.project.laravel as opposed to localhost:8000

Apologies if I’m not making sense, but hopefully you catch my drift. Thanks in advance for any help given.

Assuming you have Windows OS and have installed XAMPP (or similar) stack:

    Add the following line to httpd.conf file under # Supplemental configuration which is in the configuration folder of apache. (I have XAMP installed and for me, this path is: C:\xampp\apache\conf )

Include conf/extra/httpd-vhosts.conf 

it should be around line 484

if you already have that line, but its commented out, then un-commment it.

  1. Add the following to your httpd-vhosts.conf file (which, in my case, is located at C:\xampp\apache\conf\extra )—

In the first line below, change 80 to whatever port your localhost is running on. if you do not use port to access localhost, then leave it as 80)

  DocumentRoot "C:/xampp/htdocs/" ServerName desired.name.of.your.site ServerAlias desired.name.of.your.site 
  1. And lastly, and most importantly, add the following in your hosts file (for me, this is located at C:\Windows\System32\drivers\etc ) and then restart apache
127.0.0.1 desired.name.of.your.site 

If you have a LAMP stack, the above should still apply. just the folder paths would need to change.

Windows localhost domains Code Example, # C:\\Windows\\System32\\Drivers\\etc\\hosts 127.0.0.1 beans.beans.local

Читайте также:  Python тип данных символ

Access site with domain name without editing hosts file or setting up DNS

Im setting up multiple sites on IIS 10, using port 80. This is only in a home env, not accessible from the outside.

I would like all devices to be able to access these sites with domain name, without editing the hosts file or setting up DNS.

It seems possbible in apache See here: https://webmasters.stackexchange.com/questions/111006/how-to-access-a-website-through-a-local-area-network-that-localhost-change-to-a

Can it be done in IIS? Where do I read up on this?

The only ways for a computer to know the mapping between a name and an IP address are DNS or local hosts files. What you want is not possibile.

Updated for completeness.
On Windows systems there are two additional ways to map names to IP addresses: a WINS server and the LMHOSTS.SAM file; these are mostly relics of old times when Windows networking didn’t use DNS name resolution, but they still work.
A WINS server needs to be hosted by a Windows Server system, so you’d need a server to run it; I don’t really think this would fit your needs.
The LMHOSTS.SAM file works like the HOSTS file, but with a different syntax; it’s also located in the same place: C:\Windows\System32\drivers\etc .

Hi please check site binding and change domain name for each site in binding with port 80 in IIS configuration window. dDonot forget to put domain names in host file in your computer.

Bind to a URL that ends with localtest.me and it will resolve to 127.0.0.1

As others have commented, this is because there is a public DNS that flags this — and all subdomains — to 127.0.0.1. This is useful since if you have a website you need hosting locally and yet have no access to the hosts file, you can just add this website binding in IIS for your site.

Localhost domain name windows Code Example, # C:\\Windows\\System32\\Drivers\\etc\\hosts 127.0.0.1 beans.beans.local

How to create a domain name for localhost

# C:\Windows\System32\Drivers\etc\hosts 127.0.0.1 beans.beans.local

Windows hosts file and host name with dot, # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and …

Change localhost to domain name mac

Windows — redirect domain request to localhost without, Then you create a new domain (with the name of the DNS name to be redirected) on your local DNS server, and include an address record in the zone file of that domain, specifying the desired IP address (127.0.0.1). There is one more step that might be neccessary: if your machine cannot reach the Internet DNS …

Читайте также:  Upload xml to php

Источник

Apache: How to change the server name from localhost to custom name

I recently installed the Bitnami WAMP stack which simultaneously installs Apache 2, PHP, and MySQL. The default domain name when installing Apache server is either “localhost” which is found at the default IP address of 127.0.0.1. For example, web pages can be found at:

and scripts in the cgi-bin can be accessed like so:

http://localhost/cgi-bin/env.py http://127.0.0.1/cgi-bin/env.py

What I wanted to do was use a made up local domain name instead, called “bluegalaxy.dev”. With the Bitnami Apache configuration, the way to do this is very simple and was just a matter of editing my Windows 10 “hosts” file. This file is located at:

C:\Windows\System32\drivers\etc

Open the “hosts” file in Notepad++ or another plain text editor (Run in Administrator mode). The solution is to add a new line to the hosts file with 127.0.0.1 on the left, and the desired server name on the right. Note: You MUST remove the pound sign, or this won’t work.

Now I can still access the server via localhost, but I can also use my made up server name in script URLs. For example:

http://bluegalaxy.dev http://bluegalaxy.dev/cgi-bin/env.py

Note: In the Environment variables, this affects both SERVER_NAME and HTTP_HOST, but it does not affect the REMOTE_ADDR, which stays at 127.0.0.1.

Update (April 8, 2018): Local host names with “.dev” can no longer be used without https.

What was working before at bluegalaxy.dev was no longer working, so I changed the local domain to “bluegalaxy.local”.

Note: In addition to having multiple local domains point at 127.0.0.1 by editing the hosts file:

These different local host names can point to different server paths. This is done by editing the httpd-vhosts.conf file of the Apache server, which can be found here:

C:\Bitnami\wampstack-7.1.14-0\apache2\conf\extra\httpd-vhosts.conf

For example, localhost should point to the htdocs folder and I want lsapp.local to point to a specific folder inside htdocs called lsapp/public:

 DocumentRoot "C:/Bitnami/wampstack-7.1.14-0/apache2/htdocs" ServerName localhost DocumentRoot "C:/Bitnami/wampstack-7.1.14-0/apache2/htdocs/lsapp/public" ServerName lsapp.local 

1. In order for Apache to use the httpd-vhosts.conf file, this line inside the httpd.conf file needs to be uncommented (remove the pound sign from the beginning of the line):

# Virtual hosts Include conf/extra/httpd-vhosts.conf

2. The Apache server needs to be restarted in order for the changes to be seen.

Источник

How to change programmatically change name server using php

I have a website that receives occasional but predictable traffic spikes and my website crashes or slows down. Is it possible for me to change the name-servers programmatically using php or any other language so that the server changes after the traffic touches a certain peak. I am using a godaddy-windows hosting. And I do not want to use cloud computing.

Читайте также:  Примеры unit test python

Answer

Solution:

You aren’t going to have much luck because the load balancing stuff happens before PHP like apache. You probably will have to upgrade.

You would have to use something like a load balancer on a proxy that distributes traffic before it hits your server. Its very tricky to do and its almost impossible through a godaddy like host because you can’t customise anything on a VPS.

Answer

Solution:

You can’t just change nameservers for load balancing (CDNs are based on that principle, but they are implemented on the DNS, since changes need time to propagate). You could pay for more resources and balance them using a proxy, but a better solution is to move your app to Amazon AWS, Google App Engine or a similar cloud based service: they handle load balancing much more efficiently, and that’s what you need for occasional spikes (otherwise you end up paying for horsepower you only use occasionally)

Share solution ↓

Additional Information:

Didn’t find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Similar questions

Find the answer in similar questions on our website.

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

About the technologies asked in this question

PHP

PHP (from the English Hypertext Preprocessor — hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/

Welcome to programmierfrage.com

programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.

Get answers to specific questions

Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.

Help Others Solve Their Issues

Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.

Источник

Оцените статью