Ubuntu 16.04 Build LAMP Environment

Source: Internet
Author: User
Install Apache
$ sudo apt-get install apache2

Open the browser, Access http://localhost/The following page shows that Apache has been working.

For Ubuntu 16.04, you can view the status of Apache through the service and start, stop, restart, and so on.

$ sudo service apache2 Status/start/stop/restart

Default Web directory:/var/www/html/
Configuration directory:/etc/apache2/
Global configuration file:/etc/apache2/apache2.conf
Port configuration file:/etc/apache2/ports.conf
Virtual Host configuration file:/etc/apache2/sites-enabled/000-default.conf install MySQL

We know that MySQL is a C/S model, so install server and client:

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

During installation, you will be prompted to set the password for the MySQL root account before continuing with the installation.
Verify that the installation is successful:

$ mysql--version
mysql  Ver 14.14 distrib 5.7.21, for Linux (x86_64) using  editline Wrapper

Login test:

$ mysql-u Root-p

Enter a password to log in, indicating that the MySQL installation was successful.
Similarly, MySQL can also be controlled by service:

$ sudo service MySQL Status/start/stop/retart

To view the listening port condition:

Or

$ sudo netstat-tap
Installing PHP
$ sudo apt-get install php7.0

Check:

$ php7.0-v
php 7.0.25-0ubuntu0.16.04.1 (CLI) (NTS)
Copyright (c) 1997-2017 the PHP Group
Zend Engine v3.0.0 , Copyright (c) 1998-2017 Zend Technologies with
    Zend Opcache v7.0.25-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Ze ND Technologies

OK, let's write a PHP test right away. Create a new hello.php file in the/var/www/html directory, which reads:

<?php
    echo "Hello php!";
    Echo Phpinfo ();
? >

Save exit, enter http://localhost/hello.php in browser, amount ... Found nothing. Because the WEB server does not have the ability to parse the file, we have to install an extension module on it.

That is to say to Apache add a plug-in, after the Apache see the user request PHP file, will give this module processing, that is, the server end of the processing of PHP files and then transmitted to the user.

$ sudo apt-get install libapache2-mod-php7.0

After installation, restart the Apache service, refresh the page, you can see the following screen.

Installing additional modules

Install one more module:

$ sudo apt-get install Php7.0-mysql

Install phpMyAdmin

$ sudo apt-get install phpMyAdmin

Installation process Select Apache2, click OK, the next option is to configure the database and enter a password.
After the installation is complete, we can create phpMyAdmin shortcuts:

$ sudo ln-s/usr/share/phpmyadmin/var/www/html

Launch Apache mod_rewrite module:

$ sudo a2enmod rewrite

Restart Service:

$ sudo service php7.0-fpm restart
$ sudo service apache2 restart
$ sudo service mysql restart

Then, access Http://127.0.0.1/phpmyadmin in the browser, as follows:

All right, Ubuntu 16.04 's LAMP environment is set up and a sip of tea for a rest ...

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.