Configurando aplicação Ruby on Rails para rodar localhost no Ubuntu

Ao invés de toda vez você rodar “rails server” para subir uma aplicação Ruby on Rails, você pode deixar ela rodando por padrão no seu servidor Apache em um endereço por exemplo: http://nome_da_sua_aplicacao

Para isso no terminal:

sudo apt-get install apache2
sudo apt-get install libapache2-mod-passenger

Agora no arquivo /etc/hosts adicione um nome local para a sua aplicação para responder no navegador:

127.0.0.1       localhost nome_da_sua_aplicacao
127.0.1.1       tron
 
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

No meu caso adicionei nome_da_sua_aplicacao para responder localmente.

Agora será necessário adicionar a configuração do site no Apache, para isso:

sudo touch /etc/apache2/sites-available/nome_da_sua_aplicacao

Depois edite o arquivo acima e adicione o seguinte conteúdo:

        ServerAdmin webmaster@localhost
        ServerName nome_da_sua_aplicacao
 
        DocumentRoot /var/www/nome_da_sua_aplicacao/public
 
                Options FollowSymLinks
                AllowOverride None
 
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
 
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
 
        ErrorLog ${APACHE_LOG_DIR}/error.log
 
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
 
        CustomLog ${APACHE_LOG_DIR}/access.log combined
 
    Alias /doc/ "/usr/share/doc/"
 
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128

Onde /var/www/nome_da_sua_aplicacao/public é o caminho da sua aplicação Ruby on Rails, mais exatamente o caminho até o diretório public dela.

E ServerName nome_da_sua_aplicacao é o nome que você deseja acessar via navegador o mesmo nome que configuramos no /etc/hosts.

Agora vamos criar um link simbólico para o site funcionar no Apache:

cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/nome_da_sua_aplicacao 001-nome_da_sua_aplicacao

Agora é a hora de reiniciar o servidor web Apache para pegar as novas configurações, para isso:

sudo /etc/init.d/apache2 restart

Agora se você abrir a URL http://nome_da_sua_aplicacao no seu navegador já deve ver o seu site rodando.

Posted in Ruby on Rails at junho 12th, 2012. No Comments.

How to resolve “Could not find a JavaScript runtime” with Ruby on Rails App

If you tried to start Rails server and got this error:

/usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

In Ubuntu, you can fix it installing node.js:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install nodejs-dev

If you have other OS please look here: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

After you should starting Rails server with successful.

Please recommend me if this post help you: Recommend Me

Posted in Ruby on Rails, Ubuntu at março 1st, 2012. No Comments.

Configurar sendmail no Ubuntu

Para configurar o sendmail no Ubuntu basta seguir os passos abaixo.

Abra o terminal e digite os comandos:

sudo apt-get install sendmail-bin
sudo apt-get install sendmail

Para configurar o sendmail, digitar no terminal:

sudo sendmailconfig

Responda “y” para todas as perguntas.

Posted in Ubuntu at abril 6th, 2011. No Comments.

 Assinar RSS Feed