ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Setting up a LAMP development workstation using Ubuntu

Updated on September 30, 2008

No doubt Ubuntu and its variations are some of the most popular Linux distributions nowadays. This distributions, as well as other like OpenSuse and Mandriva had changed the image of GNU/Linux, early perceived as a system that's difficult to use and manage, only accessible to geeks.

Now the average user can see benefits in replacing proprietary operating systems with open source equivalents. Corporations from the start-up to the big tech companies are seeing advantages using GNU/Linux in their computers, ranging from stability and speed to the more obvious feature: cost.

Following the popularity of the Linux operating system comes the popularity of the PHP programming language, often tied with the Apache web server and MySQL database management system. This setup is often called “LAMP”, which stands for “Linux+Apache+MySQL+PHP”, or something like that.

I'll describe the steps required to get a LAMP development environment up and running. But I expect that you have the operating system installed, as I will not cover Ubuntu installation.

Installing Apache 2

PHP 5 can run in command-line, and you can create almost any type of software using it. But for websites and web applications, you need to run your scripts through a web server. Apache is the most natural option. That's why LAMP has an “A”.

Install it using apt-get. Apt-get will take care of any dependencies needed. Make sure you use “sudo” to run with super-user privileges.

# sudo apt-get install apache2

Apache is now installed and it's default document root is /var/www. Document root is the directory where the website files will be located. You can simply save your files under this directory and they will be accessible through http://localhost/.

Installing PHP 5

Apt-get will help us install PHP 5 as well as it did on Apache installation.

On the same command we can install also the libraries needed for PHP to access MySQL databases (package php5-mysql). Without this package, you can have MySQL running on the same machine you already have PHP, but PHP will be unable to access it.

# sudo apt-get install php5 php5-mysql libapache2-mod-php5

At this moment you can install other PHP extensions, if needed. They as packaged using names like php5-EXTENSION. For example, you can install GD library including php5-gd into the list of packages apt-get will install.

Installing MySQL

You guess it right. Apt-get will get MySQL server and client installed in your system, just as it did with other packages.

# sudo apt-get install mysql-server mysql-client

The mysql-client package will install the command-line mysql client. Most people don't like this kind of interface. You can be more productive using PHPMyAdmin, a browser-based MySQL management tool. Install it by running:

# sudo apt-get install phpmyadmin

PHPMyAdmin will be installed in the subdirectory phpmyadmin of your document root, which means that it's accessible via the address:

http://localhost/phpmyadmin

Setting MySQL root password

After MySQL installation, you have to set the root password. Don't confuse it with the system user root. On the typical Ubuntu install root not even have a password. The MySQL root user needs to have a password set, and this user will be used for any management operations on MySQL.

Set a root password by running:

# sudo mysqladmin password NEW_PASSWORD

The command will work this way only on the first run, when you do not have a password. After you have a password set, mysqladmin will require your current username and password to change the password, for obvious security reasons.

If you need to change the MySQL root password later, use the following command:

# sudo mysqladmin password -u root -pCURRENT_PASSWORD NEW_PASSWORD

Note that there are no spaces between “-p” parameter and your current password.

Team working and web applications

If you work with other people in the same network, of course you can barely follow this same steps on every machine and have several stand-alone development workstations. But it's not the optimum setup. I have some additional piece of advice on setting up a group of development machines.

Have a CVS or another version control system

It's not only for web development. CVS (or any similar version control system, like Subversion) is a must-have for any development team. Without version control, manage who have the most updated version of each single file is the hell. And when two or more developers happen to change the same file, you have a problem that's nearly to impossible to resolve.

Use a single database server

Development can be simpler by having just one database server and all other machines in the network accessing them. Having just one database takes from your hands the responsibility of synchronize the databases between all the development machines.

Other benefit of this setup is that you turn your environment more homogeneous. With the same code, developers can reproduce situations that other developers find to be tricky, and you eliminate the “this doesn't happen on my machine” problem.

An exception to the rule occurs when the development process includes constant drastic changes to the database, frequent drops and backup restore. In other words, when a developer leaves the database useless for the others. This situation can be solved by having a separate database for the user who need to do this operations. If all (or most) developers have this behavior, may be better just stick with the traditional approach (everyone has its own database server).

Setting MySQL privileges

If you decided to have a single database server, you can have a machine just for doing that or simply elect one of the developer's workstation for that, if the load will not be a problem for its owner.

Whatever the case, you have to do some additional setup to get this to work. MySQL by default doesn't allow connections from other machines. Here we go:

  • Edit the file /etc/mysql/my.cnf

    You can do it by typing on command-line:

    sudo gedit /etc/mysql/my.cnf (on Ubuntu)

    or

    sudo kwrite /etc/mysql/my.cnf (on Kubuntu)
  • Uncomment the following line:

    # bind-address = 127.0.0.1

    You uncomment it by removing the “#” character on the beginning of the line.
  • Now you have to grant the users' privileges again, but allowing them to connect from other machines. You were used to grant privileges like this:

    GRANT ALL PRIVILEGES ON database.* TO user IDENTIFIED BY 'password';

    Now you need to do:

    GRANT ALL PRIVILEGES ON database.* TO 'user'@'%' IDENTIFIED BY 'password';

    The '%' wildcard means that the username “user” can connect from any IP address. You can specify the addresses you want, or even ranges, by using for example “192.168.1.%”. But for a local network, “%” will be OK.

Comments

    0 of 8192 characters used
    Post Comment

    No comments yet.

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://hubpages.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)