Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Setup Your Local Development Environment6:57 with Alena Holligan
Most developers prefer to build applications locally, on their own computers, rather than on hosted servers. Working locally allows you to work more quickly because you don’t have to wait for your changes to be saved to a remote server and you don’t have to worry about issues like internet connectivity.
Also check out MAC: Local Dev Environment.
Advanced Options for Free Version
DO NOT USE THESE DIRECTIONS IF YOU ARE USING THE PRO VERSION
Turn On Errors
1. With MAMP running, go to the following page in your browser http://localhost/MAMP/index.php?language=English&page=phpinfo * Note: if you are using a non standard ports, this link will need to include your port number like this http://localhost:**YOUR PORT NUMBER**/MAMP/index.php?language=English&page=phpinfo 2. Search for “php.ini”. You should see something like Loaded Configuration File: C:/MAMP/bin/php/php5.6.10/conf/php.ini 3. Open the corresponding file in a text editor 4. Search for the line that says “display_errors = Off” and change it to “display_errors = On” 5. Save the file and restart the MAMP servers
Change the password of the MySQL root user
Open the Command Prompt and enter the following command line:
C:/MAMP/Library/bin/mysqladmin -u root -p password [NewPassword]
replace [NewPassword] with your new password.
Please bear in mind that you also have to change the phpMyAdmin configuration and probably your own php scripts to use the newly created MySQL password. For changing the phpMyAdmin configuration edit the file C:/MAMP/bin/phpMyAdmin/config.inc.php and up
- Install Wordpress( and Multi-Site)
Create Virtual Hosts
This allows you to have multiple projects available at the same time
NOTE: File locations for Windows Users.
- C:/Windows/System32/drivers/etc/ (if this is not correct, do a google search for your particular version of windows)
[MUSIC] 0:01 Hello and welcome. 0:04 I'm Alena Holligan, a PHP teacher here at Treehouse, and long time developer. 0:06 Most developers prefer to build applications locally, 0:11 on their own computers, rather than on a hosted server. 0:14 Working locally, allows you to work more quickly. 0:18 Because you don't have to wait for changes to be saved to a remote server. 0:21 And, you don't have to worry about issues, like Internet connectivity. 0:25 Working with files locally also allows tighter integration, 0:29 with development tools. 0:33 In addition, one of the best things about programming as a career, 0:36 is the ability to work from anywhere. 0:39 While all these reasons are good, the most important reason for 0:43 having a local development environment, 0:46 is you should never be working directly on a production server. 0:49 Always test your code before it goes live. 0:52 To make use of these advantages, we need to set up a local development environment. 0:56 This means installing the programs we need for 1:01 our local computer to work as a web server. 1:04 Namely, Apache, MySQL, and PHP. 1:07 There are many different ways to set up a local development environment. 1:10 Most involve at least some use of the command line and 1:15 can be pretty scary if you don't know what you're doing. 1:18 I'll be showing you a quick and simple method, 1:22 which will allow even complete beginners to get up and running within minutes. 1:25 Make sure you check out the notes, for more resources and advanced options. 1:29 Let's get started! 1:34 In our web browser, let's search for MAMP. 1:36 The first one is MAMP & MAMP Pro at mamp.info. 1:40 Click on Downloads and then Download again. 1:44 This may take a little while to download depending on your Internet connection. 1:48 Once the file is downloaded, open the installer and 1:52 it will guide you through these necessary steps to install the software. 1:54 Make sure you allow it to make changes to the computer. 1:58 Choose your language of choice. 2:01 And if you'd like to install MAMP Pro at this time, leave the box checked. 2:07 If you want more information about MAMP Pro, check out the notes. 2:11 Make sure you read and agree to the terms. 2:16 And let the software install. 2:26 MAMP & MAMP Pro have been installed successfully you may close the installer. 2:28 Go to your C drive, where you will see the MAMP the MAMP Pro folders. 2:33 You can also launch MAMP from the shortcut if you created one. 2:38 And MAMP we'll go into MAMP and this is where the magic happens. 2:42 It starts our server and turns our computer into a web server. 2:47 We open the start page and we'll see information about our server. 2:52 We'll see our MySQL install which is our database. 2:55 You have your tools, either phpMyAdmin or phpLiteAdmin, for 2:59 administering the database. 3:03 Also, phpInfo for all the information about our PHP install. 3:05 For now, take off everything after localhost and 3:10 this is where our website is. 3:13 Right now, it just says Index of/, because there's nothing there, so 3:15 let's fix that first. 3:19 Open you text editor. 3:20 And let's type Test. 3:23 We're going to save this into C://MAMP/htdocs. 3:25 This is where MAMPS stores our files for our website by default. 3:33 Type index.php and hit save. 3:36 Now when we go back to the browser and refresh our page, we'll see Test. 3:41 If I go back into MAMP and stop the server, and then go back into my web 3:45 browser and click refresh, we're gonna get an error because our server's not running. 3:50 So before you test your website, make sure that you start your servers in MAMP. 3:56 Now, when we refresh, we see our website again. 4:01 Congratulations. 4:05 Technically, that's all we need to do. 4:06 However, I want to show you one configuration step 4:08 that will make our workflow a little easier. 4:10 Most people find it better to work in the Documents folder, 4:13 usually within a sites folder, and then separate folders for each project. 4:16 So let's set that up. 4:20 We'll go into our text editor, and here we're gonna just add Documents, so 4:22 that we know that it's looking into a new location. 4:27 So we go File > Save As, and we're gonna go into our Documents. 4:29 Create a folder called sites. 4:35 And then a new folder called testsites. 4:38 We'll leave it as index.php and click Save. 4:42 Now we go back into MAMP and under Preferences, 4:46 you'll see the Web Server tab. 4:50 You see that the document root shows CMAMP\htdocs. 4:52 This is what we want to change, so click Select. 4:57 Go into Documents > sites > testsite, and click OK. 5:00 Now we click OK again, and MAMP will restart our servers. 5:06 Now when we go back to the web browser and 5:10 click refresh, we'll see that it says Test Documents, and 5:13 we know that it's now looking in the new location for our website. 5:16 If I wanted to have multiple projects, I could set that up with MAMP, 5:21 without using MAMP Pro, by just changing our root document. 5:25 This will allow me to have multiple websites, but only one running at a time. 5:28 Let's give this a try. 5:33 Go back into your text editor and 5:35 we're going to say Test Website 2. 5:39 And then we're going to save this as testsite2. 5:43 Leave it as index and Save. 5:52 Now we go back into MAMP. 5:55 Back to our preferences, our web server and we're going to change this location. 5:58 So instead of being in this testsite folder we're now going into testsite2. 6:04 We'll click OK, and OK again. 6:10 Again, our servers will restart, and then we can go back into the browser. 6:13 Now when we hit refresh, you'll see that it says Test Website 2. 6:19 So now we have two different websites that we can go back and 6:24 forth between using just MAMP. 6:27 Remember, if you wanna test out your other site, you need to go back into MAMP, 6:30 Preferences > Web Server, and once again, change the document route. 6:33 Now that you have your local dev environment set up, 6:40 you're ready to code anywhere. 6:43 A laptop might come in handy too. 6:45 Remember to check out the notes, where you'll find a lot more resources and 6:48 advanced options. 6:52 Until next time, maybe I'll see you at the beach. 6:53
You need to sign up for Treehouse in order to download course files.Sign up