Build lamp Environment under Ubuntu16.04

Source: Internet
Author: User
Tags php script phpinfo zend

Install Apache:
sudo apt-get install apache2

To view the Apache version:

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:
sudo apt-get install php7.0

To view the PHP version:

~$ 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:

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

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

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:
sudo apt-get install mysql-server

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

Install Php7.0-mysql:

sudo apt-get install php7.0-mysql

To restart MySQL:

sudo service mysql restart

To restart Apache:

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

Enter the PHP code, save and exit:

<?php    echo phpinfo();?>

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

Reference:

Https://www.linuxidc.com/Linux/2016-09/135614.htm

Build lamp Environment under Ubuntu16.04

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.