Briefly record it.
Environment preparation
Virtual Machine Environment
sudo -i[sudo for LZ: [email protected]:cat /etc/ 16.04. 2 LTS \ \l
Update system
sudo apt-get update
Installing Apache
sudo Install apache2
[Email protected]:~# apache2-vServer version:apache/2.4. - (Ubuntu) Server built: 2018--18t14: £º
Default Web path:/var/www/html
pwd/var/www/html[email protected]:lsindex.html
Access local address: localhost or 127.0.0.1
Install PHP
[email protected]:~# sudo apt-get PHP7. 0
[email protected]:~# PHP7. 0 - 7.0 . 28 -0ubuntu0. 16.04 . 1 (CLI) (NTS) Copyright (c) 1997 -2017 the PHP groupzend Engine v3. 0.0 , Copyright (c) 1998 -2017 Zend Technologies with Zend opcache v7. 0.28 -0ubuntu0. 16.04 . 1 , Copyright (c) 1999 -2017 , by Zend Technologies
sudo Install LIBAPACHE2-MOD-PHP7. 0
Install MySQL
sudo Install Mysql-server
You will be prompted to enter/repeat the password during the installation process.
sudo Install PHP7. 0-mysql
Here the lamp environment even if the installation is successful.
Virtual directory
If you are deploying multiple Web projects on a machine, you can specify them from different ports.
For example: There is a project helo under Web root and I want to access it directly from the Ip:port form.
pwd/var/www/html/helo[email protected]:lsindex.php
This can be done by configuring the virtual directory.
Cat /etc/apache2/ports.conf
In Listen 80 Add the port you want to set, such as 8080
[Email protected]:/var/www/html/helo#Cat/etc/apache2/ports.conf # If You just change the port or add Moreports here, you'll likely also# has to change the VirtualHost statementinch# /etc/apache2/sites-enabled/ the-Default.conflisten the Listen 8080 <ifmodule ssl_module>Listen443</ifmodule><ifmodule mod_gnutls.c>Listen443</IfModule># Vim:syntax=apache ts=4sw=4sts=4SR Noet
To set up a virtual directory:
cat /etc/apache2/sites-available/
Copy a copy of the original content, only need to change the port and documentroot two (local environment, no domain name issues, can also be modified accordingly)
Port setting: 8080, path:/var/www/html/helo
Restart the Apache2 service:
sudo /etc/init.d/apache2 restart
Access Local Ip:port
Yes, index.php's content is the classic phpinfo ().
Ubuntu installation Lamp