-
Notifications
You must be signed in to change notification settings - Fork 23
VirtualHost
jack edited this page Dec 23, 2016
·
7 revisions
The goal of this page:
- Setup a VirtualHost for local development environment.
- Put the source code at anywhere you like instead of default DocumentRoot.
- Access the local version by short url
http://capubbs/
.
- Append
127.0.0.1 capubbs
to/etc/hosts
. - Create a VirtualHost config file naming
capubbs.conf
.
- The file should be located at:
- For Mac:
/etc/apache2/other/capubbs.conf
. - For RHEL:
/etc/httpd/conf.d/capubbs.conf
. - For Debian:
/etc/apache2/sites-available/capubbs.conf
and executesudo a2ensite capubbs
.
- For Mac:
- Replace
[path/to/your/code]
by the path to your code. Be careful not to put the code in your private directory so that there will not be issues on permissions. The recommended directory is your home directory~
.- e.g. for me is
/Users/huxuan/Code/CAPUBBS
.
- e.g. for me is
<VirtualHost *:80>
DocumentRoot [path/to/your/code]
ServerName capubbs
<Directory [path/to/your/code]>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
If your apache version is 2.4 (for most Macs with OS X Yosemite), please use the following code. Run apachectl -v
to check your apache version in the terminal.
<VirtualHost *:80>
ServerName capubbs
DocumentRoot [path/to/your/code]
<Directory [path/to/your/code]>
Require all granted
</Directory>
</VirtualHost>
- Restart apache.
- For both Mac and CentOS:
sudo apachectl restart
.
- DONE! Just open any web browser and try
http://capubbs/
! - Change
bbs/lib/mainfunc.php
line 5 from$url="http://127.0.0.1/api/jiekouapi.php?ip=$ip&token=$token";
to$url="http://capubbs/api/jiekouapi.php?ip=$ip&token=$token";