-0.9 C
New York
Friday, January 17, 2025

Buy now

Php Programming:Steps for creating Virtual Host

Step #1:

Go to your Local Server’s Like as WAMP/XAMPP and Open httpd.conf file present in D:\xampp\apache\conf\httpd.conf ( XAMPP ) and D:\wamp64\bin\apache\apache2.4.51\conf\httpd.conf


Remove the #(hash) to include the “httpd-vhosts.conf” file in httpd.conf file. Like Below –

# Virtual hosts
#Include conf/extra/httpd-vhosts.confCode language: PHP (php)

to

# Virtual hosts
Include conf/extra/httpd-vhosts.confCode language: PHP (php)

Step #2:

Create a virtualhost file or modifying file. Open “httpd-vhosts.conf” file. And copy the below lines of code.

<VirtualHost *:80>
ServerName <SERVER_NAME like local.pos.com>
ServerAdmin [email protected]
DocumentRoot <PATH_TO_PROJECT_DIRECTORY_HERE>
	<Directory  "D:/wamp64/www/news24-media-ledger/public/">
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		AllowOverride All
		Require local
	</Directory>
</VirtualHost>Code language: HTML, XML (xml)

Practical Example:

#
<VirtualHost *:80>
	ServerName test.local.com
	DocumentRoot "D:/wamp64/www/test/public"
	<Directory  "D:/wamp64/www/test/public/">
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		AllowOverride All
		Require local
	</Directory>
</VirtualHost>Code language: HTML, XML (xml)

Replace PATH_TO_PROJECT_DIRECTORY_HERE & SERVER_NAME with your own values, Save the file.

Step3:

Open file called C:\Windows\System32\drivers\etc\hosts

Add the below line end of the file.

127.0.0.1      <SERVER_NAME like local.pos.com>Code language: CSS (css)

Restart your apache server and visit the site URL like – test.local.com.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

0FansLike
3,912FollowersFollow
22,200SubscribersSubscribe

Latest Articles