How do I setup php + My sql development environment in Ubuntu ?
-
Someone flagged this for closure as 'not a real question', probably based on the second sentence. This answer may help with the first part, and you might edit out that second part and try it on one of the other SE sites? I'm choosing 'Leave open' based just on the first part. – Tom Brossman Nov 25 '12 at 12:24
-
@Tom Brossman: Rollbacked, BTW I can't see any close votes on this question – Tachyons Nov 25 '12 at 12:39
-
Its way to broad, isn't it? do you mean how you install LAMP? Or eclipse with PDT? Debugger? What have you tried/where are you stuck, what do you want exactly? – Nanne Nov 25 '12 at 12:48
-
There are some good answers below. Are you not interested in the web server part and wanting to focus only on PHP and MySQL? – Tom Brossman Dec 24 '12 at 10:20
5 Answers
http://www.iasptk.com/ubuntu/20463-apache2-with-php5-and-mysql-support-on-ubuntu-server
Apache2 With PHP5 And MySQL Support On Ubuntu Server
LAMP is short for Linux, Apache, MySQL, PHP.
Install an Apache2 webserver on an Ubuntu Server with PHP5 support (mod_php) and MySQL support.
Installing MySQL 5
sudo apt-get install mysql-server mysql-client
Installing Apache2
sudo apt-get install apache2
Apache's default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.
Installing PHP5
sudo apt-get install php5 libapache2-mod-php5
We must restart Apache afterwards:
sudo /etc/init.d/apache2 restart OR sudo service apache2 restart
Getting MySQL Support In PHP5
To get MySQL support in PHP, we can install the php5-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:
apt-cache search php5
Pick the ones you need and install them like this:
sudo apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
Now restart Apache2:
sudo /etc/init.d/apache2 restart OR sudo service apache2 restart
Xcache is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and APC. It is strongly recommended to have one of these installed to speed up your PHP page.
Xcache can be installed as follows:
sudo apt-get install php5-xcache
Now restart Apache:
sudo /etc/init.d/apache2 restart OR sudo service apache2 restart
phpMyAdmin
phpMyAdmin is a web interface through which you can manage your MySQL databases.
sudo apt-get install phpmyadmin

- 1,676
-
sudo apt-get install phpmyadmin
get the php8.0 extensions along i have 7.3 installed how to install phpmyadmin specific to PHP 7.3 – Muhammad Omer Aslam Mar 03 '21 at 17:11
sudo apt-get install tasksel
sudo tasksel
- select LAMP

- 494
-
Thanks for the answer, BTW How to run my first php script?. I am an absoulte noob in webdevelopment :) – Tachyons Nov 25 '12 at 10:14
-
1Open up Gedit. Type . Save the file as info.php and put it in your /var/www directory. Then go to http://localhost/info.php in your browser and you will see your PHP details. Basically every PHP file works in the same way. However, a very smart cookie by the name of Alex has done a load of videos on Youtube as PHPacademy and for The New Boston. I suggest you start there and just ignore all the stuff about XAMPP. You have your server. – Simon Hoare Nov 25 '12 at 10:31
-
2you can do the same with the single command "sudo apt-get install lamp-server^" – Vidyadhar Nov 25 '12 at 10:54
-
install php5, php5-mysql, and mysql-server with the following command
sudo apt-get install php5 php5-mysql mysql-server
If you will be hosting php5 applications on a web server, you may want to install apache and apache's php supporting module with the following command
sudo apt-get install apache2 libapache2-mod-php5

- 2,913
-
Thanks for the answer, BTW How to run my first php script?. I am an absoulte noob in webdevelopment :) – Tachyons Nov 25 '12 at 10:14
for ubuntu 14.04 or higher:
sudo apt-get install php5-xdebug php5-mysql mariadb-server mariadb-client mysql-workbench apache2-utils apache2 libapache2-mod-php5
Make sure that the installation of the xdebug lib is in the correct folder:
cd /usr
find . -name 'xdebug.so' 2> /dev/null
That should output something like this:
./lib/php5/20121212/xdebug.so
Append both the
/etc/php5/apache2/php.ini
and
/etc/php5/cgi/php.ini
files with the following lines:
;;;;;;;;;;;;;;;;;;;;;;;;
[XDebug]
;if the find command output was different, paste that output within the double quotes with out the leading period.
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.max_nesting_level=300
;;;;;;;;;;;;;;;;;;;;;;;;
You'll need to restart the apache server:
sudo service apache2 restart
That's it, you should be good to go. To check and make sure that everything is working correctly, you can use the phpinfo() analysis tool.
Create a php info file from the shell prompt:
php -i > phpinforesults.log
open the the newly created file, select all and copy:
gedit phpinforesults.log
Finally, paste the output to https://xdebug.org/wizard.php and click the analyse button. The first section should say xdebug installed version 2.2.3, or whatever the latest version is.
Good luck, I hope this helped.

- 111
-
1
-
I know, you are right. But this post kept showing up when I was searching on how to do this. Since it was a little bit of a pain, I posted here. Sorry if there was any confusion. – Siraj May 25 '16 at 01:45
-
Also, OP was how to setup development environment. Debugging is a very important part of the development environment and should also be explained. If it is prudent, I can add the mysql setup process into this post as well. – Siraj May 25 '16 at 01:47
I highly recommend you to trying LAMP Stack from Bitnami.
It's completely self contained and will not interfere with other software on your system.
If you unsatisfied with this, just delete the folder. Or execute uninstall script inside the folder for clean removal.

- 121