How to Set Up a LAMP server on Linode

Learn how to securely set up a basic LAMP server with Centos, MySQL, and Apache on a Linode machine. By Chris Lowe.

Leave a rating/review
Save for later
You are currently viewing page 5 of 5 of this article. Click here to view the first page.

Installing PHP

PHP is just as easy to install. It doesn’t have its own server, but it’s called from Apache so you don’t have to worry about starting up another service.

Install PHP with the following command:

sudo yum install php php-mysql php-pear

Notice that there are a couple packages specified in the yum call above:

  • php – base install of PHP.
  • php-mysql – PHP components specifically for interacting with MySQL.
  • php-pear – an extension repository that offers many helper components.

PHP requires some tuning in order to be more secure, developer friendly, and performant. Open up the default PHP configuration with the following command:

sudo nano /etc/php.ini

Edit the three lines shown below in your version of php.ini:

error_log = /var/log/php.log
max_input_time = 30

Each of these changes are found in different locations in php.ini, but instead of scrolling around the file looking for them, you can hit Control-W in the text editor to search and find the configuration keys such as “error_reporting” and “max_input_time”.

Here’s what each change above does:

  • error_reporting – sets what kind of errors to show. There are several categories of errors, notices, and warnings; you can combine them with the | character as shown.
  • error_log – sets the location of the log file. While your web site is running, you can check this file to check for errors.
  • max_input_time – sets the maximum time a script to run. Setting a value here helps prevent runaway scripts from taking up all the processor time and slowing down the server.

Save and close the file when you’re done. Again, PHP will be called from Apache so there’s no separate PHP service to start. However, you do need to restart the web server so that it detects the new PHP installation, so restart the web server with the following command:

sudo service httpd restart

To confirm that your LAMP stack is running correctly, you need a basic web page to replace the generic Apache test page.

Open up the default web page in a text editor:

sudo nano /var/www/html/index.php

Modify the contents of the file to look like the following:

<h1>Hello World!</h1>

<p>LAMP on Linode checking in! :]</p>

<?php echo "<p>And don't forget about PHP.</p>"; ?>

<p>- Love,</p>

Be creative here and show off your HTML and PHP skills! Enter your server’s IP address in a browser and you’ll see this message instead of the Apache start page.

Hello, LAMP on Linode!

Setting Up Your Domain

No one these days says “check out”. Although is where the ♥ is…ha! Okay, sorry, bad geek joke.

People want to use domain names like instead. It’s also good for business, branding, and easy to remember.

Luckily, getting a domain name is quick and simple!

First, buy a domain that you want to use. In this case, we used GoDaddy and the domain

Once you’ve registered the domain name, view the domain properties by selecting the Launch button on the right under the Action section, shown below:


Select the DNS Zone File tab and click the Edit button, like so:


Edit the A (Host) record and change the IP address to the address of your Linode server as shown below:


Edit the NS (Nameserver) section and add 4 entries for Linode’s name servers as,,, and

Set the Points To address to an “@” sign – this tells the Nameserver to go look at what is defined for the “@” address set as the A (Host) record in the previoius step — this points to your Linode server.

Your configuration should resemble the screenshot below:


Save the changes via the big black button in the top center of the window and we’re done with GoDaddy.

Head to and log in. On the DNS Manager tab, click the Add a domain zone option, like so:


Enter the domain name you want routed to your server and add a contact email in the event there are any issues with routing traffic, as such:


Finally, click the Add a Master Zone button, and that’s it! A new domain name can take up to 48 hours to propagate over the internet, if your domain doesn’t resolve right away, be patient; you can always use the IP address in the meantime.

Where to Go From Here?

Congratulations! You now have your very own LAMP server configured with some security best-practices, and you can host a basic website on your own. From here, the sky’s the limit!

If you want to create a more robust website but don’t have the necesasry HTML/JS/CSS chops, Twitter’s Bootstrap framework is extremely popular and comes ready for mobile, tablet, and desktop websites out of the box. Likewise, WordPress offers the ability to host your own blog on your server.

If you want to learn more about CentOS system administration, the CentOS 6 Linux Server Cookbook offers a no non-sense look at building and running a CentOS server. Alternatively, if you’d prefer a straight-from-the-source guide, Red Hat has created a System Administration Guide that discusses every detail of working with CentOS.

Hopefully you enjoyed the tutorial; if you have any questions or comments, please let us know in the forum discussion below!

Chris Lowe


Chris Lowe


Over 300 content creators. Join our team.