본문 바로가기
Web/Server & MySQL

[2022.05.02] How to install apache2 on Ubuntu20.04 ?

by injekim97 2022. 5. 2.
반응형

[2022.05.02] How to install apache2 on Ubuntu20.04 ?

 



# apache2 install 

sudo apt update
sudo apt upgrade
sudo apt install apache2




# setup firewall

sudo ufw app list

Available applications:
  Apache          # 80 
  Apache Full     # 80 / 443
  Apache Secure   # 443 
  CUPS      # 22

 

sudo systemctl status apache2


● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-05-02 13:01:39 KST; 4min 0s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 45998 (apache2)
      Tasks: 55 (limit: 19120)
     Memory: 4.9M
     CGroup: /system.slice/apache2.service
             ├─45998 /usr/sbin/apache2 -k start
             ├─45999 /usr/sbin/apache2 -k start
             └─46000 /usr/sbin/apache2 -k start

 

 


apache server conf setting & custom 

sudo systemctl enable apache2

-> apache server background run

 

sudo mkdir /var/www/your_domain
sudo chown -R vmadmin:vmadmin /var/www/your_domain/
sudo chown -R 755 /var/www/your_domain/

-> apache-server permission grant



# apache-server-site custom (최초 1회만)

sudo vim /var/www/your_domain/index.html
<!DOCTYPE html>
<html lang="en">
        <head>
                <title> OJT Subject - Elasticsearch </title>
                <meta charset="utf-8">
                <meta name="Viewport" content="width=device-width,initial-Scale=1.0">
        </head>

        <body>
        <iframe src="http://192.168.215.7:5601/app/r/s/orange-hot-vulture" height="800" width="1800">
        </iframe>
        </body>
</html>

 

sudo vim /etc/apache2/sites-available/your_domain.conf
<VirtualHost *:80>
    ServerAdmin    webmaster@localhost
    ServerName     http://192.168.215.7
    ServerAlias    http://192.168.215.7
    DocumentRoot   /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/acces.log combined
</VirtualHost>

 

sudo a2ensite your_domain.conf 
sudo a2dissite 000-default.conf 
sudo apache2ctl configtest

 


# 계속적으로 Page 수정할 때 

sudo vim /var/www/your_domain/index.html
sudo systemctl restart apache2
vmadmin@vmadmin-virtual-machine:/usr/share/logstash$ sudo ufw allow 'Apache FUll'
Rule added
Rule added (v6)
vmadmin@vmadmin-virtual-machine:/usr/share/logstash$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
9200                       ALLOW       Anywhere                  
5601                       ALLOW       Anywhere                  
80                         ALLOW       Anywhere                  
443                        ALLOW       Anywhere                  
3306                       ALLOW       Anywhere                  
22/tcp                     ALLOW       Anywhere                  
Apache Full                ALLOW       Anywhere
반응형

댓글