Katty
Katty

Reputation: 489

Is this possible to create subdomains on local server?

I am working on a project using ZF3 and my requirenment related to local server. Suppose user 'test' login on the system then url for that user should be http://test.10.1.1.55

I have already googled for this and found a post Create subdomains on the fly with .htaccess (PHP)

For production environment subdomain is working properly but not for development environment. My server guys said to me this is not possible for local server so my question is this posible to create subdomains on local server like as live server?

e.g. 
http://test.10.1.1.55
http://test1.10.1.1.55

Note: Local server means I am talking about a system that can be accessed from others system on browser.

Upvotes: 1

Views: 3632

Answers (2)

Tanner Black
Tanner Black

Reputation: 41

If you are using apache on Linux then you would go to

cd /etc/apache2/sites-avaiable/

cp 000-default.conf subname.localhost

nano subname.localhost.conf 

Modify DocumentRoot to the root folder of your subdomain Underneath add

ServerAlias subname.localhost
ServerName subname.localhost

Then remove the entry for:

<Directory /var/www/html>
</Directory>

Save and exit Then enable your new sub

sudo a2ensite subname.localhost.conf

sudo service apache2 reload

or

sudo service apache2 restart

Re-reading your question you may be able to just use test.localhost instead of the IP.

localhost is the url for your local server by default.

Upvotes: 1

Gabriel
Gabriel

Reputation: 1449

In this case, test.10.1.155 becomes a name, rather than an actual IP address.

You could edit your /etc/hosts file, to add all these named entries, mapped to the same local IP address.

Some additional help about the Hosts file:

https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

Upvotes: 0

Related Questions