Ubuntu 18.04 LTS LAMP build

1、 Install Apache environment

First, we need to use sudo apt-get update to update the list of apt package managers in the current system. Then use the sudo apt install apache2 command to install the Apache software.

sudo apt-get update
sudo apt-get install apache2

After inputting, you will see the following output

ubuntu@VM-0-7-ubuntu:~$ sudo apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:........
Need to get2,857 kB of archives.
After this operation,9,307 kB of additional disk space will be used.
Do you want to continue?[Y/n]

Here to ask us whether to install, we press Y on the keyboard, and then press the Enter key, after which you will see output similar to the following:

Get:1 http://mirrors.tencentyun.com/ubuntu xenial-security/main amd64 libjpeg-tu
.........
Processing triggers forufw(0.35-0ubuntu2)...
ubuntu@VM-0-7-ubuntu:~$

At this time, you have installed the Apache service, try to access your server through a browser, find the public IP of your server in the Tencent Cloud console, and copy it to the browser to open it. If you see the following output, it proves you Apache has been successfully installed.

**2、 Install **MySQLDatabase Service

We have installed the basic web service software Apache. Next we will install the database service. There are many choices for the database. Here we choose the most commonly used MySQL service. Just like installing Apache, we only need to enter sudo apt-get install mysql-server to install MySQL service. The MySQL version installed here is version 5.7.

sudo apt-get install mysql-server

After the input is complete, you will see the following output

ubuntu@VM-0-7-ubuntu:~$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:........0 upgraded,21 newly installed,0 to remove and 205 not upgraded.
Need to get19.4 MB of archives.
After this operation,162 MB of additional disk space will be used.
Do you want to continue?[Y/n] y

Please press Y on the keyboard and press Enter to continue. Next, the installer will ask you to enter the password of your database root user, as shown in the figure.

Here, please enter the password you want to set for the root user. I enter passwd as an example. Please set a more complicated password when setting it yourself. After the input is complete, press Enter, and the system will ask you to enter the password you just set again. Similarly, after the input is complete, we press Enter. Next will enter the long installation process, you will see output similar to the following.

Do you want to continue?[Y/n] y
Get:1 http://mirrors.tencentyun.com/ubuntu xenial-security/main amd64 mysql-common all 5.7.23-0ubuntu0.16.04.1[15.4 kB]
Get:2 http://mirrors.tencentyun.com/ubuntu xenial/main amd64 libaio1 amd64 0.3.110-2[6,356 B]..........
Setting up mysql-server(5.7.23-0ubuntu0.16.04.1)...
Processing triggers for libc-bin(2.23-0ubuntu9)...
Processing triggers forsystemd(229-4ubuntu21.2)...
Processing triggers forureadahead(0.100.0-19)...
ubuntu@VM-0-7-ubuntu:~$

Next, we will install the php environment.

3、 Install PHP environment

The same simple, we can still use the apt package manager to install php, but this time we not only need to install php itself, but also install php-fpm, which is a FastCGI manager and can be effective Control memory and process, can smoothly reload PHP configuration. Similarly, in order to connect to the database, we also need to install the php-mysql plugin. At the same time, in order to connect to Apache, we also need to install the libapache2-mod-php plugin. Use the following command to quickly install.

sudo apt-get install php
sudo apt-get install php-fpm
sudo apt-get install php-mysql
sudo apt-get install libapache2-mod-php

After entering these three commands, the system will also output a lot of content, we just need to wait patiently. It is worth noting that my system version is Ubuntu server 18.04 LTS, and PHP 7.2 is installed by default.

4、 Check whether it is working properly

We can test whether our php is running normally. Before the test, we need to prepare the test script. Here we create a new file named info.php. This file must be placed in the directory pointed to by the root line in the default.conf we wrote above, in the configuration The file /etc/apache2/apache2.conf can be viewed. The configuration in this article is in the /var/www/html directory. The specific operations are as follows.

cd /var/www/html
vim info.php

Then write the following code in the editor

<? php phpinfo();?>

Then press the ESC key on the keyboard, then press shift+;, enter w+q to save and exit. Next, visit http://your server's public IP address/info.php through a browser. If you see the result as shown in the figure, it proves that everything is normal. Start deploying your favorite programs as soon as possible.

( Modified from https://cloud.tencent.com/developer/article/1357329)

Recommended Posts

Ubuntu 18.04 LTS LAMP build
lamp on ubuntu
Ubuntu build etcd
Ubuntu build Seafile
Build a LAMP development environment on Ubuntu 16.04
Ubuntu18.04.3 LTS first experience
Ubuntu 18.04 LTS quickly beautified
[Linux] Build Samba server (ubuntu16.04)
ubuntu16.04 build vim and pyt
ubuntu 16.04 build pptpd V** server
Install Python 3.7 on Ubuntu 18.04 LTS
Server upgrade Ubuntu 20.04 LTS record
Build Ubuntu 12.04 cross compilation server
Detailed ubuntu 20.04 LTS installation record
ubuntu1804 build the latest Suricata
Server upgrade Ubuntu 20.04 LTS record
ubuntu build python development environment
Ubuntu16.04 build GitLab server tutorial
How to upgrade to Ubuntu 16.04 LTS
Ubuntu 18.04.1 build Java environment and HelloWorld
Detailed ubuntu14.04 build (migration) hustoj record
Build Nginx-RTMP live server on ubuntu
[Sharp Tools]-Try Ubuntu 20.04 (LTS) Focal Fossa
Ubuntu16.04 build php5.6 Web server environment
Windows10 update Ubuntu20.04 LTS method steps
UBUNTU 16.04 LTS experience (commemorating LINUX-25 anniversary)
Build a file server on ubuntu
Build Discuz forum based on ubuntu
How to build nfs service on ubuntu16.04
[Linux] Pure ubuntu quickly build pagoda panel
Build the C++ compilation environment under ubuntu
Configure Java development environment in Ubuntu20.04 LTS
Steps to build LNMP environment on ubuntu 20.04
Build arm virtual operating environment on Ubuntu
Ubuntu 18.04 LTS configuration network tutorial through Netplan
Build a python development environment under Ubuntu
Build a Minecraft Bedrock Edition server (Ubuntu)