How to Install Linux, Apache, MySQL, PHP (LAMP) stacks on Ubuntu

Source: Internet
Author: User
Tags auth gmp install php snmp snmp module sqlite tidy xsl

About LAMP

LAMP Stack is a group of open source software used to get Web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the virtual private server is a already running Ubuntu, the Linux part was taken care of. Here's how to install the rest.

Set up

The steps-tutorial require the user to has root privileges on your VPS. You can see how to set the-in-Initial Server Setup in steps 3 and 4.

Step 1:install Apache

Apache is a free open source software which runs over 50% of the world ' s Web servers.

To install Apache, open terminal and type in these commands:

sudo apt-get updatesudo apt-get install apache2

That ' s it. To check if Apache was installed, direct your browser to your server ' s IP address (eg. http://12.34.56.789). The page should display the words "It works!" like this.

How to Find your Server ' s IP address

You can run the following command to reveal your server ' s IP address.

Ifconfig eth0 | grep inet | awk ' {print $} '
Step 2:install MySQL

MySQL is a powerful database management system used for organizing and retrieving data

To install MySQL, open terminal and type in these commands:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

During the installation, MySQL would ask you to set a root password. If you miss the chance to set the password and the program is installing, it's very easy-to-set the password later from Within the MySQL shell.

Once you has installed MySQL, we should activate it with the This command:

sudo mysql_install_db

Finish up by running the MySQL set up script:

Sudo/usr/bin/mysql_secure_installation

The prompt would ask you to your current root password.

Type it in.

Enter current password to root (enter for none): OK, successfully used password, moving on ...

Then the prompt would ask if you want the root password. Go ahead and choose N and move on to the next steps.

It ' s easiest just to say Yes to the options. At the end, MySQL would reload and implement the new changes.

By default, a MySQL installation had an anonymous user, allowing Anyoneto logs into MySQL without had to had a user ACC  Ount created Forthem.  This was intended only for testing, and the Installationgo a bit smoother. You should remove them before moving into aproduction environment. Remove anonymous users? [y/n] Y ... success!  Normally, Root should only is allowed to connect from ' localhost '. Thisensures that someone cannot guess at the root of password from the network. Disallow Root login remotely? [y/n] Y ... success!  By default, MySQL comes with a database named ' test ' that anyone canaccess. This was also intended only for testing, and should was removedbefore moving into a production environment. Remove test database and access to it? [y/n] y-dropping Test Database ... success! -Removing privileges on test database ... success! Reloading the privilege tables would ensure that all changes made so farwill take effect immediately. REload privilege tables now? [y/n] Y ... success! Cleaning up ...

Once you ' re do with that can finish up by installing PHP.

Step 3:install PHP

PHP is a open source Web scripting language that's widely use to build dynamic webpages.

To install PHP, open terminal and type in the This command.

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

After your answer yes to the prompt twice, PHP would install itself.

It may also is useful to add PHP to the directory index, to serve the relevant PHP index files:

sudo nano/etc/apache2/mods-enabled/dir.conf

Add index.php to the beginning of index files. The page should now:

<ifmodule mod_dir.c>          directoryindex index.php index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule>
PHP Modules

PHP also has a variety of useful libraries and modules so you can add onto your virtual server. You can see the libraries is available.

Apt-cache Search php5-

Terminal'll then display the list of possible modules. The beginning looks like this:

Php5-cgi-server-side, html-embedded scripting language (CGI binary) Php5-cli-command-line interpreter for the PHP5 SCRI  pting Languagephp5-common-common files for packages built from the PHP5 sourcephp5-curl-curl module for php5php5-dbg- Debug symbols for Php5php5-dev-files for PHP5 module DEVELOPMENTPHP5-GD-GD module for PHP5PHP5-GMP-GMP module for P HP5PHP5-LDAP-LDAP module for php5php5-mysql-mysql module for PHP5PHP5-ODBC-ODBC module for Php5php5-pgsql-postgres QL module for Php5php5-pspell-pspell module for Php5php5-recode-recode module for PHP5PHP5-SNMP-SNMP module for PHP5 Php5-sqlite-sqlite module for php5php5-tidy-tidy module for PHP5PHP5-XMLRPC-XML-RPC module for php5php5-xsl-xsl mo Dule for Php5php5-adodb-extension optimising the ADODB database abstraction libraryphp5-auth-pam-a PHP5 Extension for PAM authentication[...]

Once decide to install the module, type:

Name of the module

You can install multiple libraries at once by separating the name of each module with a space.

congratulations! Your now has LAMP stack on your droplet!

Step 4:results-see PHP on your Server

Although LAMP is installed, we can still take a look and see the components online by creating a quick PHP Info page

To set the this up, first create a new file:

sudo nano/var/www/info.php

ADD in the following line:

<?phpphpinfo ();? >

Then Save and Exit.

Restart Apache So, all of the changes take effect:

sudo service apache2 restart

Finish up by visiting your PHP Info page (make sure you replace the example IP address with your correct one): http://12.3 4.56.789/info.php

How to Install Linux, Apache, MySQL, PHP (LAMP) stacks on Ubuntu

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.