--- slug: Building Your Web Server Installing Apache title: Building Your Web Server Installing Apache, MySQL, PHP (LAMP) Stack on Ubuntu 12.04 authors: [slorber, yangshun] tags: [hola, docusaurus] --- import CodeBlock from '@site/src/components/CodeBloack';
What is LAMP?
LAMP stack is a bundle of free software that helps set up web servers. The name stands for Linux, Apache, MySQL, and PHP. Since your virtual private server is already using Ubuntu (which is a type of Linux), you've got one part covered. Now, let's see how to install the rest.
Getting Started
To follow this tutorial, you'll need to have administrator access on your VPS. If you're unsure how to set this up, check out the "Initial Server Setup" guide for instructions on getting started.
Setting Up Apache
Apache is a popular, free software used to run many websites.

To install Apache, follow these steps:
  1. Open the terminal on your computer.
  2. Type in the following commands:

That's all there is to it! To make sure Apache is installed correctly, just open your web browser and enter your server's IP address (e.g., http ://12.34.56.789). If everything's set up right, you'll see a page with the words "It works!" on it.
How to Check Your Server's IP Address
To find out your server's IP address, you can use the following command:

MySQL Setup
MySQL is a system that helps you manage your data, making it easier to organize and find information.

To install MySQL, follow these steps in your terminal:

After the installation, MySQL will prompt you to set a root password. If you didn't set the password during the installation, don't worry. You can easily set it later from inside the MySQL shell.
Once MySQL is installed, let's activate it with this command:

To complete the process, run the MySQL setup script:

You'll be asked to enter your current root password. Just type it in.
Enter current password for root (enter for none): OK, successfully used password, moving on…
Next, the prompt will inquire if you wish to change the root password. Select "N" to keep the current password and proceed to the following steps.

It's simplest to say "Yes" to all the options. Once you've done that, MySQL will reload and apply the updates.

After completing those steps, you can wrap up by installing PHP.
Getting PHP installed
PHP is an open source web scripting language that is widely used to build dynamic web pages.
To add PHP to your system, open your terminal and type in this command.

Once you've confirmed "yes" to the prompt twice, PHP will install itself automatically.

You might also want to include PHP in the directory index, so it can serve the appropriate PHP index files:

Make sure to include "index.php" at the start of your index files. Your page should now appear like this:
DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm `} />
PHP Extensions
In addition to its core functionality, PHP offers various libraries and extensions that you can install on your virtual server. You can view the available extensions to enhance PHP's capabilities.

The terminal will show you a list of modules you can choose from. It will look something like this:

When you've chosen the module you want to install, type the following command:

You can install multiple libraries simultaneously by listing each module's name with a space in between.

Great job! Your droplet now has a fully functional LAMP stack!
Your PHP server's results - Viewing PHP
Even though LAMP is installed, let's confirm by creating a simple PHP info page. To do this, start by making a new file:

Now, include the following line:
`} />
After that, save your changes and close the file.

Next, restart Apache to make sure all the changes are applied:

Finally, open your web browser and go to your PHP info page. Make sure to replace "12.34.56.789" with the correct IP address of your server: http://your_server_ip_address/info.php

Conclusion -
Awesome job! You've built a solid foundation for your website using LAMP on Ubuntu. With Apache for serving pages, MySQL for managing data, and PHP for dynamic content, your server is ready to go. To do even more with your server, you can try adding new features with PHP extensions or explore different tools and frameworks that work well with LAMP.

Excited to start creating your website or app? Let's dive in!