How to deploy rails 3 app using parallels Plesk? - ruby-on-rails

How to deploy my Rails 3 app on shared hosting ?
When I buy hosting, they clearly mention Ruby on Rails support.
My hosting is Linux. The hosting service provider's technical member also don't know how to use Rails app. He is just saying that you can use Rails apps with FastCGI.
The hosting provider also does not allow to SSH access!
Thank you in advance.

There appears to be some threads out there on this:
forum.parallels.com/
kb.parallels.com/en/5489
Resolution
As of version 8.1, Plesk Control Panel supports Ruby on Rails. There is not an option in the Plesk Control Panel that should be checked to enable Ruby on Rails support; you only need to install the ruby packages.
To install an application written in Ruby, take the following steps:
Go to Domains > your-domain.com > Setup.
Select the CGI and FastCGI check-boxes and click OK.
Connect to your FTP account, change to the /htdocs directory, and create a subdirectory where the application files will reside. Let's call this directory your_application, for illustration purposes.
Upload the application files to the htdocs/your_application directory.
Create a file with the name .htaccess in this directory, open it with a text editor of your choice, and add the following lines into the file:
RewriteEngine On
RewriteRule ^$ /public/index.html [L]
RewriteCond %{REQUEST_URI} !^/your_application/public
RewriteRule ^(.*)$ /public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/dispatch.fcgi/$1 [QSA,L]
Save the file.
Remove the your_application/public/.htaccess file.
Open the your_application/public/dispatch.fcgi file with a text editor and put the following lines there: #!/usr/bin/ruby
Save the file.
The web application will now be accessible at the following URL: http://your-domain.com/your_application

Related

how to setup cakephp that runs from url path

So I'm building microservice architecture and I have separate cakePHP installations for Administration and Partners. So https://example.com is going to be served for normal users and that works fine as it's a standard installation.
But I can't figure out how to set up other two that they work as https://example.com/admin and https://example.com/partners. I use nginx to direct traffic to the correct docker container running admin and partners cakephp. Problem is how to let CakePHP know that his root website path is /admin and not just \? Because all the routing gets messed up.
I'm using CakePHP 4.x and PHP 7.2.x
I think you can simply change the App.baseUrl in the cakephp configuration. For more info check the official documentation
I think it's not a good option to create multiple projects for different AUTH (Partner/Administration). Cakephp allow multiple authentication for different roles.
Example: for a school project I had created Admin/School/Teacher/Students using different AUTH and AUTH storage , which never conflict with each other.
In your case there is a solution .
Assuming that you want to use https://example.com/ and Partner and https://example.com/admin as administrator.
1.First host your Partner project in ROOT.
Create a folder , named "admin" in Partner root projects folder.
Copy/Move your admin project code to your "admin" folder.
Change/update your ".htaccess" files in Partner root folder(FOR APACHE).
APACHE CODE
# Uncomment the following to prevent the httpoxy vulnerability
# See: https://httpoxy.org/
#<IfModule mod_headers.c>
# RequestHeader unset Proxy
#</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule admin admin/ [L]
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
After "RewriteEngine on " a new line added to bypass the PARTNER cakephp.
NGINX
# nginx configuration by winginx.com
location / {
rewrite admin /admin/ break;
rewrite ^/(\.well-known/.*)$ /$1 break;
rewrite ^/$ /webroot/ break;
rewrite ^(.*)$ /webroot/$1 break;
}

Rails - .htaccess not forcing users to use https

I want user to only be able to access the https version of the site. I figured out that a way to do this is with a .htaccess file. I've have added the SSL cert and thats all working fine.
I made the .htaccess file and added the following code in it (replacing 'example' with the domain name)
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
I deployed it and visited http://example.com/ and it loaded just fine as http.
I dont know if because its a rails app that I might need to put the .htaccess file in the public folder, or if there is more I need to do. But from what I read this should work.
I'm using google cloud platform to host my site, and I cant find the VM server type so maybe its not the right server type to run .htaccess files on?
I'm hoping someone here knows how to get this working.
With .htaccess try the following:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
However, with Rails you can use the following in your environment config:
config.force_ssl = true

Ruby On Rails on eHost

Is it possible to just upload my RoR files to my server (eHost) and have my website up and running?
If not, what should I do in order to have it working on any Host with support for RoR? I know of heroku but it is quite expansive for me right now. eHost charges only $3.27 per month and they claim to have support for RoR. I even called Tech Support and asked them to update the vertion to 2.3.0(Ruby) and 4.2.4(Rails).
I am new on RoR and have no idea of how to host my application on the ordinary hosts out there. So any help will be very welcome.
I've not tried this, I only hope this gives you an idea,
They say they support Ruby and RoR, So taking a look https://support.ehost.com/articles/ruby-on-rails-and-gems they say it's on Apache CGI server.
So - this is my suggestion - you upload your project, and either you contact support or you might want to try the suggestion here:
http://blog.hulihanapplications.com/browse/view/52-how-to-install-a-ruby-on-rails-app-part-2 I'll quote the section (in case it ever becomes unavailable). It's under the section FastCGI/CGI:
Configure .htaccess
Apache usually looks in any web directory for an Override file(which lets you set your own Apache configuration settings for the directory) called .htaccess. For ruby on rails, we need a special .htaccess file that tells the server to set up the directory as a ruby on rails application. This file should be created in the public directory if it's not already there. Here's what the contents of the file should look like:
#AddHandler fastcgi-script .fcgi
#AddHandler fcgid-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]<br>RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
Linking to public
The public directory inside your rails application contains all your public resources(images, css, javascript, etc.), and well as the .htaccess file needed to run your application. Until now, your public directory hasn't been visible to the outside world. Now we'll link your application to a directory inside your web root.
For example, if I was planning on running my rails application in a subdirectory of my website called www.mywebsite.com/myrailsapp, you'll need to create a symbolic link(it's kind of like a shortcut) in your web root directory(remember, this is where your regular website stuff goes, usually named public_html or www). Let's also pretend that on the server, the path to your web root is /home/myaccount/public_html and the path to your rails application is /home/myaccount/myrailsapp. Therefore, the command to create a symbolic link will be:
ln -s /home/myaccount/myrailsapp/public /home/myaccount/public_html/myrailsapp

ZF2 installation on shared hosting server

I am trying to install ZF2 on my shared hosting server. I followed these steps:
Downloaded and extracted Zend Framework 2 on my computer.
Created a directory on my "public_html" with the name of "zendPrj".
Uploaded the "Zend" directory using Filezilla into the "zendPrj" folder.
Created a "php.ini" with the following commands:
include_path = ".:/usr/lib/php:/usr/local/lib/php:/home/public_html/mycpanalusername/zndPrj/Zend/library"
allow_url_fopen = On
allow_url_include = On
and uploaded it into the "Zend" folder (which has got the "library", "bin", "resources" folders in it).
Created a ".htaccess" file with the following instruction:
SetEnv PHPRC /home/mycpanalusername/public_html/zendPrj/Zend/php.ini
Created a testing file as follows:
require_once 'Zend/Mail.php';
$mail=new Zend_Mail();
print_r($mail);
echo 'it is working';
But I don't get any results. Instead, a blank page is shown. Where am I going wrong?
OK, this is how I had setup ZF2 application in my shared hosting
folder structure for my application which should be copied to the sub domain folder (which is same as zf2 application structure)
Step 1: copy zf2 library (i.e ZEND folder inside zendframework download) to the root folder of your host i.e. after copy it looks like this(in my case) /home/username/zf2lib/ZEND (any location not accessible by public)
Step 2: edit .htaccess
#SetEnv ZF2_PATH /home/username/zf2lib
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
Step 3: edit init_autoloader.php to point to zf2 library, in this we have two option 1. if your host support SetEnv tag in .htaccess then simply uncomment the first line in the above .htaccess (mostly shared host don't provide these option, especially in my case) if the option 1 is not possible then you have to edit the init_autoloader.php file as below
Comment out from line 24 to 32, this code is responsible for various option to init the zend library, in our case we know where zf2 lib are loaded, so we are going to hard code the path, add line 33 and change username to your host user name.
Final step: copy all this content to your sub domain folder and access the site with subdomain.domain.com it all works well for me, hope it work for you too, good luck!
If you're trying to just access one of the classes (i.e. Mail) then you should note that in ZF2 the library structure changed to follow PSR-0. So Zend/Mail.php doesn't exist and the class name is not Zend_Mail. To access the mail class you need to include Zend/Mail/Mail.php and the class name is just Mail.
If you're trying to use the full MVC stack, then you should do what Raj suggested.
Also, if you want to see what the error is, you might want to include this at the top of your file:
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);

how to install symfony1.4 on a shared host

i am developing a site in symfony1.4 and doctorine. i am developing it on my local host by installing pear and using command line. And on my local host i am using wamp server. now i would like to upload it on a shared host. how to install it on a shared host.i am not much aware of symfony .Any one please help me
thanks in advance
I follows this steps:
add the symfony framework inside the folder myproject/lib/vendor. In ProjectConfiguration class change the require_once instruction in require_once dirname(__FILE__).'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';. So the framework folder will be called simply symfony without version.
upload the project, with the project folder, inside the root that is the domain folder;
use the url rewriting, adding inside the .htaccess file, the below code to use urls like mydomain.com/the-remainder-of-the-address instead of mydomain.com/myproject/web/the-remainder-of-the-address:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} www\.mydomain\.com [NC]
RewriteRule ^(.*)$ myproject/web/$1 [NC,L]
</IfModule>
Also to let generate by routing rule through the function link_to (or url_for) urls like mydomain.com/friendly-name.html instead of mydomain.com/myproject/web/friendly-name.html it needs to add in myappConfiguration class this code:
public function configure()
{
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'] = '/myapp.php';
}
Finally I suggest you to have a look at this useful deployment check list: symfony-check.org to solve typical problems in deployment.
Put symfony library in your project lib
Change project configuration class for include autoload class of framework.

Resources