CouchDB and PHP Web Development Beginner’s Guide
上QQ阅读APP看书,第一时间看更新

Time for action — using Terminal to show hidden files

Now that we have Terminal up and running, let's get familiar with it by running a quick command that exposes all of the hidden files on your computer. Whether you know it or not, there are a variety of files that are hidden, and they will need to be visible in order for us to complete the setup of our development environment.

  1. Start by opening Terminal.
  2. Type in the following command to allow the Finder to show hidden files, press Enter when you are ready:
    defaults write com.apple.finder AppleShowAllFiles TRUE 
    
  3. In order to see the files, you will need to restart the Finder, type the following command, and press Enter:
    killall Finder 
    

What just happened?

We just used Terminal to run a special command that configured Finder to show the hidden files and then ran another command to restart the Finder. It's not important for you to remember these commands or fully understand what they mean; you probably will never have to type this again. If you look around your computer you should see quite a few files that you haven't seen before. Here's a quick example of what my hard drive looks like now:

What just happened?

Tip

If it irritates you to see so many files, you can hide hidden files again once the setup is complete. You can do this by simply running the following command in Terminal: defaults write com.apple.finder AppleShowAllFiles FALSE. Then by restarting the Finder by running: killall Finder.

Now that all of the files on our machine are shown, let's talk about text editors, which will be the primary way you'll view and edit your development project.

Text editor

In order to write code, you will need a solid text editor. There are a lot of text editors out there, and you can use whichever one you prefer. All of the code in this book will work with any of them. I personally prefer TextMate because of its simplicity and ease-of-use.

You can download and install TextMate here: http://macromates.com/.

Apache

Apache is an open source web server and the engine that will run the PHP code that you'll write in this book. Luckily, Apache comes pre-installed on all installations of Mac OS X, so all we need to do is start it using Terminal.

  1. Open Terminal.
  2. Run the following command to start Apache:
    sudo apachectl start 
    

That's all it takes to get Apache up and running on your computer. Apache won't let you turn it on if it's already running. Try typing that same statement again; your machine will alert you that it's already running:

Apache

Note

It's very unlikely, but on the off chance that your machine does not have Apache installed, you can install it by following the instructions on Apache's website: http://httpd.apache.org/docs/2.0/install.html.

Web browser

You probably use a web browser every day when surfing the Internet, but it will also double up as a powerful debugging tool for us. I will use Chrome as my web browser, but the up-to-date versions of Safari, Firefox, or Internet Explorer will work just fine as well. Let's use our web browser to check that Apache is accessible.