This article explains how and why I set up my new project directories, the way I do. I use a bash script to generate these directories, but you could manually set up the folders.
I do all my development on a Linux desktop because it gives me quick and easy access to the tools I need in order to automate development. The structure explained below favours the use of Git (SVN or Bazaar would work too), but no version control system is required.
First, I'll give you some background about how I develop websites. I run a LAMP server on my desktop/laptop so that I can do my work offline. I then commit my work to Git and push it to whoever needs it or the live server. Creating a consistant directory structure on both your development and server will keep you and your files organized. The goal here is to have everything you need to deploy to any server you want.
My Directory Structure
The public directory could also be called any of the following: public_html, html, http, webdocs, etc. "Public" will be the directory that is accessible by your webs server (and potentially the world). All other directories will be private.
I usually install the core CMS or framework to this directory. The bash script below installs Joomla by default; however, you could change the script variable to any CMS (as long as it is a zipped file).
There always seems to be a situation that requires a core edit to the CMS or framework during development. A "core edit" is when you have to edit a file that potentially could be lost during the next CMS update. In order to keep CMS updates easy, I copy my changes to the file from the public directory into the core-edit directory. This strategy keeps a saved copy of the modified file so that you can remember what has changed if an update overwrites the file. In the past, I used a symbolic link from here to the public directory; however, symbolic links are a hassle on some shared hosting accounts (that do not support symbolic links).
My docs folder contains all of my documentation for the project. Documents that talk about installation, upgrading, merging, thrid party services, bridges or anything else releated to the project. I usual store the files as markdown (.md) so that I can referto them from Github or Gitlab.
The scripts directory is where you are going to keep all of your bash scripts. These scripts are intended to be run relative to this directory. I talk about these scripts in other articles. For example:
Optionally, you could place cron jobs in this directory if you don't create a cron directory. Also, most CMS have existing cron folders already.
The sql folder is where I store database dumps, updates and configurations (such as database users). I store database backups here so that I can commit them and push/pull them to different servers. Keeping the database in Git allows a quick deploy to different servers (unless you have a large database).
If you are using bind, you can store all the files here to move between servers if required. I tend to use services such as Cloudflare; therefore, I don't use bind files all that often and have removed it from newer version of this script (view the commit history).
If you are using a VPS, the apache folder will contain your Apache configurations (excluding htaccess). I use Apache2 which allows me to symbolic link directly to this directory. With symbolic links in place, making updates to the Apache configuration is a breeze when using Git. You could rename and modify the contents this folder for Nginx config files as well.
Project Directory Script
Before the script is functional, you will have to modify the variables located at the top of the script. Also, view the source comments for requirements at the top of the script before you run it. I use Ubuntu on my desktop, but I don't run all native appliactions.
The script is located on GitHub, and is named "newProject.bash". Here is the link to the raw file: github.com/nickyeoman/NYScripts/blob/master/newProject.bash
How To Use
Usually you would download this to your home or scripts directory.
#To install (on a linux system), just run the following command: wget https://raw.github.com/nickyeoman/NYScripts/master/newProject.bash #then just run bash newProject.bash example.com