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