Skip to content

Instantly share code, notes, and snippets.

@regepan
Last active November 14, 2018 01:20
Show Gist options
  • Save regepan/18250529182224dec53f8fbb83a4d8d1 to your computer and use it in GitHub Desktop.
Save regepan/18250529182224dec53f8fbb83a4d8d1 to your computer and use it in GitHub Desktop.

Add new port number based virtual host.

on Mac OSX 10.11.4 El Capitan

If you create virtual host, you can use document root for each project.

Add new virtual host

$ sudo vim /etc/apache2/extra/httpd-vhosts.conf

Add like following. In this case 3025 is port number.
You can add port number you like.
Edit port number & directory name.

<VirtualHost *:3025>
    DocumentRoot "/Library/WebServer/Documents/hoge"

    <Directory "/Library/WebServer/Documents/hoge">
      Options FollowSymLinks Indexes
      AllowOverride All 
      Order deny,allow
      Allow from all
   </Directory>
</VirtualHost> 

When you finished add above codes.
Type :wq command on Vim editor to save & finish Vim editor.

Open new port number.

$ sudo vim /etc/apache2/httpd.conf

Add following code around Line 52~ to open port.

Listen 3025 

When you finished to edit.
Type this command :wq to save & finish Vim editor.

Restart Apache to activate new virtualhost you created.

$ sudo apachectl restart

That's all.
From now you can access to http://localhost:3025/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment