mysite-day02

Setup LAMP Stack

Check Apache

Check location of Apache:

1
2
which apache2
/usr/sbin/apache2

Check status of Apache server:

1
sudo service apache2 status

You may get following result if the service is running properly:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled>)
Active: active (running) since <timestamp>; xxmin ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 698 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 836 (apache2)
Tasks: 55 (limit: 2289)
Memory: 12.1M
CGroup: /system.slice/apache2.service
|-836 /usr/sbin/apache2 -k start
|-846 /usr/sbin/apache2 -k start
|-847 /usr/sbin/apache2 -k start

Jun 05 14:04:34 xiaoqi-web-002 systemd[1]: Starting The Apache HTTP Server...
Jun 05 14:04:35 xiaoqi-web-002 systemd[1]: Started The Apache HTTP Server.

Start Apache Server if it’s deactive

sudo service apache2 start

Check Hosts File

1
2
3
4
more /etc/hosts
===============
127.0.0.1 localhost
...

Noted: the apache website files are located in /var/www/html/index.html

Edit index.php

1
touch /var/www/html/index.php

Type below content:

1
2
3
<?php
echo phpinfo();
?>

You can remove the original index.html, then the default website will show the PHP page, if now, you need to install the PHP first.

Install PHP

1
2
3
php -v
# if not installed, please do below
sudo apt-get install php7.4

Install MySQL

1
2
sudo apt-get install mysql-server
systemctl status mysql.service

With GUI, you can install DBeaver to manage the MySQL database

Information: https://github.com/Alecaddd/virtualhost to get the automatic script for install/delete Apache sites.