클라우드 서버 도움말

Build a LAMP stack (Linux, Apache, MySQL, PHP) - Ubuntu 14

Difficulty: 3
Time: 20 minutes

To build a dynamic web application, you need what has been coined a “stack” - which is developer lingo for an integrated set of software that has all of the components your application needs.

Most stacks have the same types of components and differ mainly in which pieces of software they use for those components. For example, we’ll look at LAMP (which this article covers):

Component LAMP Software
Operating system Linux (e.g. Ubuntu)
Web server Apache
Database MySQL
Programming language PHP

If you're astute, maybe you noticed that LAMP is just an acronym for the software the stack uses.

In this guide, we'll walk you through installing all of these components (except for Linux, which is already installed as your OS when you create the server).

Install Apache

  1. Before you begin any installation, make sure that your software is up to date:
    sudo apt-get update
  2. Install Apache:
    sudo apt-get install apache2
  3. Set Apache to start on server boot:
    sudo update-rc.d apache2 defaults
  4. Verify that Apache is installed by going to:
    http://your server's IP address.
    If Apache is installed, the Apache Test Page displays.

    Note: GoDaddy Cloud Server customers can use Find your server's IP.

Install MySQL

  1. Install MySQL:
    sudo apt-get install mysql-server php5-mysql
  2. Enter a root password, and then press enter.
    Warning: It is possible to not enter a password here. However, we cannot urge you strongly enough to enter a strong password here. Without one your server becomes incredibly vulnerable.
  3. Activate MySQL:
    sudo mysql_install_db
  4. Set MySQL to start on server boot:
    sudo update-rc.d mysql defaults
  5. Secure your database server:
    sudo /usr/bin/mysql_secure_installation

    Answer the following questions when prompted:

    Question Suggested Answer Why/Why not?
    Enter current password for root (enter for none): Enter the password you created earlier. MySQL needs this password to have sufficient access to system resources, so that it can function as a database server.
    Do you want to change the root password? n Unless you want to change what you just did.
    Remove anonymous users? y The anonymous user allows anyone to login without requiring an account created by an admin. A hacker attempting to compromise your database server may try logging in as this user.
    Disallow root login remotely? y It is more secure to create a non-root user with admin permissions. Answer "no," if you need more flexibility to manage your database server.
    Remove test database and access to it? y If you have a reason to keep a test database, answer "no."
    Reload privilege tables now? y Why wait?

Install PHP

  • Install PHP
    sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Because you're going to use PHP for your site, you should also make sure Apache prioritizes index.php over other index files (that is: the file that displays when visitors come to your website).

  1. Open the dir.conf file:
    sudo vim /etc/apache2/mods-enabled/dir.conf
  2. Move index.php to the first position directly after DirectoryIndex, so the line looks like this:
    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
  3. Save and close the file:
    :wq!
  4. Restart Apache:
    sudo service apache2 restart

Install PHP modules

If your applications requires any PHP modules, you can install them now.

  1. View available PHP modules:
    apt-cache search php5-
  2. The list of available PHP modules displays. If you want to get more information on a particular package, you can display the description by typing:
    apt-cache show the name of the package you want to use
  3. Install the package you want:
    sudo apt-get install the name of the package you want to use

Test PHP processing on Apache

  1. Create a new PHP file under the /var/www/html directory:
    sudo vim /var/www/html/info.php
  2. After the file opens, type in the following code:
    <?php
    phpinfo();
    ?>
  3. Save and close the file:
    :wq!
  4. To verify it works, type this URL in your browser: http://your server's IP address/info.php

A page displays with the PHP version, extensions, build date, and other information.

Next steps

Now that you have a LAMP stack, we recommend setting up Apache Virtual Hosts for your websites.


이 글이 도움되었나요?
피드백을 보내주셔서 감사합니다. 고객 서비스 담당자에게 문의하시려면 지원 전화 번호 또는 위의 채팅 옵션을 이용하시기 바랍니다.
도와드릴 수 있어 기쁩니다! 더 도와 드릴 것이 있나요?
그것 유감스럽습니다. 혼동이 되었던 사항 또는 솔루션이 고객님의 문제를 해결하지 못했던 원인을 알려주세요.