-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapache2.conf
More file actions
78 lines (54 loc) · 1.38 KB
/
apache2.conf
File metadata and controls
78 lines (54 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
SIMPLE
Step 1 —
Inside, /var/www/your_domain/index.html
add the following sample HTML:
<html>
<head>
<title>Welcome to NIELIT</title>
</head>
<body>
<h1>Success! NIELIT localhost is working!</h1>
</body>
</html>
Step 2 —
Create the Password File
sudo htpasswd -c /etc/apache2/.htpasswd <usarname>
sudo htpasswd /etc/apache2/.htpasswd <another_user>
cat /etc/apache2/.htpasswd
Step 3 —
Inside, /etc/apache2/sites-available/000-default.conf
add the following:
Inside, /etc/apache2/sites-enabled/000-default.conf
add this:
<VirtualHost *:80>
ServerAdmin admin@your_email_domain
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
<Directory "/var/www/html">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
</VirtualHost>
Step 4 —
Inside, /etc/hosts
add the following:
<ip> domain.name
127.0.0.1 mydomain.com
sudo systemctl restart apache2
Step 6 —
if needed
allowed in:
/var/www/html/.htaccess
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
Step 7 —
sudo apache2ctl configtest
sudo systemctl restart apache2
navigating to http://your_domain