How to set up a PHP Development Environment with 1 Ubuntu computer

If you have one pc and you want to use this pc as a development environment the best thing you can do is have Ubuntu installed.

and then what? follow this post…

php developers

I am asuming you have a PC with a recent Ubuntu on it lest say somethng like 12.x or the new 13.04 (i like to date posts) to check your version from the terminal if you don’t know how to go to the terminal probably this isn’t the right tutorial for you have a look arround and come back in a cople of hours.

cat /etc/lsb-release

 

Thats the main sotware you will nead and this is one posible option but there are many different flavors out there.  Some times the we use applications just because we feel confortable working on them and produce quicker but not because it is better than others.

Lamp (Linux, Apache, Mysql and PHP).  This will convert your workstation into a webserver to run php script and access to the mysql database.

NetBeans, is the IDE (Integrated Development Environment) I use runs on windows and linux and I very recomend the version 7.4 as for me is much faster than the 7.3 but again this is probably the software where developers will disagree the most.  Choose your IDE is an important step but will depend where you comming from (notpad, commodore 64, .net, vb6, java, vim, Emac or what ever background) my path was vb6 – notepad+ – .net – Eclipse – NetBeans.  I stay for a while in Eclipse because the android plugin but thats history for me.  You should have a look at least the website of Eclipse PDT (PHP Development Tools) or Aptana then you have some paid options like Zend Studio or Aptana Studio Pro but I don’t see the point.

– DBeaver (Universal Database Manager) This is a database client with a user interface to perform all the operations you will need from your mysql local server like manage users, databases, tables etc.

Nautilus (Official file manager for the GNOME desktop) If you think in windows you think in Winscp integrated with Putty because you need to connect trough SSH quite often to linux but we are in linux right? well ubuntu what ever so you just need to mount the remote directory you want to work on and you can use nautilus to connect trough different protocols as http, https, ftp, samba etc.

 

 

Instaling LAMP
If you are using your normal user in Ubuntu you will need to sudo each command to install “things” as a the super user root. (I am not trying to be patronaizing here, we all have learn what ever we know, just skip it if you know thise things…)If you confident you can change your terminal and run the commands as root using:

sudo bash

You will see that the user changes

 

The quicker way I found is trough tasksel but you have to be very carefull about the options you select or lets say deselect = DANGER!!!

Tasksel is a Debian/Ubuntu tool to install multiple packages as a task I thinks it is supercool but of course you can destroy your Ubuntu because you are installing and uninstalling multiple packages in one go. Be brave my friend worst case scenario will be google for a day trying to resurrect your Ubuntu.

Open the console and run:

sudo apt-get install tasksel

You will get something like that:

oe-tasksel-lamp.jpg

You want live what ever you have allready selected and select if you don’t have it LAMP server but I also recomend if you don’t have it:

OpenSSH “…is a freely available version of the Secure Shell (SSH) protocol family of tools for remotely controlling a computer or transferring files between computers…”

mor info: https://help.ubuntu.com/10.04/serverguide/openssh-server.html

and

Samba file server: “…One of the most common ways to network Ubuntu and Windows computers is to configure Samba as a File Server. This section covers setting up a Samba server to share files with Windows clients…”

more info: https://help.ubuntu.com/10.04/serverguide/samba-fileserver.html

I know that strictly talking about this only Ubuntu envirourment you won’t need samba but become very cool when you have your dev folder in a a remote windows or even usb pendrive, and you mount with samba this folder into your www apache folder. (we will go that way in another tutorial)

After the instalation begins you will be prompt about the mysql root password and there is when you take a pen open your secret pasword notebook and write root – password123 or what ever password you choose.  You will need this password very soon.

If everything went ok you are siting in a proper web server and you can feel very important you can even go realy live with a free service like http://www.noip.com/ and impress your grandmother but this is other story.

Lest test the server and see if realy works:

If you open your browser and type localhost you should get the default page saying something like: It works!

 

You will have a /var/www directory where your apache points by default.  We will go trough apache configuration later but for now just create a php file into this folder to see what it is instaled in apache and php.

 

sudo gedit /var/www/info.php

 

add the folowing php code:

<?php
phpinfo();
?>

and type in your browser:

http://localhost/info.php

you will get something like that:

phpinfo.png

 

Configuring apache
Open QuickSynergy and select the Use tab 

Nice coding….

 

 

.step-by-step {
    counter-reset: my-badass-counter;
}
.step-by-step dt {
    position: relative;
    font-size: 1.4em;
    line-height: 1.2em;
    color: #386F34;
    padding: 4px 0 10px 0;
}
.step-by-step dt:before {
    content: counter(my-badass-counter);
    counter-increment: my-badass-counter;
    position: absolute;
    left: 0;
    top: 0;
    font: bold 50px/1 Sans-Serif;
}
.step-by-step dd {
    margin: 0 0 50px 0;
}	
.step-by-step dt, .step-by-step dd {
    padding-left: 50px;
}

 

 

 

Eduardo

 

 

 

Tags
About the author
Eduardo Silva was born in Buenos Aires, Argentina, and has being living in London for the past 15 years. With a background in psychology he is a IT developer and the co-founder of open-ecommerce.org, a digital content social enterprise. His passion is digital story-telling and has created short films and documentaries to help people promote there ideas.