This post is the second part of a 2-part series on how I setup my PHP Development Environment using Windows 7 as a base operating system and a basic LAMP server running on Ubuntu installed on Oracle VirtualBox. (You can read the first part here)
Section 1: phpMyAdmin
To be able to manage MySQL conveniently, we will install phpMyAdmin. We will need an internet connection and perform the following steps:
- Fire up your virtual machine and login.
- Run sudo apt-get install phpmyadmin to install the package.
- Direct your browser to localhost:8080/phpmyadmin. You should see the phpMyAdmin login page there. Try to login using the root account and the password you designated to it when you installed Ubuntu LAMP server.
- If you did not set a root password for MySQL, run cd /etc/phpmyadmin to switch to the phpMyAdmin installation directory and then run sudo pico config.inc.php to edit the configuration file. Press Ctrl-W and type in allownopassword to find the keyword, and then uncomment the line. Press Ctrl-X and then Y to save the file. You should now be able to log in as root without using a password.
That’s it, we should now be able to use phpMyAdmin.
Section 2: NetBeans PHP
Now, we’re going to install NetBeans PHP as our IDE of choice. You’re free to install any other IDE to your liking, but I’m only going to explain how to use NetBeans PHP.
- Go to the shared folder you have set up previously (see Part 1), create a new folder for your new project, and create a new index.php file there. Just fill it up with some HTML or some code.
- Download the Java SE Development Kit if you haven’t already done so. This is a prerequisite to install the NetBeans IDE. Install it.
- Download the installation file from the NetBeans website. Install it.
- Open NetBeans, then go to File –> New Project.
- Select PHP Application with Existing Sources. Click Next.
- Set the Sources Folder to the folder you created in step 1. Select your preferred PHP version, then click Next.
- Set the Run As option to Local Web Site, and click Finish. Make sure to edit your site URL to add your forwarded port number (set to 8080 in Part 1).
We are now ready to start writing code. Try creating a PHP file and write some echoes or whatever in it. Save it and then click the play button on the top toolbar to open a new browser window/tab directed at your site.
Section 3: Apache/PHP Configuration
The apache2 server works almost out of the box, but usually we would want it to be properly configured and equipped with some of the more common modules. Here’s how to do some basic configuration:
- Run sudo pico /etc/php5/apache2/php.ini to open and edit the PHP configuration file.
- Find the date.timezone parameter and set it to your liking. You can find the list of valid timezones here.
- Find the short_open_tag parameter and set it to Off. This is to prevent you from coding with short open tags, which might not be supported on some servers. Press Ctrl-X and then Y to save and close the file.
- Run sudo pico /etc/apache2/sites-available/default to open and edit the apache2 virtual host configuration file.
- In the <Directory> tag for root (/) and /var/www/, set AllowOverride to FileInfo Indexes. Save and close the file.
- Run sudo a2enmod rewrite proxy proxy_http proxy_ftp proxy_connect to enable the listed modules needed to support mod_rewrite.
- Run service apache2 restart to restart the apache2 server.
That’s it. Now we’re practically ready to start cracking. I might write some more about the actual code I’m working on, which is based on CodeIgniter 2 integrated with Doctrine ORM version 2, but I can’t make any promises as of now.
1 Comment so far