Setting up a PHP environment on Ubuntu
I could number several benefits of using Linux for PHP development, but that will be matter for another some other time. Ubuntu is one of the most (if not the most) user-friendly Linux distros and setting up a local environment, known as LAMP (Linux, Apache, MySQL and PHP) is really easy.
1. Open the terminal.
2. Update the repositories (if you haven't done it already):
sudo apt-get update
3. Install the following Apache packages:
sudo apt-get install apache2 libapache2-mod-php5
Now we can install PHP packages. There are many packages available for you to install, according to your needs, of course. There are some of the packages I believe to be the ones I'll be using the most:
sudo apt-get install php5 php5-cli php5-common php5-mysql
PHP5: the main package
PHP5-CLI: if you want to use PHP on command line.
PHP5-COMMON: Common files for packages built from the php5 source
PHP5-MYSQL: MySQL module for php5
4 Install MySQL
sudo apt-get install mysql-server
Voilá, it is as simple as those steps to have a local PHP server working and ready to rock.
Note: chances are these steps will work exactly the same way for other Debian-based distros.
Written by Luis Milanese
Related protips
4 Responses
Having to install Apache just to do some PHP development is one of the reasons I prefer Python. By the way, doesn't PHP 5.4 include a built in web server?
Hi Smotko,
Thank you for your message.
Yes, PHP 5.4 comes with a built in web server but there are many people still using PHP 5.3 on their production servers and using Apache for web server.
As for Python, I'm still getting around with it and it's a language really fun to learn.
Shameless ad: https://github.com/chluehr/roundsman - my simple script to do all of this (and more). Just do (don't w/o checking it first!):
wget -q -O - https://raw.github.com/chluehr/roundsman/master/setup.sh | bash
@chluehr that is one interesting script.