Fiz esse script da forma mais simples que consegui, para iniciantes como eu fazer a instalação em servidor local/VPS do i-educar 2.6.0, de forma fácil e sem erros.
No final do processo de instalação o script informa os dados de acesso ao banco de dados, por padrão o acesso remoto ao banco vai estar desabilitado.
Basta copiar o conteúdo abaixo e colar em um arquivo sh, exemplo: install_ieducar_ubuntu.sh
Conceder permissão de execução para o arquivo: chmod +x install_ieducar_ubuntu.sh
#!/bin/bash
# Informações de conexão para criação do banco de dados do i-Educar"
DB_HOST=127.0.0.1
DB_PORTA=5432
DB_BASE=ieducar
DB_USUARIO=ieducar
echo "INSTALANDO LIBS BASE"
sleep 2
sudo apt update -y
sudo apt upgrade -y
sudo apt install -y git wget curl zip unzip net-tools software-properties-common bash-completion
#atribui configuraçao
sed_configuracao() {
orig=$(echo $1 | tr -s ' ' '|' | cut -d '|' -f 1 | head -n 1)
origparm=$(echo $1 | tr -s ' ' '|' | cut -d '|' -f 3 | head -n 1)
if [[ -z $origparm ]];then
origparm=$(echo $1 | tr -s ' ' '|' | cut -d '|' -f 2 | head -n 1)
fi
dest=$(grep -E "^(#|\;|)$orig" $2 | tr -s ' ' '|' | cut -d '|' -f 1 | head -n 1)
destparm=$(grep -E "^(#|\;|)$orig" $2 | tr -s ' ' '|' | cut -d '|' -f 3 | head -n 1)
if [[ -z $destparm ]];then
destparm=$(grep -E "^(#|\;|)$orig" $2 | tr -s ' ' '|' | cut -d '|' -f 2 | head -n 1)
fi
case ${dest} in
\#${orig})
sed -i "/^$dest.*$destparm/c\\${1}" $2
;;
\;${orig})
sed -i "/^$dest.*$destparm/c\\${1}" $2
;;
${orig})
if [[ $origparm != $destparm ]]; then
sed -i "/^$orig/c\\${1}" $2
else
if [[ -z $(grep '[A-Z\_A-ZA-Z]$origparm' $2) ]]; then
fullorigparm3=$(echo $1 | tr -s ' ' '|' | cut -d '|' -f 3 | head -n 1)
fullorigparm4=$(echo $1 | tr -s ' ' '|' | cut -d '|' -f 4 | head -n 1)
fullorigparm5=$(echo $1 | tr -s ' ' '|' | cut -d '|' -f 5 | head -n 1)
fulldestparm3=$(grep -E "^(#|\;|)$orig" $2 | tr -s ' ' '|' | cut -d '|' -f 3 | head -n 1)
fulldestparm4=$(grep -E "^(#|\;|)$orig" $2 | tr -s ' ' '|' | cut -d '|' -f 4 | head -n 1)
fulldestparm5=$(grep -E "^(#|\;|)$orig" $2 | tr -s ' ' '|' | cut -d '|' -f 5 | head -n 1)
sed -i "/^$dest.*$fulldestparm3\ $fulldestparm4\ $fulldestparm5/c\\$orig\ \=\ $fullorigparm3\ $fullorigparm4\ $fullorigparm5" $2
fi
fi
;;
*)
echo ${1} >> $2
;;
esac
}
echo "INSTALANDO POSTGRESQL 13"
sleep 2
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt update -y
POSTGRES_VERSAO=13
sudo apt install -y postgresql-$POSTGRES_VERSAO postgresql-client-$POSTGRES_VERSAO
echo "CONFIGURANDO POSTGRESQL"
sleep 2
pg_dropcluster --stop $POSTGRES_VERSAO main
pg_createcluster -u postgres -g postgres $POSTGRES_VERSAO $DB_BASE
# Liberando autenticao
sed -i 's/md5$/trust/g' /etc/postgresql/$POSTGRES_VERSAO/$DB_BASE/pg_hba.conf
sed -i 's/peer$/trust/g' /etc/postgresql/$POSTGRES_VERSAO/$DB_BASE/pg_hba.conf
PGPATH=/etc/postgresql/$POSTGRES_VERSAO/$DB_BASE/postgresql.conf
sed_configuracao "listen_addresses = '*'" "$PGPATH"
/etc/init.d/postgresql start
sudo -u postgres psql postgres -c "ALTER USER postgres WITH PASSWORD 'postgres';"
echo "SENHA DO USUARIO postgres É postgres. DEVE SER ALTERADA MANUALMENTE APOS INSTALACAO."
DB_PASSWORD_IEDUCAR=$(openssl passwd -crypt $DB_USUARIO)
psql -U postgres -c "CREATE ROLE $DB_USUARIO WITH LOGIN PASSWORD '$DB_PASSWORD_IEDUCAR';"
psql -U postgres -c "CREATE DATABASE $DB_BASE OWNER $DB_USUARIO"
psql -U postgres -c "GRANT postgres TO $DB_USUARIO;"
psql -U postgres -c "ALTER USER $DB_USUARIO WITH SUPERUSER;"
VERSAO=2.6.0
download_ieducar() {
wget https://github.com/portabilis/i-educar/releases/download/$VERSAO/ieducar-$VERSAO.tar.gz -O /tmp/ieducar-$VERSAO.tar.gz
}
RELEASE=$(cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -c18-30)
case "$RELEASE" in
bionic)
echo "É UBUNTU 18.04"
sleep 2
;;
focal)
echo "É UBUNTU 20.04"
sleep 2
;;
*)
echo "RELEASE INVALIDA"
sleep 2
exit
;;
esac
echo "FAZENDO DOWNLOAD DO PACOTE DO i-Educar"
download_ieducar
# Configurando usuario ssh
echo "CONFIGURANDO USUARIO SSH"
sleep 2
IEDUCAR_SSH_PASSWORD=$(openssl passwd -crypt ieducar)
sudo useradd -d /home/ieducar -g www-data -G sudo,www-data -k /etc/skel -m -s /bin/bash -p $IEDUCAR_SSH_PASSWORD ieducar
echo "INSTALANDO PHP 7.4"
sleep 2
sudo add-apt-repository -y ppa:ondrej/php
sudo apt update -y
sudo apt install -y php7.4-fpm php7.4-common php7.4-zip php7.4-pgsql php7.4-curl php7.4-xml php7.4-xmlrpc php7.4-json php7.4-pdo php7.4-gd php7.4-imagick php7.4-ldap php7.4-imap php7.4-mbstring php7.4-intl php7.4-cli php7.4-tidy php7.4-bcmath php7.4-opcache
PHP_PATH=/etc/php/7.4/fpm/php.ini
sed_configuracao "upload_max_filesize = '2048M'" "$PHP_PATH"
sed_configuracao "post_max_size = '2048M'" "$PHP_PATH"
sed_configuracao "max_execution_time = '300'" "$PHP_PATH"
PHP_WWW_PATH=/etc/php/7.4/fpm/pool.d/www.conf
sed_configuracao "request_terminate_timeout = '300'" "$PHP_WWW_PATH"
echo "INSTALANDO NGNIX"
sleep 2
sudo apt install -y nginx
echo "CONFIGURANDO VIRTUAL HOST"
sleep 2
echo > /etc/nginx/conf.d/default.conf
cat << NGNIX_DEFAULT_IEDUCAR > /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name default_server;
root /var/www/ieducar/public;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location ~ ^/intranet/?$ {
rewrite ^.*$ /intranet/index.php redirect;
}
location ~ /module/(.*)/(styles|scripts|imagens)/(.*) {
rewrite ^/module/(.*)/(imagens|scripts|styles)/(.*)$ /intranet/$2/$3 break;
}
location ~ /module/(.*)/(.*) {
rewrite ^/module/(.*/)(.*intranet/.*)$ /$2 redirect;
rewrite ^/module/(.*/)(.*index\.php)$ /$2 redirect;
rewrite ^/module/(.*/)(.*logof\.php)$ /intranet/logof.php redirect;
rewrite ^/module/(.*/)(.*meusdados\.php)$ /intranet/meusdados.php redirect;
rewrite ^/module/(.*/)(.*_xml.*)(\.php)$ /intranet/$2.php redirect;
rewrite ^/module/(.*/)(.*erro_banco\.php)$ /intranet/erro_banco.php redirect;
rewrite ^/module/(.*/)(.*educar_pesquisa_cliente_lst\.php)$ /intranet/educar_pesquisa_cliente_lst.php redirect;
rewrite ^/module/(.*/)(.*educar_pesquisa_obra_lst\.php)$ /intranet/educar_pesquisa_obra_lst.php redirect;
rewrite ^/module/(.*)$ /module/index.php last;
}
location ~ ^(/intranet.*\.php|/modules.*\.php|/module/) {
rewrite ^(.*)$ /index.php$1;
}
location ~ \.php {
fastcgi_read_timeout 300;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param PATH_INFO \$fastcgi_path_info;
}
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
}
NGNIX_DEFAULT_IEDUCAR
echo > /etc/nginx/conf.d/upstream.conf
cat << NGNIX_UPSTREAM_IEDUCAR > /etc/nginx/conf.d/upstream.conf
upstream php-fpm {
server unix:/run/php/php7.4-fpm.sock;
}
NGNIX_UPSTREAM_IEDUCAR
sudo rm -v /etc/nginx/sites-enabled/default
sudo service nginx restart
echo "EXTRAINDO PACOTE DO i-Educar"
sleep 2
tar -zxf /tmp/ieducar-$VERSAO.tar.gz -C /var/www/
mv /var/www/ieducar-$VERSAO /var/www/ieducar
sudo service php7.4-fpm restart
sudo chown -R www-data:www-data /var/www/ieducar
echo "CONFIGURANDO O BANCO DE DADOS DO i-Educar"
sleep 2
sudo cat << ENV > /var/www/ieducar/.env
APP_NAME=i-Educar
APP_ENV=production
APP_KEY=base64:DjkHU/qQgA2pJUKjClLssG2NDiK37/Ff+U0G8SB38Eg=
APP_DEBUG=false
APP_URL=http://localhost
APP_TIMEZONE=America/Sao_Paulo
APP_TRACK_ERROR=false
APP_DEFAULT_HOST=ieducar.com.br
API_ACCESS_KEY=
API_SECRET_KEY=
LEGACY_CODE=true
LEGACY_DISPLAY_ERRORS=false
LEGACY_PATH=ieducar
LOG_CHANNEL=stack
TELESCOPE_ENABLED=false
DB_CONNECTION=pgsql
DB_HOST=`echo $DB_HOST`
DB_PORT=`echo $DB_PORTA`
DB_DATABASE=`echo $DB_BASE`
DB_USERNAME=`echo $DB_USUARIO`
DB_PASSWORD=`echo $DB_PASSWORD_IEDUCAR`
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
HONEYBADGER_API_KEY=
GOOGLE_TAG_MANAGER=
FILESYSTEM_DRIVER=local
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
MIX_SOCKET_SERVER=127.0.0.1
MIX_SOCKET_PORT=6001
ENV
echo "PRE-INSTALACAO TERMINADA."
echo " ACESSE: http://seu.endereco.de.ip/install.php E CONCLUA O PROCESSO DE INSTALACAO."
echo "INFORMACOES DE ACESSO AO BANCO DE DADOS"
echo " HOST: " `echo $DB_HOST`
echo " PORTA: " `echo $DB_PORTA`
echo " DB_BASE: " `echo $DB_BASE`
echo " DB_USUARIO: " `echo $DB_USUARIO`
echo " DB_PASSWORD_IEDUCAR: " `echo $DB_PASSWORD_IEDUCAR`
echo "GUARDE A SENHA SSH PARA USUARIO ieducar: " `echo $IEDUCAR_SSH_PASSWORD`