How to install a wordpress inside a rails on heroku - ruby-on-rails

I unzip and rename wp-config-sample.php => wp-config.php and conffig it.
it is exactly my file (i have no edit)
// Heroku Postgres settings
if (isset($_ENV["DATABASE_URL"])) {
$db = parse_url($_ENV["DATABASE_URL"]);
define("DB_NAME", trim($db["path"],"/"));
define("DB_USER", $db["user"]);
define("DB_PASSWORD", $db["pass"]);
define("DB_HOST", $db["host"]);
} else {
die("Cannot determine database settings from DATABASE_URL\n");
}
Then I create .htaccess (app/.htaccess) and config(i have no edit):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
Then I upload it to blog folder on heroku. And try install but it always return eror 404 (I see logs heroku) my link to install:
http://mywebsite.heroku.com/blog/wp-admin/install.php
ActionController::RoutingError (No route matches "/blog/wp-admin/install.php
Please help me install this.
Thanks so much

You can't do this - but not due to Heroku not having PHP - because it does. The Cedar stack added support for PHP Facebook applications but you are able to run Wordpress on them. See http://tjstein.com/2011/09/running-wordpress-on-heroku-and-amazon-rds/
HOWEVER You cannot mix languages in the same Heroku application, eg Rails and PHP - they would need to exist as separate Heroku applications. When the application slug is compiled the language is detected at that point.

Related

Wordpress inside Rails subfolder: how to set blog root path?

Inspired by that great article from Paul Arterburn and forced by my client SEO needs, I have setup a Wordpress blog hosted by WPEngine to work inside a subdirectory of a Ruby-on-Rails app hosted by Heroku.
Description of the problem
The problem is that relative URLs doesn't match the blog URL. For example when I create a link like Should be https://www.example.com/blog/, the webpage display the link as https://www.example.com. Not cool.
Strange enough, the rest of the links seems to be fine.
A category: https://www.example.com/blog/categories/some-category
An article: https://www.example.com/blog/some-category/my-great-post
Something else could help to solve that problem. We are using the extension AMPforWP. When we add /amp to the post URL, eg https://www.example.com/blog/some-category/my-great-post/amp it become https://example.wpengine.com/blog/some-category/my-great-post/amp.
Eventually, if I desactivate AMPforWP extension, the URLs (but blog home page) can't be reach, the server return an 500 error. Even if I activate the AMPforWP again.
Here's what I have done so far
Ruby-on-Rails
/config/routes.rb
get '/blog' => redirect("https://www.example.com/blog/")
/config.ru
# https://github.com/waterlink/rack-reverse-proxy
use Rack::ReverseProxy do
reverse_proxy /^\/blog(\/.*)$/, 'http://example.wpengine.com$1', :username => 'example', :password => 'fakepwd', :timeout => 500, :preserve_host => true
end
WPEngine admin
https://my.wpengine.com/installs/example/domains
Wordpress admin
https://www.example.com/blog/wp-admin/options-general.php
.htaccess configuration
.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN wtfdivi
# END wtfdivi
I'm stuck... :-(
Any help could be greatly appreciated. Thank you.
I know this question has been a while. I had the same setup, I have a rails application pointing to a WordPress blog as a "folder url" instead of a subdomain. Here is how I've solved it.
First, on reverse proxy I had to disable preserve_host so it would keep the domain on the request and not mess with my rules.
config.middleware.insert(0, Rack::ReverseProxy) do
reverse_proxy_options preserve_host: false
reverse_proxy %r{^\/blog(\/.*)$}, "#{Rails.application.config.blog_url}$1"
end
Then on my Wordpress I've moved the installation to a subfolder (named blog), instead of the root folder and used most of the default configuration of .htaccess as follows:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Hope it still can help.

Removing .html and .php from links in IIS

As the title says, I would like to know how to remove ".html" and ".php" from links in a Windows server (IIS).
Most of the information I have found about this subject was only valid for Linux servers.
Only today I heard about the file web.config and got new material to study. Nevertheless, I am still struggling with it.
You can use the url rewrite module for IIS: http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
Here is a good tutorial on the subject: http://www.surfingsuccess.com/asp/iis-url-rewrite.html
Read about friendly-url and .htaccess
See an example:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([a-z0-9-]+)/?$ index.php?pag=$1 [NC]
RewriteRule ^([a-z0-9-]+)/([0-9]+)/?$ index.php?pag=$1&id=$2 [NC]
</IfModule>
That way when you use:
localhost/contact
The server will do an internal redirect to:
localhost/index.php?pag=contact

Symfony 1.4 Error 400 on the home page in prod env (not in dev env)

I have made an tested an application on my computer and all is working fine (I used only the dev environment via the frontend_dev.php page).
When I deploy this application on the test server, I have the error 400 Bad Request below:
Bad Request
Your browser sent a request that this server could not understand.
I accessed to the website with the normal URL.
I'm using symfony 1.4 with doctrine (no others plugins are involved), wamp 2 (php 5.3, apache 2.0.59).
If I try to access the application with the dev environment, it works.
Try checking if the no_script property on your application setting.yml file. If should be set to False, clear cache and try again
Thank you very much Guiman. You have leaded me to the answer.
The no_script_name property wasn't the origin of the problem. Instead, I have my .htaccess in the web directory which was badly generated (I swear on my pet's head that I haven't edited this file before). Below is the file generated by symfony (the bold attribute isn't working within the code one, look at the last line):
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
And this is the updated one (again, look at the last line):
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ **/myApp/index.php** [QSA,L]
</IfModule>
I don't know what happened but I will check on the symfony website I there are similar issues.

How do I edit .htaccess to allow both rails and wordpress requests?

I want to run an instance of wordpress within my rails app. I currently have wordpress files housed in public/wordpress, but I need to configure my .htaccess file to allow both types of requests. How do I do that? currently, .htaccess is:
General Apache options
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)/!$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 "Application error Application failed to start properly"
You should start by adding this to the .htaccess in your public folder:
RewriteCond %{REQUEST_URI} ^/wordpress.*
RewriteRule .* - [L]
However, this is not the whole story. You also need to edit /etc/apache2/sites-available/
with this addition (to tell Rails not to process anything in /blog as part of the app):
<Location /wordpress>
PassengerEnabled off
Also in /etc/apache2/apache2.conf you may need to tell Apache to make any directory index (e.g. wordpress/) execute an index.php file if there is one:
DirectoryIndex index.php

Rewriting rails url from port 3000?

i have an applicaiton that runs at actionengineers.com:3000. How do i reqwite the application to a subdomain or directory (actionengineers.com/myapp) without disturbing the main site of course. i tried to use .htaccess file but i allways get eror 404. here is the code in the .htaccess file.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.deep.actionengeneers.com$
RewriteRule ^/?$ "http\:\/\/127\.0\.0\.1\:3000%{REQUEST_URI}" [P,QSA,L]
Try this rule:
RewriteCond %{HTTP_HOST} =www.deep.actionengeneers.com
RewriteRule ^ http://127.0.0.1:3000%{REQUEST_URI} [P,L]
Now all requests to www.deep.actionengeneers.com are getting passed through to 127.0.0.1:3000 via proxy.

Resources