Rails deployment using Phusion Passenger on Bluehost - ruby

I am trying to deploy a rails application on Bluehost using passenger and I have been failing all the time.
I installed the passenger gem using:
gem install passenger
And also ran:
passenger-install-apache2-module
And ran all my db migrations and also did a asset precompile
The problem is, I am trying to host it on a sub-domain, so I did the following steps:
Created a sub-domain.
Created a sym link from rails app pointing to the sub-domain.
Added the following lines to my .htaccess:
PassengerEnabled On
PassengerAppRoot /home/username/rails_apps/my_app
And when I navigate to my domain in the browser it gives me:
Internal Server Error.
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#sub.domain.com
Where am I going wrong?
Thanks in advance :)

Hey have you checked user & group in your httpd conf file?
make sure that if you have user/group www-data in httpd conf then your project directories should have same owner & group.

I also tried doing the same thing, but was unsuccessful, but when I dig a bit deep I figured out following:
The apache server in Bluehost uses passenger in different path. Hence our installation would not affect it.
Passenger3.x of Bluehost is using ruby 1.8 as default one, hence the ruby version cannot be changed.

Check Bluehost on what needs to be in the .htaccess file.
Mine looks like this:
<IfModule mod_passenger.c>
Options -MultiViews
PassengerResolveSymlinksInDocumentRoot on
#Set this to whatever environment you'll be running in
RailsEnv production
RackBaseURI /home/rails_apps/my_app
SetEnv GEM_HOME /home/<my_bluehost_username>/ruby/gems
</IfModule>
You should use this command to find your ruby gems location:
gem env

Related

Missing "passenger.conf" Apache2

I am trying to deploy Redmine on my Ubuntu Linux server running Apache2. However, for my deployment of Redmine, I need to modify passenger.conf which is missing at the path /etc/apache2/mods-available/passenger.conf. I am wondering if this configuration file should have been provided during installation and how I can create this missing file?
If you need to configure passenger, then install using this ref link from phusion passenger official site
https://www.phusionpassenger.com/library/config/apache/intro.html

New TYPO3 installation on localhost: Backend does not work

I have installed a new copy of TYPO3 on localhost. When all the installation is finished I click to login and its giving error:
This site can’t be reached The connection was reset.
Try:
Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_RESET
So the problem is that I'm unable to move to admin penal of TYPO3. I have installed many time new copy of TYPO3 but same error. I also have installed new xampp but same error. Can any one help me to solve this error?
Following steps will also sort this problem.
open httpd.conf file under xampp/apache/conf folder
add the following code if not there
<IfModule mpm_winnt_module>
ThreadStackSize 8388608
</IfModule>
save the file.
Now restart apache and then restart the XAMPP.
Maybe an SSL problem with xampp default configuration.
To fix the Open SSL problem with Xampp under windows, you can download another version of Open SSL that works with TYPO3. You will find below the link to download the coresponding version of you 32 or 64 bits windows :
http://slproweb.com/products/Win32OpenSSL.html
– Win32 OpenSSL v1.x Light
or
– Win64 OpenSSL v1.x Light.
After installation, just copy/replace the two files below with the downloaded version:
– C:\xampp\php\extras\openssl\openssl.exe
– C:\xampp\php\extras\openssl\openssl.cfg
Restart Apache, then login on TYPO3 backend is ok!

Setting Up Symfony Dev Environment in Heroku

So as the title suggests, I am setting up a Symfony project in heroku. It is on my Mac OSX laptop. I followed the directions here to set it up. I got everything installed, pushed my project to heroku, tested it and it works on the web.
Now I'm trying to set up the local dev environment. I would like to be able to simply use heroku local to launch the dev server as usual. I installed the heroku php buildpack, and I created a Procfile with these contents:
web: $(composer config bin-dir)/heroku-php-apache2 web/
the composer config bin-dir command returns vendor/bin, and then I can see that heroku-php-apache2 file in there. Everything looks good.
When I run heroku local I get this error:
[WARN] No ENV file found
15:48:49 web.1 | This program requires Apache 2.4.10 or newer with mod_proxy and mod_proxy_fcgi enabled; check your 'httpd' command.
15:48:49 web.1 Exited with exit code 1
So I checked the httpd -v and I have:
Server version: Apache/2.4.27 (Unix)
Server built: Oct 3 2017 10:26:24
I just enabled (uncommented) mod_proxy and mod_proxy_fcgi in the /etc/apache2/httpd.conf file and restarted the machine, but still seeing the same error. I am starting to think it is a problem with my Procfile or something.
Any help is greatly appreciated.
For anyone having a similar problem, I was able to fix the issue. The issue WAS that I edited the wrong httpd.conf file, since I installed the apache from homebrew.
The path /etc/apache2/httpd.conf is correct if you are using the default apache2 installation on the mac. If you installed apache from homebrew like I did, you will find the httpd.conf file at /usr/local/etc/httpd/httpd.conf.
You need to uncomment the 2 lines for mod_proxy and mod_proxy_fcgi and also uncomment the port listener directive, since heroku likes to listen on non-default port 5000 and heroku will automatically do that at run time.
Also the server cannot be running already when you use heroku local.
:-)

No such file or directory - getcwd

I uploaded my Sinatra app to Beanstalk. When I go to my site my logs are returned
No such file or directory - getcwd
The app was working before. I believe the issue has to do with the fact that I added SASS to my app, but I'm not positive. In my config.ru, I have the following code dealing with SASS...
# use scss for stylesheets
Sass::Plugin.options[:style] = :compressed
use Sass::Plugin::Rack
If it could be another issue, let me know and I can provide more information. Thanks.
Some people received this error after trying to run from an already deleted directory.
I received this error after switching databases and leaving the server running. The old server info was still showing up but I was getting this error. Restarted my rails server and everything works fine with the new db.
Basically it means that there is a significant state change on the server, and your environment needs to be reset/restarted.
The key for me was starting a new terminal session.
I just ran into this after trying vagrant up on a newly created directory (after deleting one by the same name) in the same terminal session (oddly, for the first time after working with Vagrant for years). In my case I had already run vagrant destroy, so nothing about the environment needed to or could be be restarted. I was blocked until I started a new terminal session, then vagrant up ran smoothly again.
Found out pg was installed instead of mysql2 in bundler.
Ran across this issue with an Amazon EC2 and rails 5. I had to delete my directory and git clone it. I used bundle install and rake db:migrate and afterwards I ran into the same error. All I had to do to fix it was run sudo service nginx restart to restart the server and when I went back to the website it was working again.

How do I update Ruby Gems from behind a Proxy (ISA-NTLM)

The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?
... or am I just being lazy?
Note: rubysspi-1.2.4 does not work.
This also works for "igem", part of the IronRuby project
For the Windows OS, I used Fiddler to work around the issue.
Install/Run Fiddler from www.fiddler2.com
Run gem:
$ gem install --http-proxy http://localhost:8888 $gem_name
I wasn't able to get mine working from the command-line switch but I have been able to do it just by setting my HTTP_PROXY environment variable. (Note that case seems to be important). I have a batch file that has a line like this in it:
SET HTTP_PROXY=http://%USER%:%PASSWORD%#%SERVER%:%PORT%
I set the four referenced variables before I get to this line obviously. As an example if my username is "wolfbyte", my password is "secret" and my proxy is called "pigsy" and operates on port 8080:
SET HTTP_PROXY=http://wolfbyte:secret#pigsy:8080
You might want to be careful how you manage that because it stores your password in plain text in the machine's session but I don't think it should be too much of an issue.
This totally worked:
gem install --http-proxy http://COMPANY.PROXY.ADDRESS $gem_name
I've been using cntlm (http://cntlm.sourceforge.net/) at work. Configuration is very similar to ntlmaps.
gem install --http-proxy http://localhost:3128 _name_of_gem_
Works great, and also allows me to connect my Ubuntu box to the ISA proxy.
Check out http://cntlm.wiki.sourceforge.net/ for more information
I tried some of these solutions, and none of them worked. I finally found a solution that works for me:
gem install -p http://proxy_ip:proxy_port rails
using the -p parameter to pass the proxy. I'm using Gem version 1.9.1.
Create a .gemrc file (either in /etc/gemrc or ~/.gemrc or for example with chef gem in /opt/chef/embedded/etc/gemrc) containing:
http_proxy: http://proxy:3128
Then you can gem install as usual.
This solved my problem perfectly:
gem install -p http://proxy_ip:proxy_port compass
You might need to add your user name and password to it:
gem install -p http://[username]:[password]#proxy_ip:proxy_port compass
If you are having problems getting authenticated through your proxy, be sure to set the environment variables in exactly the format below:
set HTTP_PROXY=some.proxy.com
set HTTP_PROXY_USER=user
set HTTP_PROXY_PASS=password
The user:password# syntax doesn't seem to work and there are also some badly named environment variables floating around on Stack Overflow and various forum posts.
Also be aware that it can take a while for your gems to start downloading. At first I thought it wasn't working but with a bit of patience they started downloading as expected.
Quick answer : Add proxy configuration with parameter for both install/update
gem install --http-proxy http://host:port/ package_name
gem update --http-proxy http://host:port/ package_name
I tried all the above solutions, however none of them worked. If you're on linux/macOS i highly suggest using tsocks over an ssh tunnel. What you need in order to get this setup working is a machine where you can log in via ssh, and in addition to that a programm called tsocks installed.
The idea here is to create a dynamic tunnel via SSH (a socks5 proxy). We then configure tsocks to use this tunnel and to start our applications, in this case:
tsocks gem install ...
or to account for rails 3.0:
tsocks bundle install
A more detailed guide can be found under:
http://blog.byscripts.info/2011/04/bypass-a-proxy-with-ssh-tunnel-and-tsocks-under-ubuntu/
Despite being written for Ubuntu the procedure should be applicable for all Unix based machines. An alternative to tsocks for Windows is FreeCap (http://www.freecap.ru/eng/). A viable SSH client on windows is called putty.
Posts abound regarding this topic, and to help others save hours of trying different solutions, here is the final result of my hours of tinkering.
The three solutions around the internet at the moment are:
rubysspi
apserver
cntlm
rubysspi only works from a Windows machine, AFAIK, as it relies on the Win32Api library. So if you are on a Windows box trying to run through a proxy, this is the solution for you. If you are on a Linux distro, you're out of luck.
apserver seems to be a dead project. The link listed in the posts I've seen lead to 404 page on sourceforge. I search for "apserver" on sourceforge returns nothing.
The sourceforge link for cntlm that I've seen redirects to http://cntlm.awk.cz/, but that times out. A search on sourceforge turns up this link, which does work: http://sourceforge.net/projects/cntlm/
After downloading and configuring cntlm I have managed to install a gem through the proxy, so this seems to be the best solution for Linux distros.
A workaround is to install http://web.archive.org/web/20060913093359/http://apserver.sourceforge.net:80/ on your local machine, configure it and run gems through this proxy.
Install: Just download apserver 097 (and not the experimental 098!) and unpack.
Configure: Edit the server.cfg file and put the values for your MS proxy in PARENT_PROXY and PARENT_PROXY_PORT. Enter the values for DOMAIN and USER. Leave PASSWORD blank (nothing after the colon) – you will be prompted when launching it.
Run apserver: cd aps097; python main.py
Run Gems: gem install—http-proxy http://localhost:5865/ library
I am working behind a proxy and just installed SASS by downloading directly from http://rubygems.org.
I then ran sudo gem install [path/to/downloaded/gem/file]. I cannot say this will work for all gems, but it may help some people.
This worked for me in a Windows box:
set HTTP_PROXY=http://server:port
set HTTP_PROXY_USER=username
set HTTP_PROXY_PASS=userparssword
set HTTPS_PROXY=http://server:port
set HTTPS_PROXY_USER=username
set HTTPS_PROXY_PASS=userpassword
I have a batch file with these lines that I use to set environment values when I need it.
The trick, in my case, was HTTPS_PROXY sets. Without them, I always got a 407 proxy authentication error.
If you are on a *nix system, use this:
export http_proxy=http://${proxy.host}:${port}
export https_proxy=http://${proxy.host}:${port}
and then try:
gem install ${gem_name}
rubysspi-1.3.1 worked for me on Windows 7, using the instructions from this page:
http://www.stuartellis.eu/articles/installing-ruby/
If you want to use SOCKS5 proxy, you may try rubygems-socksproxy https://github.com/gussan/rubygems-socksproxy.
It works for me on OSX 10.9.3.
If behind a proxy, you can navigate to Ruby downloads, click on Download, which will download the specified update ( or Gem ) to a desired location.
Next, via Ruby command line, navigate to the downloaded location by using : pushd [directory]
eg : pushd D:\Setups
then run the following command: gem install [update name] --local
eg: gem install rubygems-update --local.
Tested on Windows 7 with Ruby update version 2.4.1.
To check use following command : ruby -v
Rather than editing batch files (which you may have to do for other Ruby gems, e.g. Bundler), it's probably better to do this once, and do it properly.
On Windows, behind my corporate proxy, all I had to do was add the HTTP_PROXY environment variable to my system.
Start -> right click Computer -> Properties
Choose "Advanced System Settings"
Click Advanced -> Environment Variables
Create a new System variable named "HTTP_PROXY", and set the Value to your proxy server
Reboot or log out and back in again
Depending on your authentication requirements, the HTTP_PROXY value can be as simple as:
http://proxy-server-name
Or more complex as others have pointed out
http://username:password#proxy-server-name:port-number
for anyone tunnelling with SSH; you can create a version of the gem command that uses SOCKS proxy:
Install socksify with gem install socksify (you'll need to be able to do this step without proxy, at least)
Copy your existing gem exe
cp $(command which gem) /usr/local/bin/proxy_gem
Open it in your favourite editor and add this at the top (after the shebang)
require 'socksify'
if ENV['SOCKS_PROXY']
require 'socksify'
host, port = ENV['SOCKS_PROXY'].split(':')
TCPSocket.socks_server = host || 'localhost'
TCPSocket.socks_port = port.to_i || 1080
end
Set up your tunnel
ssh -D 8123 -f -C -q -N user#proxy
Run your gem command with proxy_gem
SOCKS_PROXY=localhost:8123 proxy_gem push mygem

Resources