Created
September 7, 2020 16:59
-
-
Save whittlem/4af40134fe278618e1f6b9459673e348 to your computer and use it in GitHub Desktop.
Amazon AWS EC2 RHEL8 provisioning script for Apache 2.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum repolist all; | |
yum-config-manager --enable codeready-builder-for-rhel-8-rhui-rpms; | |
yum update -y; | |
dd if=/dev/zero of=/swapfile bs=128M count=32; | |
chmod 600 /swapfile; | |
mkswap /swapfile; | |
swapon /swapfile; | |
swapon -s; | |
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab; | |
mkdir -p /opt/SP/home; | |
groupadd www; | |
groupadd wwwadm; | |
groupadd wwwrun; | |
useradd -c "WWW Run User" -d /opt/SP/home/wwwrun -s /sbin/nologin -g www wwwrun; | |
usermod -a -G www wwwrun; | |
usermod -a -G wwwrun wwwrun; | |
useradd -c "WWW Admin User" -d /opt/SP/home/wwwadm -s /bin/bash -g www wwwadm; | |
usermod -a -G www wwwadm; | |
usermod -a -G wwwadm wwwadm; | |
mkdir /var/httpd; | |
mkdir /var/SP; | |
ln -s /var/httpd/var/SP/httpd; | |
chown -R wwwadm:www /var/SP; | |
chmod +s /var/SP; | |
chmod g+s /var/SP; | |
yum install wget gcc make -y; | |
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; | |
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; | |
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; | |
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; | |
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; | |
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~/opt/apache-2.4/htdocs~/var/SP/httpd/htdocs~g' /opt/SP/apache-2.4/conf/httpd.conf | |
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 | |
chown -R wwwadm:www /opt/apache-2.4; | |
yum install git -y; | |
cd ~; | |
git clone https://gist.github.com/whittlem/c264ad52eabca17e9f8d94ae2037f1fc; | |
mv -f c264ad52eabca17e9f8d94ae2037f1fc/rhel8-apache24-service /etc/init.d/apache; | |
chown root:root /etc/init.d/apache; | |
chmod 611 /etc/init.d/apache; | |
chkconfig apache on; | |
netstat -antup | grep :80; | |
curl http://localhost; | |
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 -rf /root/c264ad52eabca17e9f8d94ae2037f1fc; | |
rm -rf /root/apr-1.7.0; | |
rm -rf /root/apr-util-1.6.1; | |
rm -rf /root/expat-2.2.9; | |
rm -rf /root/httpd-2.4.46; | |
rm -rf /root/nghttp2-1.40.0; | |
service apache start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment