testing nginx :)
This commit is contained in:
parent
bbe5d49ef6
commit
5f86e1f2aa
|
@ -4,7 +4,13 @@ A little install script that installs FreePBX 17, but without all the commercial
|
|||
|
||||
## Usage
|
||||
```bash
|
||||
wget -O install.sh https://git.chrischro.me/ChrisChrome/freepbx-oss/raw/branch/main/install.sh && chmod +x install.sh && ./install.sh
|
||||
curl -sSL https://git.chrischro.me/ChrisChrome/freepbx-oss/raw/branch/main/install.sh | bash
|
||||
```
|
||||
|
||||
Or if you're feeling like beta-testing, you can use the following to install FreePBX with NGINX instead of Apache2
|
||||
|
||||
```bash
|
||||
curl -sSL https://git.chrischro.me/ChrisChrome/freepbx-oss/raw/branch/main/install-nginx.sh | bash
|
||||
```
|
||||
|
||||
## Arguments
|
||||
|
|
191
install-nginx.sh
Normal file
191
install-nginx.sh
Normal file
|
@ -0,0 +1,191 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check that we're running with effective UID 0, if not, ask for sudo
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exec sudo "$0" "$@"
|
||||
fi
|
||||
|
||||
# Check that we're running at least debian 12 or later
|
||||
if [ "$BYPASS_VERSION_CHECK" != "true" ]; then
|
||||
if [ "$(lsb_release -sc)" != "bookworm" ]; then
|
||||
# This script must be run on Debian 12 Bookworm, you are running $(lsb_release -sc)
|
||||
echo "This script must be run on Debian 12 Bookworm, you are running $(lsb_release -sc)" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Install Flags
|
||||
# --edge - Install FreePBX Edge version
|
||||
|
||||
# Check all flags are valid
|
||||
for i in "$@"; do
|
||||
case $i in
|
||||
--edge)
|
||||
EDGE=true
|
||||
shift
|
||||
;;
|
||||
-y)
|
||||
SKIP_PROMPT=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Invalid flag: $i" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# If not skip, ask for confirmation
|
||||
if [ "$SKIP_PROMPT" != true ]; then
|
||||
read -p "This script will install FreePBX Open-Source, Asterisk 20, and many other dependencies, do you want to continue? (y/n): " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
apt-get update;
|
||||
apt-get upgrade;
|
||||
|
||||
# Install dependencies
|
||||
apt -y install build-essential git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev libjansson-dev libxml2-dev uuid-dev default-libmysqlclient-dev htop sngrep lame ffmpeg mpg123 git vim curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev uuid-dev expect;
|
||||
|
||||
# Install LAMP stack
|
||||
# apt install -y linux-headers-`uname -r` # Doesn't seem to be needed?
|
||||
apt-get install -y build-essential openssh-server nginx mariadb-server mariadb-client bison flex php8.2 php8.2-curl php8.2-cli php8.2-common php8.2-mysql php8.2-gd php8.2-mbstring php8.2-intl php8.2-xml php8.2-zip unzip zip php8.2-fpm php-pear curl sox libncurses5-dev libssl-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev odbc-mariadb libical-dev libneon27-dev libsrtp2-dev libspandsp-dev sudo subversion libtool-bin python-dev-is-python3 unixodbc vim wget libjansson-dev software-properties-common nodejs npm ipset iptables fail2ban php-soap;
|
||||
|
||||
# Install Asterisk
|
||||
cd /usr/src;
|
||||
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz;
|
||||
# Check sha256 checksum from http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.sha256 automatically
|
||||
ASTCHKSUM=$(sha256sum asterisk-20-current.tar.gz | cut -d' ' -f1);
|
||||
OLASTCHKSUM=$(curl -s http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.sha256 | cut -d' ' -f1);
|
||||
if [ "$ASTCHKSUM" != "$OLASTCHKSUM" ]; then
|
||||
echo "Checksum mismatch, exiting...";
|
||||
exit 1;
|
||||
fi
|
||||
tar xvf asterisk-20-current.tar.gz;
|
||||
cd asterisk-20*/;
|
||||
contrib/scripts/get_mp3_source.sh;
|
||||
contrib/scripts/install_prereq install;
|
||||
./configure --libdir=/usr/lib64 --with-pjproject-bundled --with-jansson-bundled;
|
||||
make menuselect.makeopts;
|
||||
menuselect/menuselect --enable app_macro menuselect.makeopts;
|
||||
# make menuselect; # In theory i can just skip this?
|
||||
make;
|
||||
make install;
|
||||
make samples;
|
||||
make config;
|
||||
ldconfig;
|
||||
|
||||
groupadd asterisk;
|
||||
useradd -r -d /var/lib/asterisk -g asterisk asterisk;
|
||||
usermod -aG audio,dialout,www-data asterisk;
|
||||
usermod -aG asterisk www-data
|
||||
chown -R asterisk:asterisk /etc/asterisk;
|
||||
chown -R asterisk:asterisk /var/{lib,log,spool}/asterisk;
|
||||
chown -R asterisk:asterisk /usr/lib64/asterisk;
|
||||
sed -i 's|#AST_USER|AST_USER|' /etc/default/asterisk;
|
||||
sed -i 's|#AST_GROUP|AST_GROUP|' /etc/default/asterisk;
|
||||
sed -i 's|;runuser|runuser|' /etc/asterisk/asterisk.conf;
|
||||
sed -i 's|;rungroup|rungroup|' /etc/asterisk/asterisk.conf;
|
||||
echo "/usr/lib64" >> /etc/ld.so.conf.d/x86_64-linux-gnu.conf;
|
||||
ldconfig;
|
||||
|
||||
# Configure Nginx
|
||||
rm -rf /etc/nginx/sites-available/default # Kinda scary, will find better approach some time
|
||||
|
||||
cat <<EOF > /etc/nginx/conf.d/freepbx.conf
|
||||
server {
|
||||
listen 80 default_server;
|
||||
|
||||
root /var/www/html;
|
||||
|
||||
# Add index.php to the list if you are using PHP
|
||||
index index.html index.htm index.php;
|
||||
|
||||
location / {
|
||||
# First attempt to serve request as file, then
|
||||
# as directory, then fall back to displaying a 404.
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/8.2/fpm/php.ini;
|
||||
sed -i 's/\(^memory_limit = \).*/\1256M/' /etc/php/8.2/fpm/php.ini;
|
||||
systemctl restart nginx;
|
||||
systemctl restart php8.2-fpm
|
||||
rm /var/www/html/index.html;
|
||||
|
||||
# Configure ODBC
|
||||
cat <<EOF > /etc/odbcinst.ini
|
||||
[MySQL]
|
||||
Description = ODBC for MySQL (MariaDB)
|
||||
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so
|
||||
FileUsage = 1
|
||||
EOF
|
||||
|
||||
cat <<EOF > /etc/odbc.ini
|
||||
[MySQL-asteriskcdrdb]
|
||||
Description = MySQL connection to 'asteriskcdrdb' database
|
||||
Driver = MySQL
|
||||
Server = localhost
|
||||
Database = asteriskcdrdb
|
||||
Port = 3306
|
||||
Socket = /var/run/mysqld/mysqld.sock
|
||||
Option = 3
|
||||
EOF
|
||||
|
||||
# Install FreePBX
|
||||
cd /usr/local/src;
|
||||
#wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-17.0-latest.tgz;
|
||||
if [ "$EDGE" = true ]; then
|
||||
wget https://mirror.freepbx.org/modules/packages/freepbx/freepbx-17.0-latest-EDGE.tgz;
|
||||
mv freepbx-17.0-latest-EDGE.tgz freepbx-17.tgz;
|
||||
else
|
||||
wget https://mirror.freepbx.org/modules/packages/freepbx/freepbx-17.0-latest.tgz;
|
||||
mv freepbx-17.0-latest.tgz freepbx-17.tgz;
|
||||
fi
|
||||
tar zxvf freepbx-17.tgz;
|
||||
cd /usr/local/src/freepbx/;
|
||||
./start_asterisk start;
|
||||
./install -n;
|
||||
|
||||
# Install modules
|
||||
fwconsole ma installall;
|
||||
fwconsole reload;
|
||||
fwconsole restart;
|
||||
|
||||
# Setup FreePBX systemd
|
||||
cat <<EOF > /etc/systemd/system/freepbx.service
|
||||
[Unit]
|
||||
Description=FreePBX VoIP Server
|
||||
After=mariadb.service
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/sbin/fwconsole start -q
|
||||
ExecStop=/usr/sbin/fwconsole stop -q
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload;
|
||||
systemctl enable freepbx;
|
||||
|
||||
echo "FreePBX Open-Source has been installed successfully!";
|
||||
echo "You can access FreePBX at http://$(hostname -I | cut -d' ' -f1)/";
|
|
@ -53,7 +53,7 @@ apt-get upgrade;
|
|||
apt -y install build-essential git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev libjansson-dev libxml2-dev uuid-dev default-libmysqlclient-dev htop sngrep lame ffmpeg mpg123 git vim curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev uuid-dev expect;
|
||||
|
||||
# Install LAMP stack
|
||||
apt install -y linux-headers-`uname -r`
|
||||
# apt install -y linux-headers-`uname -r` # Doesn't seem to be needed?
|
||||
apt-get install -y build-essential openssh-server apache2 mariadb-server mariadb-client bison flex php8.2 php8.2-curl php8.2-cli php8.2-common php8.2-mysql php8.2-gd php8.2-mbstring php8.2-intl php8.2-xml php-pear curl sox libncurses5-dev libssl-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev odbc-mariadb libical-dev libneon27-dev libsrtp2-dev libspandsp-dev sudo subversion libtool-bin python-dev-is-python3 unixodbc vim wget libjansson-dev software-properties-common nodejs npm ipset iptables fail2ban php-soap;
|
||||
|
||||
# Install Asterisk
|
||||
|
|
Loading…
Reference in a new issue