Store
Community Documentation

v3 Knowledgebase

Setting up a development site


Contents



1Set up a development site
1.1 A local development site
1.1.1 On Windows
1.1.2 On Linux
1.2 A public development site
1.2.1 .Htaccess protect the dev site
1.3 Further references


Set up a development site


Not an easy topic, but if you're here you want to make things right from the start.
Some of the benefits of having a development site is that you get to test first hand if any change you plan on making will break anything, will look how you want it, etc.

There are two types of development sites depending on your needs and possibilities


A local development site


If you are just one developer or site owner (not a team) then a local set up is usually a good start. You dont need to share your code changes with anyone else or report anything to anyone but you.


On Windows


The first step is to have a local web server. While you can download Apache, Php and MySql separately there is really no need for this and our recommended approach is to just download and install XAMPP.
Assuming the installation went fine your public documents' folder will sit on C:/xampp/htdocs This is where you want to put your local files and the phpfox script.

Since you used XAMPP you should now already have a working web server, you can proceed with the normal Phpfox Installation instructions


On Linux


You will need several packages installed, Apache + Php5 + MySql 5.
If you are on debian you can try the following command:



~$ sudo apt-get install apache2 php5 php5-curl php5-gd php5-mcrypt php5-imagick php5-mysql php5-ffmpeg mysql-server phpmyadmin ffmpeg

I may have left some packages out but this should prompt to install any dependencies, let me know if theres any missing so I can add it. (mcrypt is needed for phpmyadmin and curl and gd for phpfox).

You will be required to enter a password for the root user in MySql, do NOT lose this password, it is very important and powerful.

More complete guides on how to set up a LAMP can be found on howtoforge.

If everything went fine you should now have a working server, if you point your browser to http://localhost you will get an Apache page saying everything is ok.

Now we want to have Apache set up so if you browse to http://development.mysite.com it will show your site in your local computer. This does not mean we are going to install the script right now, only tell Apache that when you look for development.mysite.com it should look for the local computer and not a site from the internet.

So open the file /etc/hosts and add an entry like this:



127.0.1.1 development.mysite.com

(The distance between both items is exactly one tab.)

Now you need to tell Apache that when someone looks for development.mysite.com they're looking at a specific folder, you do this by editing the /etc/apache2/httpd.conf file, by default it may look like this:


 ServerName localhost 

you want to change that for this:



# ServerName localhost
<VirtualHost *>
DocumentRoot /var/www/mysite.com
ServerName development.mysite.com
</VirtualHost>

Keep in mind that with this redirection you can even "replace" your internet site, you can have it so if you go to mysite.com it would look for a file in your local computer so be careful not to mix them here, we are using a prefix (development.) to keep everything in its place.

After this you need to restart apache:
try this:


/etc/rc.d/rc.httpd restart

If it doesnt work you dont have a debian machine, so this should do:


service httpd restart

You should now be able to access your local site by going to http://development.mysite.com

You can now continue with the Phpfox Installation instructions. Keep in mind though, that your license needs to be set up to point to your real domain, the "development" part is allowed by the Benc Enterprises license agreement.


A public development site


This is good if you work with a team or just want to have your dev site publicly.
Using an FTP client (like FileZilla) connect to your site and go to the public folder, this is usually "public_html" or "httpdocs". In there, create a new directory called:
development

You can now follow the Phpfox Installation instructions applied to this subfolder. The script will not be shown on your main site.


.Htaccess protect the dev site


Since it is a development site you may want to hide it from everyone, this is fairly easy to do and you can use this site to generate the 1 file that you need, the htpasswd
http://www.yellowpipe.com/yis/tools/htaccess_generator/index.php

Yes, the site will tell you to download and upload two files, but you only need the htpasswd. Upload that one and rename it to:
.htpasswd
Now open your existing .htaccess and add the following to the beginning of it:


AuthUserFile /.htpasswd

AuthGroupFile /dev/null
AuthName "Password Protected Area"
AuthType Basic

<limit GET POST>
require valid-user
</limit>

That should do it, if you ever lose your password (we hope you dont) you can generate a new one from that site and replace your .htpasswd, the .htaccess does not need to change.


Further references


  1. http://www.heritage-tech.net/336/setting-up-multiple-apache-local-web-sites-on-your-computer/
  2. http://www.yellowpipe.com/yis/tools/htaccess_generator/create-htaccess.php