138 lines
3.6 KiB
Bash
138 lines
3.6 KiB
Bash
# Install using: sudo su -c "bash <(wget -qO- /url/to/install-apache.sh)"
|
|
|
|
# Make sure script is ran as root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
exec sudo /bin/bash "$0" "$@"
|
|
fi
|
|
REALUSER=$(logname)
|
|
mkdir /home/$REALUSER/www 2>>install.log &
|
|
|
|
#apt install docker.io
|
|
|
|
# apt update 2>>install.log &&
|
|
apt install apache2 -y 2>>install.log &&
|
|
apt install samba -y 2>>install.log &&
|
|
|
|
# Setting up Samba shares
|
|
if ! grep -q "/home/$REALUSER/www" "/etc/samba/smb.conf"; then
|
|
cat <<EOT >> "/etc/samba/smb.conf"
|
|
[$REALUSER-www]
|
|
comment = Samba File Server Share
|
|
path = /home/$REALUSER/www
|
|
browsable = yes
|
|
guest ok = yes
|
|
read only = no
|
|
create mask = 777
|
|
force create mode = 777
|
|
directory mask = 777
|
|
force directory mode = 777
|
|
[/$REALUSER-www]
|
|
EOT
|
|
fi
|
|
if ! grep -q "/var/www" "/etc/samba/smb.conf"; then
|
|
cat <<EOT >> "/etc/samba/smb.conf"
|
|
[www]
|
|
comment = Samba File Server Share
|
|
path = /var/www
|
|
browsable = yes
|
|
guest ok = yes
|
|
read only = no
|
|
create mask = 777
|
|
force create mode = 777
|
|
directory mask = 777
|
|
force directory mode = 777
|
|
valid users = $REALUSER, root
|
|
force user = root
|
|
force group = root
|
|
writeable = yes
|
|
admin users = root
|
|
[/www]
|
|
EOT
|
|
fi
|
|
if ! grep -q "/etc/apache2" "/etc/samba/smb.conf"; then
|
|
cat <<EOT >> "/etc/samba/smb.conf"
|
|
[apache2]
|
|
comment = Samba File Server Share
|
|
path = /etc/apache2
|
|
browsable = yes
|
|
guest ok = yes
|
|
read only = no
|
|
create mask = 777
|
|
force create mode = 777
|
|
directory mask = 777
|
|
force directory mode = 777
|
|
valid users = $REALUSER, root
|
|
force user = root
|
|
force group = root
|
|
writeable = yes
|
|
admin users = root
|
|
[/apache2]
|
|
EOT
|
|
fi
|
|
sed -i -e 's/obey pam restrictions = yes/obey pam restrictions = no/g' /etc/samba/smb.conf
|
|
service smbd restart 2>>install.log &&
|
|
ufw allow samba 2>>install.log
|
|
|
|
if ! pdbedit "$REALUSER" &>/dev/null; then
|
|
sudo smbpasswd -a $REALUSER 2>>install.log
|
|
fi
|
|
|
|
mkdir -p /var/www/cms/www 2>>install.log &&
|
|
mkdir -p /var/www/cms/log 2>>install.log &&
|
|
chmod -R uga+rwx /home/$REALUSER/www/ 2>>install.log &&
|
|
chmod -R uga+rwx /var/www/ 2>>install.log &&
|
|
# chmod -R 775 /var/www/
|
|
# chown -R $REALUSER:$REALUSER /var/www/
|
|
# chown -R $REALUSER:$REALUSER /etc/apache2/
|
|
|
|
service apache2 restart 2>>install.log &&
|
|
|
|
apt install libcgi-session-perl -y 2>>install.log &&
|
|
apt install libapache2-mod-perl2 -y 2>>install.log &&
|
|
apt install libarchive-zip-perl -y 2>>install.log &&
|
|
apt install libdbd-sqlite2-perl -y 2>>install.log &&
|
|
apt install libdbd-sqlite3-perl -y 2>>install.log &&
|
|
apt install libdbd-mysql-perl -y 2>>install.log &&
|
|
apt install libio-string-perl -y 2>>install.log &&
|
|
apt install libjson-perl -y 2>>install.log &&
|
|
apt install libmime-lite-perl -y 2>>install.log &&
|
|
apt install libexcel-writer-xlsx-perl -y 2>>install.log &&
|
|
apt install libgd-perl -y 2>>install.log &&
|
|
apt install librest-client-perl -y 2>>install.log &&
|
|
apt install libxml-simple-perl -y 2>>install.log &&
|
|
|
|
a2enmod rewrite 2>>install.log &&
|
|
a2enmod headers 2>>install.log &&
|
|
a2enmod expires 2>>install.log &&
|
|
a2enmod cgi.load 2>>install.log &&
|
|
a2enmod ssl 2>>install.log &&
|
|
a2enmod proxy 2>>install.log &&
|
|
a2enmod proxy_http 2>>install.log &&
|
|
|
|
|
|
if [ ! -f "/etc/apache2/sites-enabled/cms.conf" ]; then
|
|
cat <<EOT > "/etc/apache2/sites-enabled/cms.conf"
|
|
# Listen 8090
|
|
<VirtualHost *:80>
|
|
ServerAdmin webmaster@localhost
|
|
DocumentRoot /var/www/cms/www
|
|
ErrorLog /var/www/cms/log/error.log
|
|
CustomLog /var/www/cms/log/access.log combined
|
|
|
|
<Directory /var/www/cms/www>
|
|
Options Indexes FollowSymLinks MultiViews
|
|
DirectoryIndex index.html index.pl
|
|
AllowOverride All
|
|
Require all granted
|
|
</Directory>
|
|
<Files ~ "\.(pl|cgi)$">
|
|
AddHandler cgi-script .pl
|
|
Options +ExecCGI
|
|
</Files>
|
|
</VirtualHost>
|
|
EOT
|
|
fi
|
|
|
|
systemctl restart apache2 2>>install.log &&
|
|
|
|
echo 'Installation complete' |