Script Bash para instalar o site

1

Primeiro de tudo, desculpe-me se este é o lugar errado para fazer esta pergunta.

Eu fiz um script Bash que instala um backup do DirectAdmin no Apache. As etapas estão funcionando, mas no final, recebo um erro 500 ao abrir o site real.

Passos:
1. Descompacte o arquivo backup.tar.gz
2. remover arquivos desnecessários
3. Solicite detalhes do banco de dados no nome do site
4. Cat para arquivos admin.conf
5. Criar banco de dados e usuário
6. Crie e gere para /etc/apache2/sites-available/website.conf
7. a2ensite e service apache2 reload
8. Criar uma entrada no arquivo de hosts do Windows

Eu rastreei todos os passos para trás e tudo parece funcionar, mas quando eu entro na URL eu recebo um erro 500. Fiz tudo isso sem um script e tudo funciona.

Alguém pode me dizer de onde o erro pode vir? Há algo diferente ao fazer todas essas etapas com um script bash?

EDITAR: Aqui está o script inteiro usado:

#!/bin/bash
clear
tar -zxvf backup.tar.gz
sudo cp -R ./domains/*/public_html/* ./
sudo cp ./backup/*.sql ./
rm -rf ./backup ./domains
rm backup.tar.gz
sudo chmod 775 ./config.php
echo "ROOT_PWD?"
read -s root_pwd
echo "WEBSITENAME?"
read website
echo "DB_USERNAME?"
read usrname
echo "DB_PASSWORD?"
read db_pwd
echo "DB_DATABASE?"
read db
cat > ./config.php <<EOL
<?php
// HTTP
define('HTTP_SERVER', 'http://www.$website.nl/admin/');
define('HTTP_CATALOG', 'http://www.$website.nl/');

// HTTPS 
define('HTTPS_SERVER', 'http://www.$website.nl/admin/');
define('HTTPS_CATALOG', 'http://www.$website.nl/');

// DIR 
define('DIR_APPLICATION', $_SERVER['DOCUMENT_ROOT'].'/admin/'); 
define('DIR_SYSTEM', $_SERVER['DOCUMENT_ROOT'].'/system/'); 
define('DIR_IMAGE', $_SERVER['DOCUMENT_ROOT'].'/image/'); 
define('DIR_LANGUAGE', $_SERVER['DOCUMENT_ROOT'].'/admin/language/'); 
define('DIR_TEMPLATE', $_SERVER['DOCUMENT_ROOT'].'/admin/view/template/'); 
define('DIR_CONFIG', $_SERVER['DOCUMENT_ROOT'].'/system/config/'); 
define('DIR_CACHE', $_SERVER['DOCUMENT_ROOT'].'/system/storage/cache/'); 
define('DIR_DOWNLOAD', $_SERVER['DOCUMENT_ROOT'].'/system/storage/download/'); 
define('DIR_LOGS', $_SERVER['DOCUMENT_ROOT'].'/system/storage/logs/'); 
define('DIR_MODIFICATION', $_SERVER['DOCUMENT_ROOT'].'/system/storage/modification/'); 
define('DIR_UPLOAD', $_SERVER['DOCUMENT_ROOT'].'/system/storage/upload/');
define('DIR_CATALOG', $_SERVER['DOCUMENT_ROOT'].'/catalog/');

// DB 
define('DB_DRIVER', 'mysqli'); 
define('DB_HOSTNAME', 'localhost'); 
define('DB_USERNAME', '$usrname'); 
define('DB_PASSWORD', '$db_pwd'); 
define('DB_DATABASE', '$db'); 
define('DB_PORT', '3306');
define('DB_PREFIX', 'oc_');
EOL
chmod 444 ./config.php
chmod 755 ./admin/config.php
cat > ./admin/config.php <<EOL
<?php
// HTTP
define('HTTP_SERVER', 'http://www.$website.nl/admin/');
define('HTTP_CATALOG', 'http://www.$website.nl/');

// HTTPS
define('HTTPS_SERVER', 'http://www.$website.nl/admin/');
define('HTTPS_CATALOG', 'http://www.$website.nl/');

// DIR
define('DIR_APPLICATION', $_SERVER['DOCUMENT_ROOT'].'/admin/');
define('DIR_SYSTEM', $_SERVER['DOCUMENT_ROOT'].'/system/');
define('DIR_IMAGE', $_SERVER['DOCUMENT_ROOT'].'/image/');
define('DIR_LANGUAGE', $_SERVER['DOCUMENT_ROOT'].'/admin/language/');
define('DIR_TEMPLATE', $_SERVER['DOCUMENT_ROOT'].'/admin/view/template/');
define('DIR_CONFIG', $_SERVER['DOCUMENT_ROOT'].'/system/config/');
define('DIR_CACHE', $_SERVER['DOCUMENT_ROOT'].'/system/storage/cache/');
define('DIR_DOWNLOAD', $_SERVER['DOCUMENT_ROOT'].'/system/storage/download/');
define('DIR_LOGS', $_SERVER['DOCUMENT_ROOT'].'/system/storage/logs/');
define('DIR_MODIFICATION', $_SERVER['DOCUMENT_ROOT'].'/system/storage/modification/');
define('DIR_UPLOAD', $_SERVER['DOCUMENT_ROOT'].'/system/storage/upload/');
define('DIR_CATALOG', $_SERVER['DOCUMENT_ROOT'].'/catalog/');

// DB
define('DB_DRIVER', 'mysqli');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', '$usrname'); 
define('DB_PASSWORD', '$db_pwd'); 
define('DB_DATABASE', '$db');
define('DB_PORT', '3306');
define('DB_PREFIX', 'oc_');
EOL
chmod 444 ./admin/config.php

mysql -u root -p$root_pwd -e "CREATE DATABASE $db"
mysql -u root -p$root_pwd -e "CREATE USER '$usrname'@'localhost' IDENTIFIED BY '$db_pwd';"
mysql -u root -p$root_pwd -e "GRANT ALL PRIVILEGES ON $db . * TO '$usrname'@'localhost';"
mysql -u $usrname -p$db_pwd $db < *.sql

touch /etc/apache2/sites-available/$website'.conf'
cat > /etc/apache2/sites-available/$website'.conf' <<EOL
<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName $website.nl
    ServerAlias www.$website.nl
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/$website/

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
EOL
a2ensite $website'.conf'
service apache2 reload

Quando fiz um backup do DirectAdmin no site www.example.com e usei este site no meu script, tudo foi como deveria, mas ao digitar o URL em um navegador, recebo o erro 500.

Os logs do Apache estão vazios.

    
por Rob Michiels 19.03.2017 / 20:06

1 resposta

-1

Ah, você precisa usar ip_conntrack , faça o seguinte:

  1. modprobe ip_conntrack
  2. obter lista de variáveis de sysctl com sysctl -a |grep -i conn :
    a saída é ":

    net.netfilter.nf_conntrack_acct = 0
    net.netfilter.nf_conntrack_buckets = 65536
    net.netfilter.nf_conntrack_checksum = 1
    net.netfilter.nf_conntrack_count = 116
    net.netfilter.nf_conntrack_events = 1
    net.netfilter.nf_conntrack_expect_max = 1024
    net.netfilter.nf_conntrack_generic_timeout = 600
    net.netfilter.nf_conntrack_helper = 0
    net.netfilter.nf_conntrack_icmp_timeout = 30
    net.netfilter.nf_conntrack_log_invalid = 0
    net.netfilter.nf_conntrack_max = 262144
    net.netfilter.nf_conntrack_tcp_be_liberal = 0
    net.netfilter.nf_conntrack_tcp_loose = 1
    net.netfilter.nf_conntrack_tcp_max_retrans = 3
    net.netfilter.nf_conntrack_tcp_timeout_close = 10
    net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
    net.netfilter.nf_conntrack_tcp_timeout_established = 432000
    net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
    net.netfilter.nf_conntrack_tcp_timeout_last_ack = 30
    net.netfilter.nf_conntrack_tcp_timeout_max_retrans = 300
    net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 60
    net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 120
    net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
    net.netfilter.nf_conntrack_tcp_timeout_unacknowledged = 300
    net.netfilter.nf_conntrack_timestamp = 0
    net.netfilter.nf_conntrack_udp_timeout = 30
    net.netfilter.nf_conntrack_udp_timeout_stream = 180
    net.nf_conntrack_max = 262144
    
  3. altere net.ipv4.netfilter.ip_conntrack_max varibale.

  4. armazenar em arquivo.
por 19.03.2017 / 20:20