Install Apache:
Weirubo@weirubo-VirtualBox: ~$ sudo apt-get install apache2
To view the Apache version:
Weirubo@weirubo-VirtualBox: ~$ apache2-vapache/2.4. (Ubuntu)2016-04-T18:xx:
The above information indicates that Apache installation was successful and access to Apache via the browser:
HTTP/127.0.0.1 or http://localhost
Install PHP7:
Weirubo@weirubo-VirtualBox: ~$ sudo apt-get install PHP7. 0
To view the PHP version:
Weirubo@weirubo-VirtualBox:~$ PHP7.0-vPhp7.0.4-7UBUNTU2 (CLI) (nts) Copyright (c) 1997-2016 the php groupzend engine v3. 0.0, copyright (c) 1998-< Span class= "number" >2016 zend technologies with 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:
Weirubo@weirubo-VirtualBox: ~$ sudo apt-get install LIBAPACHE2-MOD-PHP7. 0
To see if the libapache2-mod-php7.0 installed successfully:
Weirubo@weirubo-VirtualBox: ~$ 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:
Weirubo@weirubo-VirtualBox: ~$ sudo apt-get install mysql-server
You will be asked to enter the root password during installation.
Install Php7.0-mysql:
Weirubo@weirubo-VirtualBox: ~$ sudo apt-get install PHP7. 0-mysql
To restart MySQL:
Weirubo@weirubo-VirtualBox: ~$ sudo service mysql restart
To restart Apache:
Weirubo@weirubo-VirtualBox: ~$ 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
Weirubo@weirubo-VirtualBox: ~$ sudo vim/var/www/html/phpinfo.php
Enter the PHP code, save and exit:
<?php Echo phpinfo ();? >
Using a browser to access:
http://127.0.0.1/phpinfo.php
Ubuntu16.04 Building Lamp Architecture Server