Home > Debian, Debian GNU/Linux, HowTo, Linux, My Works, PHP, Programming Help, ubuntu > how to move your php development environment to linux (Debian/Ubuntu)

how to move your php development environment to linux (Debian/Ubuntu)

Nowadays, lots of php developers are thinking to move their development environment to linux. And I am writing this tutorial for them. As I like Debian GNU/Linux (www.debian.org) best and ubuntu (www.ubutnulinux.org) is now doing great, in this tutorial I am using the commands for debian & ubuntu.

Ok, now starting:

First on all let’s make a list of software a PHP developer need mostly:

1.Apache
2.PHP
3.Mysql
4.PHP IDE

Ok, let’s start with Apache. Debian & ubuntu use APT to manage the packages. You can easily install apache using apt, here is the command

Debian user:

su

Ubuntu user:

sudo su

Rest of the command ar same for both debian & ubuntu.

apt-get install apache2

It will install all the apache2 & all the related packages (software)
If you need to enable mod_rewrite, follow this link
Now install the PHP

Apt-get install php5 libapache2-mod-php5

This will install the php5 and configure your apache2 server for PHP. You don’t need to do anything.
Lets test the server, if it working ok.

touch /var/www/info.php

Chown www-data:www-data info.php

Now edit this info.php with your feviourate editor and add write code to show phpinfo():
and now browse http://localhost/info.php from your browser. Now check if all your requested library are installed.
if you need any more library, you can check if it already available on your debian/ubuntu package list.

apt-cache search php5-

then you will get the list of available php5 library. Now simple use this command to install it.

apt-get install php5-gd

(example, if you want to install php5 GD library)

Remember: after installing every extra packages, you must need to restart apache server

/etc/init.d/apache2 restart

Ok, so you have now apache2 and php5 installed system. Let’s install mysql:

apt-get install mysql-server-5.0 php5-mysql

It will install all the necessary packages to run mysql-server.
Now restart your apache to take effect.
Complete!!!! Server is allmost ready.
Now i am going to derive how you will transfer your old code to this new environment. Belive me it’s too simple, so don’t worry.

First of all copy your source code to /var/www, here is the details procedure:

mkdir /windows

Here we make a folder for C drive of windows to mount.
mount /dev/hda1 /windows
then we mount the C drive to windows folder (here i use hda1 as example, if your hdd is sata then it will be sda1)

cp -r windows/Apache2/htdocs/xyz /var/www

here we copied our xyz site to /var/www (in debian and ubuntu, default apache2 root folder is /var/www)

cd /var/www

chown -R www-data:www-data xyz

Now change the ownership to www-data

Now we need to move the mysql database, there is two way:

1.use phpmyadmin
2.simple copy the database from data folder
I am deriving the 2nd way.

cp -r /windows/Mysql/data/xyz /var/lib/mysql

chown -R mysql:mysql /var/lib/mysql/xyz

You are done.

PHP Ide for linux environment:

    1.Zend ( i personaly use this)
    2.PHPEd
    3.PHPEclipse
    4.quanta plus
    5.emacs
    6.vi
    7.PHPedit

***I know this tutorial needs more edit, please make your comments if you got anything wrong, or missed anything. I want it a cool tutorial for php developers.

Read some reviewed, the best and most affordable php hosting solutions on the market.

Views :14514
  1. August 4th, 2007 at 21:01 | #1

    Nice Tutorial!
    This is as easier as it gets in Debian/Ubuntu.
    When you have time, plz make one for some other distros, e.g. Fedora too.

  2. August 4th, 2007 at 22:15 | #2

    I think you could make it more simple, for example if you install software like XAMPP, that will do everything for you. 🙂

  3. babu
    August 4th, 2007 at 22:19 | #3

    বড়ই খটমটে ব্যাপার। বুঝতে পারলাম না।

  4. August 4th, 2007 at 22:27 | #4

    @omi: thanks, i forget to tell about xampp 🙂

    btw, i don’t like xampp (lot’s of bad experince with it)
    Belive me, i am runing 2 dedicated servers.

  5. August 5th, 2007 at 01:03 | #5

    Nice Tutorial.

  6. deborah
    August 5th, 2007 at 10:25 | #6

    good effort to shine light on the topic,keep it up

  7. August 5th, 2007 at 10:33 | #7

    hi lavlu, great work. it is so good to see how people with a burning passion also are good teachers and can give the best guidelines. it seems that the php team now is overflowing with passion and burning interest.

  8. August 5th, 2007 at 12:25 | #8

    @arild

    hey, php team was always overflowing with passion compared to your other teams, eh!

    see lavlu, x-hasin, morshed, mizan – all are guiding others in their blog!

  9. murshed ahmmad khan
    August 5th, 2007 at 14:15 | #9

    Very good effort 🙂 and also a useful post for PHP developers. keep up such good tutorials always.

    Installing XAMPP is easy as it hides all complexity. But as a developer everyone should know the manual installation and what’s actually going on the back end.

  10. August 5th, 2007 at 23:41 | #10

    আমি উবুন্টু যখন ইউজ করেছিলাম তখন উবুন্টুর সারভার সিডি থেকে পিএচপি ,মাইএসকিউএল তার পর পিএচপিমাইএ্যাডমিন ইনস্টলকরে মোটামুটি ল্যাম্প LAMP(Linux Apache Mysql PHP) বানিয়ে ফেলেছিলাম । আমার জুমলা , ওয়ারডপ্রেস পিএইচপিবিবির ইনস্টলের হাতেখড়ি ওখান থেকেই। তবে লিনাক্সে xampp ট্রাই করিনি।

  11. August 6th, 2007 at 00:28 | #11

    তবে নতুন ব্যবহারকারীদের জন্য xampp ভালো। আর আপনার লিনাক্সে যদি নেট কানেকশন না থাকে তবে লাভলুভাই এর উল্ল্যেখিত প্যাকেজগুলো আপনি Ubuntu Server Edition সিডি থেকে ইনস্টল করতে পারবেন।

    http://www.ubuntu.com/products/WhatIsUbuntu/serveredition

    সিডিটি ডাউনলোড করে Synaptic Package Manager এ গিয়ে রিপোজিটরিতে সারভার সিডিটি এ্যাড করে সিনাপটিকের প্যকেজ লিস্টটি রিফ্রেশ করলে উক্ত এ্যাপলিকেশন গুলো লিস্টে দেখাবে। আমি সুবিধার জন্য অন্য রিপোজিটরি গুলো মুছে দিয়েছিলাম ফলে লিস্টে ইনস্টলড এ্যাপলিকেশন এবং সারভার সিডির এ্যাপলিকেশন গুলোই দেখতে পেয়েছি। ((তবে দরকার নাহলে এটা আপনার করার প্রয়োজন নেই))

    ব্যাস

    হ্যাপি লিনাক্সিং লিনাক্সে আগ্রহীদের জন্য বলছি। সাইকেল চালানো শেখার সময় যেমন পড়ে পড়ে শিখেছিলেন তেমনি সহজ লিনাক্স “উবুন্টু” (সব অটোমেটিক আর সহজ যেমন হার্ডডিস্ক মাউন্টিং,deb file এ ক্লিক করে প্যাকেজ ইনস্টল ইত্যাদি)
    ব্যবহার না করে জটিলটি আগে ব্যাবহার করুন । যেমন আমার প্রথম ব্যবহৃত লিনাক্স হচ্ছে ফিডোরা কোর 4 এটি ব্যবহারের সময় নানান জায়গায় আটকেছি কিভাবে আমার হাডডিস্কড্রাইভ গুলো মাউন্ট করতে হবে জানতাম না

    আরপিএম প্যকেজগুলো কিভাবে টারমিনালে কমান্ড দিয়ে ইনস্টল করতে হয় জানতাম না , সোর্সকোড কম্পাইল করে কিভাবে প্রোগ্রাম ইনস্টল করতে হয় জানতাম না। এগুলো আস্তে আস্তে গবেষনা করতে করতে শিখেছি এক্ষেত্রে সবচেয়েবেশী সহায়তা যেখানথেকে পেয়েছি তাহল বিডিলাগ থেকে

    http://groups.yahoo.com/group/bdlug/

    এভাবে শিখার ফলে এখন আমি উবুন্টু ইউজ করলেও প্রয়োজনীয় অনেক কমান্ড জানি সহজ কাজটা জটিল ভাবে ও করতে জানি (Terminal) এ 🙂

  12. razon
    August 6th, 2007 at 09:01 | #12

    nice tutorial.. i agree abt xampp.. i also have some bad experience.. anyway i don’t like any third party package who make our life easier.. i can’t learn properly from that software.. how to configure or customize.. may be u all understand..

  13. August 6th, 2007 at 10:23 | #13

    A great resource for every PHP developer. Great work lavluda. You are too good 🙂

  14. Tania
    August 6th, 2007 at 23:50 | #14

    Hay nice tutorial :), Go ahead……..

  15. August 6th, 2007 at 23:52 | #15

    thanks tania, arild, hasin bhai, darkloard, morshid bhai, mizan bhia, deborah apu, zaher, babu, omi , sharif for your valuable comments. Your comments giving the energy to write more :).

  16. August 7th, 2007 at 11:41 | #16

    Great! Any update about project 🙂

  17. August 7th, 2007 at 12:47 | #17

    thanks mizan bhai, now i am thinking to write a total guide to setup your dedicated server with debian / ubuntu linux 🙂

  18. MiZan Rahman
    August 8th, 2007 at 16:12 | #18

    No problem, ami achi 🙂

  19. August 12th, 2007 at 02:45 | #19

    মুভেবলটাইপ ট্রাই করসেন?

    4th ভাসর্ন ফ্রি এবং ওপেনসোর্স

    http://www.movabletype.org/

    http://www.movabletype.org/screenshots/

  20. October 6th, 2007 at 13:34 | #20

    Thank you for sharing!

  21. arnold
    April 28th, 2008 at 00:48 | #21

    Thanks for a great tutorial. Everything worked first time except moving database. After moving mysql db folders in phpmyadmin I can see a list of moved databases with correct number of tables next to them, but when I click on one of them they show as empty (no tables). Any suggestions?

  22. arnold
    April 28th, 2008 at 00:53 | #22

    Thanks for a great tutorial. Everything worked first time, except moving mysql databases. I moved db folders and changed permissions. When I go to phpmyadmin it shows transfered databases and correct number of tables next to them, but when I click on one of them, it says database empty (no tables) any ideas?

  23. April 28th, 2008 at 08:22 | #23

    hi arnold,

    i just found the reson, i missed 1 command in mysql section.

    after
    “chown -R mysql:mysql /var/lib/mysql/xyz”
    you have to run:
    “chmod 700 -R /var/lib/mysql/xyz”

    please reply if you still getting problem.

  24. arnold
    April 28th, 2008 at 22:06 | #24

    After posting here I decided to transfer my old data to another windows system, created temporary wamp server there and exported all databases using phpmyadmin.

    Anyway, thanks for your reply. Release of Hardy Heron and your post about moving development environment made me make up my mind and finally switch to Linux. I finally have Zend for Eclipse up and running and working on my projects again.

  25. December 10th, 2011 at 18:18 | #25

    Woh I like your posts , saved to fav! . 166659

  26. December 29th, 2012 at 13:39 | #26

    It’s perfect time to make some plans for the future and it’s time to be happy.
    I have read this post and if I could I desire to suggest you few interesting things or suggestions.
    Perhaps you could write next articles referring to this article.

    I wish to read more things about it!

  1. August 5th, 2007 at 09:43 | #1

%d bloggers like this:
45 queries in 0.409 seconds