apache/install.sh

raw link view readme
1 yum install policycoreutils-python -y
2
3 semanage fcontext -at httpd_sys_rw_content_t "/srv(/.*)?"
4
5 yum install firewalld -y
6 systemctl start firewalld
7 systemctl enable firewalld
8 firewall-cmd --permanent --zone=public --add-interface=eth0
9 firewall-cmd --permanent --add-service=http --zone=public
10 firewall-cmd --reload
11
12 systemctl start httpd
13 systemctl enable httpd
14
15 htpasswd -b -c /srv/website-password dbetz mypassword
16 htpasswd -b /srv/website-password user01 stuff
17
18 # password area (http://localhost/stuff)
19
20 cat >> /etc/httpd/conf/httpd.conf << EOF
21
22 Order allow,deny
23 Allow from 10.0.0.0/8
24 AuthType Basic
25 AuthName "apache sucks"
26 AuthUserFile /srv/website-password
27 Require user dbetz
28
29 EOF
30
31 mkdir /var/www/html/stuff
32 cat > /var/www/html/stuff/index.html << EOF
33 stuff here
34 EOF
35
36 # home dirs (http://localhost/~dbetz)
37 setsebool -P httpd_enable_homedirs 1
38 sed -i "s/#UserDir public_html/UserDir public_html/;s/ UserDir disabled/ #UserDir disabled/" /etc/httpd/conf.d/userdir.conf
39
40 mkdir /home/dbetz/public_html
41 chmod 701 /home/dbetz
42 chmod 701 /home/dbetz/public_html
43
44 cat > /home/dbetz/public_html/index.html << EOF
45 home here
46 EOF
47
48 restorecon -R -v /srv
49 chown -R nobody:apache /srv
50
51 systemctl restart httpd
52