-
Notifications
You must be signed in to change notification settings - Fork 4
/
aws-ec2-rhel8-apache24-server.sh
executable file
·123 lines (104 loc) · 3.72 KB
/
aws-ec2-rhel8-apache24-server.sh
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/bash
yum update -y
yum install gcc make -y
# https://libexpat.github.io
cd ~
wget https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.gz
tar -zxvf expat-2.2.9.tar.gz
cd expat-2.2.9
./configure --prefix=/opt/SP/expat-2.2.9
make clean && make && make install
echo "/opt/SP/expat-2.2.9/lib" >> /etc/ld.so.conf
ldconfig
# https://github.com/nghttp2/nghttp2/releases
cd ~
wget https://github.com/nghttp2/nghttp2/releases/download/v1.40.0/nghttp2-1.40.0.tar.gz
tar -zxvf nghttp2-1.40.0.tar.gz
cd nghttp2-1.40.0
./configure --prefix=/opt/SP/nghttp2-1
make clean && make && make install
echo "/opt/SP/nghttp2-1/lib" >> /etc/ld.so.conf
ldconfig
# https://apr.apache.org/download.cgi
cd ~
wget http://mirror.vorboss.net/apache//apr/apr-1.7.0.tar.gz
tar -zxvf apr-1.7.0.tar.gz
cd apr-1.7.0
./configure --prefix=/opt/SP/apr-1.7.0
make clean && make && make install
echo "/opt/SP/apr-1.7.0/lib" >> /etc/ld.so.conf
ldconfig
yum install openldap-devel -y
# https://apr.apache.org/download.cgi
cd ~
wget http://www.mirrorservice.org/sites/ftp.apache.org//apr/apr-util-1.6.1.tar.gz
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/opt/SP/apr-util-1.6.1 \
--with-apr=/opt/SP/apr-1.7.0 \
--with-expat=/opt/SP/expat-2.2.9 \
--with-ldap \
--with-ldap-lib=/usr/lib64 \
--with-ldap-include=/etc/openldap
make clean && make && make install
echo "/opt/SP/apr-util-1.6.1/lib" >> /etc/ld.so.conf
ldconfig
yum install openssl-devel pcre-devel zlib-devel -y
# https://httpd.apache.org/download.cgi#apache24
cd ~
wget http://apache.mirror.anlx.net/httpd/httpd-2.4.46.tar.gz
tar -zxvf httpd-2.4.46.tar.gz
cd httpd-2.4.46
./configure --prefix=/opt/apache-2.4 \
--with-apr=/opt/SP/apr-1.7.0 \
--with-apr-util=/opt/SP/apr-util-1.6.1 \
--libdir=/opt/apache-2.4/lib64 \
--enable-nonportable-atomics=yes \
--with-devrandom=/dev/urandom \
--with-ldap \
--enable-authnz-ldap \
--with-crypto \
--with-gdbm \
--with-ssl \
--enable-mods-shared=all \
--enable-mpms-shared=all \
--enable-authnz_fcgi \
--enable-cgi \
--enable-pie \
--enable-http2 \
--enable-proxy-http2 \
--with-nghttp2=/opt/SP/nghttp2-1 ac_cv_openssl_use_errno_threadid=yes
make clean && make && make install
ln -s /opt/apache-2.4 /opt/SP/apache-2.4
chown -R wwwadm:www /opt/apache-2.4
sed -i 's/^User daemon\s*$/User wwwrun/' /opt/SP/apache-2.4/conf/httpd.conf
sed -i 's/^Group daemon\s*$/Group wwwrun/' /opt/SP/apache-2.4/conf/httpd.conf
sed -i 's/^Listen 80$/Listen 8080/' /opt/SP/apache-2.4/conf/httpd.conf
sed -i 's~^#LoadModule proxy_http_module modules/mod_proxy_http.so~LoadModule proxy_http_module modules/mod_proxy_http.so~' /opt/SP/apache-2.4/conf/httpd.conf
sed -i 's~^#LoadModule proxy_module modules/mod_proxy.so~LoadModule proxy_module modules/mod_proxy.so~' /opt/SP/apache-2.4/conf/httpd.conf
sed -i 's~/opt/apache-2.4/htdocs~/var/SP/httpd/htdocs~g' /opt/SP/apache-2.4/conf/httpd.conf
echo 'export PATH=$PATH:/opt/SP/apache/bin' >> ~/.bash_profile
chown -R wwwadm:www /opt/SP/apache-2.4
chmod +s /opt/SP/apache-2.4
cd ~
mkdir -p /var/SP/httpd
chown -R wwwadm:www /var/SP/httpd
mv /opt/SP/apache-2.4/htdocs /var/SP/httpd
cp ~/aws-ec2-install-scripts/assets/services/apache /etc/init.d
chown root:root /etc/init.d/apache
chmod 611 /etc/init.d/apache
chkconfig apache on
service apache start
netstat -antup | grep -i 8080
echo "" >> /etc/sudoers
echo "%www ALL=(ALL) NOPASSWD:/usr/sbin/service" >> /etc/sudoers
yum remove gcc make openldap-devel openssl-devel pcre-devel zlib-devel -y
rm -f /root/apr-1.7.0.tar.gz
rm -f /root/apr-util-1.6.1.tar.gz
rm -f /root/expat-2.2.9.tar.gz
rm -f /root/httpd-2.4.46.tar.gz
rm -f /root/nghttp2-1.40.0.tar.gz
rm -f ~wwwadm/.bash_profile
cp ~/.bash_profile ~wwwadm/.bash_profile
chmod 644 ~wwwadm/.bash_profile
chown wwwadm:www ~wwwadm/.bash_profile