How to Install Apache on Ubuntu 20.04

Install Apache

sudo apt-get update
Code language: JavaScript (javascript)
sudo apt-get install apache2
Code language: JavaScript (javascript)

Configure Firewall

sudo ufw allow "Apache"
Code language: JavaScript (javascript)
sudo ufw status

Checking Web Server

sudo systemctl status apache2

Setting Up Virtual Hosts

*note that server document directory: /var/www/

Create the website directory

sudo mkdir /var/www/<mark>your_domain</mark>
Code language: JavaScript (javascript)

Assignment ownership of the directory with the $USER environment variable

sudo chown -R $USER:$USER /var/www/<mark>your_domain</mark>
Code language: JavaScript (javascript)

Change permissions

sudo chmod -R 755 /var/www/<mark>your_domain</mark>
Code language: JavaScript (javascript)

In order for Apache to serve this content, it’s necessary to create a virtual host file with the correct directives. Instead of modifying the default configuration file located at /etc/apache2/sites-available/000-default.conf directly, let’s make a new one at /etc/apache2/sites-available/your_domain.conf:

sudo vim /etc/apache2/sites-available/your_domain.conf
<VirtualHost *:80> ServerAdmin [email protected] ServerName your_domain ServerAlias www.your_domain DocumentRoot /var/www/your_domain ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Code language: HTML, XML (xml)

you can add redirect to https in here

<VirtualHost *:80> . . . Redirect "/" "https://your_domain_or_IP/" . . . </VirtualHost>
Code language: HTML, XML (xml)

Save and close the file when you are finished.

Let’s enable the file with the a2ensite tool:

sudo a2ensite your_domain.conf
Code language: CSS (css)

Disable the default site defined in 000-default.conf:

sudo a2dissite 000-default.conf
Code language: JavaScript (javascript)

Next, let’s test for configuration errors:

sudo apache2ctl configtest

Restart Apache to implement your changes:

sudo systemctl restart apache2

No Comments

Send Comment Edit Comment


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next