Ubuntu 16.04 Apt-get Build lamp environment

Source: Internet
Author: User
Tags php script phpinfo

This article focuses on using the Apt-get installation lamp (Ubuntu 16.04,apache2.4.18,mysql5.7.12,php7.0.4) environment in Ubuntu, so no longer describes how to install Ubuntu. Install Apache:
[email protected]:~$ sudo apt-get install apache2

To view the Apache version:

[email protected]:~$ apache2 -vServer version: Apache/2.4.18 (Ubuntu)Server built:   2016-04-15T18:00:57

The above information indicates that Apache was successfully installed and accessed via browser APACHE:HTTP://127.0.0.1/

sudo vim /etc/apache2/apache2.conf    // 将 <Directory /var/www/>    // 改成 <Directory "你的目录">    // 可以将/var/www 中的默认网页复制到 你的目录 中sudo vim /etc/apache2/sites-available/000-default.conf    // 将 DocumentRoot /var/www/html    // 改成 DocumentRoot "你的目录"sudo /etc/init.d/apache2 restart    // 重启
Install PHP7:
[email protected]:~$ sudo apt-get install php7.0

View PHP Version: [Email protected]:~$ php7.0-v

PHP 7.0.4-7ubuntu2 (cli) ( NTS )Copyright (c) 1997-2016 The PHP GroupZend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologieswith Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

The above information indicates that the PHP7 installation was successful.

Install libapache2-mod-php7.0:

[email protected]:~$ sudo apt-get install libapache2-mod-php7.0

To see if the libapache2-mod-php7.0 installed successfully:

[email protected]:~$ cat /etc/apache2/mods-enabled/php7.0.load# Conflicts: php5LoadModule php7_module /usr/lib/apache2/modules/libphp7.0.so

The above information indicates that the libapache2-mod-php7.0 installation was successful and PHP7 successfully loaded the module libphp7.0.so

Install MySQL:
[email protected]:~$ sudo apt-get install mysql-server

You will be asked to set the root password during installation.

Install Php7.0-mysql:

[email protected]:~$ sudo apt-get install php7.0-mysql

To restart MySQL:

[email protected]:~$ sudo service mysql restart

To restart Apache:

[email protected]:~$ sudo service apache2 restart

To complete the lamp environment, let's write a PHP script to test whether Apache can parse PHP files: Create a new PHP file, phpinfo.php

[email protected]:~$ sudo vim /var/www/html/phpinfo.php

Enter the PHP code, save and exit:

<?php    echo phpinfo();?>

Access using the browser: http://127.0.0.1/phpinfo.php

Original http://www.php-z.com/article-2924-1.html

Ubuntu 16.04 Apt-get build lamp environment

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.