configuring .htaccess file with multiple subdomains Justhost - ruby-on-rails

Situation is like this :
I have hosting company justhost.com
There I have main domain and two subdomains. First subdomain is with PHP
based webpage, but second is newly created and based on ruby on
rails.
I want such thing, before I am sure that newly created application on RoR is functioning well, keep old one up and running. But somehow when I want modify .htaccess file with code for RoR (source- https://my.justhost.com/cgi/help/rails#access ).
main htacces file located on root_page :
DirectoryIndex index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml index.htm home.htm default.htm index.fcgi default.html
# -FrontPage-
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthUserFile /home/ecotec11/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/ecotec11/public_html/_vti_pvt/service.grp
ErrorDocument 404 /404.shtml
AuthName ecotechno.lv
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
htacces file for RoR application:
Options -MultiViews
PassengerResolveSymlinksInDocumentRoot on
#Change to your environment
RailsEnv production
RailsBaseURI /$HOME/$USER/eco
SetEnv GEM_HOME /
This is what I get :
http://gyazo.com/291394024c60284e315b04b3b91128f4 :
It seems that project can't find installed gems or valid rails installation. I tried to update rails installation, but now when it succeded there is no change at all.
Thanks

Related

Wamp Server : Path of uploaded files

Hi I have a WAMP server where some files are upload into an specific path.
C:\wamp\www\upload\
in this case. However could it be possible to upload these files into for example
D:\Documents\User\upload ?
Upload.php specifies the path where the files are stored but I haven´t the way of changing to another path.
Thanks in advance,
Katherine
Edit: upload.php
Here is the upload_file.php
<?php
$target_path = "c:\\";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "El fichero ". basename( $_FILES['uploadedfile']['name'])." ha sido enviado";
} else{
echo "Hubo un error, inténtalo de nuevo!";
}
?>
Katherine,
In WAMP, Apache is setup ( as it should be for security reasons ) so that Apache will not allow access to the root folder of the C:\
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
**Deny from all**
</Directory>
This stops hackers that successfully break into your site from being allowed to cause REALLY SERIOUS DAMAGE.
So I would expect to see an error message in either your Apache error log or your Php error log. I would also expect to see and error on the screen from XDEBUG unless you have disabled that feature. Maybe you should re-enable it as these error messages are really useful while you are developing!!!
change php.ini
display_errors = On
Now it is possible to open up specific folders outside the normal website folder structure like this
This is an excerpt from the httpd.ini without all the comments
<Directory "d:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
Alias /my_other_upload_folder_alias "c:/some_other/folder/my_other_upload_folder"
<Directory "c:/some_other/folder/my_other_upload_folder">
AllowOverride All
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
</Directory>
</Directory>
You then use 'my_other_upload_folder_alias' as the folder name in your php code.
PS. You look like you are placing your site into c:\wamp\www this is a bad idea!
Create subfolders for your sites like this
c:\wamp\www\site1
c:\wamp\www\site2
And think about create one virtualHost per site.

Request exceeded the limit of 10 internal redirects due to probable configuration error

I was trying to remove index.php from the URL of a Magento website:
_Turn on “use webserver rewrite”
_ Set permission 755 to necessary files and folders
_ make sure mode rewrite is on
_ configure htaccess file. comment, uncomment allow symlinks, change rewrite base from /magento/ to / or /var/www/hosts/www.domainname.com/ or /hosts/www.domainname.com/ or /www.domainname.com/
_reindex, flush cache
But all results in 500 server internal error.
In the log file I can see:
[Fri Apr 20 11:11:59 2012] [error] [client 88.87.40.140] client denied by server configuration: /var/www/hosts/www.nordocks.no/app/etc/local.xml
[Fri Apr 20 11:12:07 2012] [error] [client 117.5.178.168] Request exceeded the limit of 10 internal redirects due to probable configuration error.
And this is my .htaccess
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi
# Action php5-cgi /cgi-bin/php5-cgi
# AddHandler php5-cgi .php
############################################
## GoDaddy specific options
# Options -MultiViews
## you might also need to add this line to php.ini
## cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini
############################################
## this line is specific for 1and1 hosting
#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php
############################################
## default index file
DirectoryIndex index.php
<IfModule mod_php5.c>
############################################
## adjust memory limit
# php_value memory_limit 64M
php_value memory_limit 256M
php_value max_execution_time 18000
############################################
## disable magic quotes for php request vars
php_flag magic_quotes_gpc off
############################################
## disable automatic session start
## before autoload was initialized
php_flag session.auto_start off
############################################
## enable resulting html compression
#php_flag zlib.output_compression on
###########################################
# disable user agent verification to not break multiple image upload
php_flag suhosin.session.cryptua off
###########################################
# turn off compatibility with PHP4 when dealing with objects
php_flag zend.ze1_compatibility_mode Off
</IfModule>
<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<IfModule mod_deflate.c>
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
# Netscape 4.x has some problems...
#BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
#BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
#SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_ssl.c>
############################################
## make HTTPS env vars available for CGI mode
SSLOptions StdEnvVars
</IfModule>
<IfModule mod_rewrite.c>
############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## you can put here your magento root folder
## path relative to web root
#RewriteBase /
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead
AddDefaultCharset Off
#AddDefaultCharset UTF-8
<IfModule mod_expires.c>
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresDefault "access plus 1 year"
</IfModule>
############################################
## By default allow all access
Order allow,deny
Allow from all
###########################################
## Deny access to release notes to prevent disclosure of the installed Magento version
<Files RELEASE_NOTES.txt>
order allow,deny
deny from all
</Files>
############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags
#FileETag none
Please give me an instruction on how to deal with this error.
On my side it was not a permission problem but simply (and the same is in your .htaccess) the line with:
RewriteBase /
was commented.
Uncommenting it solved the problem.
Set permission 755 to necessary files and folders
You've hit a rock on this one. The permissions have been changed on items that need other permissions than 755 set.
Resetting File Permissions
The base things to watch out for are the files & directories that must be writeable:
- file: magento/var/.htaccess
- directory: magento/app/etc
- directory: magento/var
- all the directories under: magento/media
chmod o+w var var/.htaccess app/etc
chmod -R o+w media
I had this same problem.
The directory for my Magento website on my Ubuntu server is: /var/www/magento
When running Magento initial installation I selected "No" for Use Web Server Rewrites. This setting is under Admin Panel - System - General - Web.
In .htaccess of root magento folder after finishing the initial installation it had:
RewriteBase /magento/
As noted before my folder was /var/www/magento/
I changed Web Server Rewrites to Yes. In .htaccess I changed:
RewriteBase /
Works fine now.
I ran into this issue aswell
adding
RewriteBase /
to the .htaccess brought me a step further.
After this I ran into the next issue:
Could not determine temp directory, please specify a cache_dir manually";i:1;s:4307:"#0 /XXX/XXX/lib/Zend/Cache/Backend.php(217): Zend_Cache::throwException('Could not deter...')
Solution for this was to edit the
\lib\Zend\Cache\Backend\File.php
In the file.php search for
'cache_dir' => null,
and replace with
'cache_dir' => "var/tmp/",
I hope this saves somebody else some time.

Parsing apache2 config using nokogiri

How can i parse apache2 config file using nokogiri or any other xml parser? I've tried to parse the file using Nokogiri::XML the following way:
parsed = Nokogiri::XML(File.open("/home/user/config"))
That didn't help. When trying to inspect the object using parsed.errors i get the following:
[#<Nokogiri::XML::SyntaxError: Start tag expected, '<' not found>]
Is there any gems or anything else to parse apache config, edit and save it?
UPD:
Here is my config file:
LoadModule passenger_module /home/user/.rvm/gems/ree-1.8.7-2012.02#gemset/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /home/user/.rvm/gems/ree-1.8.7-2012.02#gemset/gems/passenger-3.0.11
PassengerRuby /home/user/.rvm/wrappers/ree-1.8.7-2012.02#gemset/ruby
<VirtualHost *:80>
ServerAdmin user#localhost
RailsEnv staging
DocumentRoot /path_to_project/public
Alias /webdav /path_to_project/public/dir
Alias /webdav-some-dir path_to_project/public/dir/another_dir
ServerSignature On
<Directory path_to_project/public>
AllowOverride all
Options -MultiViews
AddDefaultCharset utf-8
</Directory>
<Location /webdav>
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/project_name/passwd.dav
PassengerEnabled off
Require globalAdministrator
<Limit GET OPTIONS PROPFIND>
Require user username #valid-user
</Limit>
<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
Require user username #globalAdministrator
</Limit>
</Location>
<LocationMatch "/webdav/.+/.+/.+/.+/.+/.+">
<Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
Require user username #valid-user
</Limit>
</LocationMatch>
<Location /webdav-some-dir>
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/project_name/passwd.dav
PassengerEnabled off
Require globalAdministrator
<Limit GET OPTIONS PROPFIND>
Require user username #valid-user
</Limit>
<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
Require user username #valid-user
</Limit>
</Location>
<LocationMatch "/webdav-some-dir/.+/.+/.+/.+/.+">
<Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
Require user username #valid-user
</Limit>
</LocationMatch>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Apache config files are not valid XML. It has XML-like (most likely SGML-like) tags for grouping of options, but it's not in any way XML. Try the apache_config gem for parsing the config file; though it seems unmaintained.
Hash.from_xml(File.open("/path/to/config", "r").read)
If this doesnt work you schould also post the content of the config file here....
What are you trying to accomplish? I think your app should not be concerned about the apache setup it's running under...

Deploy Rails Application on Bluehost

I am trying to deploy my RoR application in Bluehost but I´m having some trouble. I want my Rails application to be accessible from a top-level domain, that is to be access once someone access my website URL. I have followed several tutorials, and tried several approaches, but I´m still getting no where. When I access my URL (http://hotelelcidacapulco.com/) I get the following message: No such file or directory - config.ru
I assume it must be a problem of the Symlink. I´ve tried different symlinks however I think it should be:
ln -s ~/path/appName/public appname so something like this:
ln -s ~/rails_apps/ElCid/public ElCid
But I get again the error message message: No such file or directory - config.ru
Again, I´m deffinitely no expert but I assume it has something to do with the symlink. I´ve been struggling a lot, and would really appreciate the help as I need to get it runnning as soon as possible.
Here are my files:
/home3/hotelelc/public_html/.htaccess File:
SetEnv GEM_HOME /home3/hotelelc/ruby/gems
<IfModule mod_passenger.c>
Options -MultiViews
PassengerResolveSymlinksInDocumentRoot on
RailsEnv production
RackBaseURI /
SetEnv GEM_HOME /home3/hotelelc/ruby/gems
</IfModule>
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"
/home3/hotelelc/.bashrc File:
export HPATH=/home3/hotelelc/
export GEM_HOME=$HPATH/ruby/gemsexport GEM_HOME=$HPATH/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib64/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$HPATH/ruby/gems/bin
export PATH=$PATH:$HPATH/ruby/gems
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
Finally, this is my /config/environment.rb File:
require File.expand_path('../application', __FILE__)
ElCid::Application.initialize!
ENV['GEM_PATH'] = '/home3/hotelelc/ruby/gems:/usr/lib64/ruby/gems/1.8'
Try moving your .htaccess file to the public directory of your app instead of public_html. I believe this will be app/public/.htaccess. Hope it helps!
Yeah I know this is an old question, but for future readers.

How to password control access to all urls except one in apache 2

I want to password protect all urls on my beta site at the moment. Except one url because it is called by flash and flash can't handle basic auth properly it seems. So i want to disable basic auth for that one url. This is my config in apache. Apache is a proxy for tomcat but that should not matter right ?
<IfModule mod_proxy_ajp.c>
ProxyRequests On
ProxyVia On
<Location /uploader>
Order allow,deny
Allow from all
ProxyPass ajp://localhost:8050/uploader
ProxyPassReverse ajp://localhost:8050/uploader
</Location>
<Location />
Order allow,deny
Allow from all
AuthType Basic
AuthName "Restricted area"
AuthUserFile /etc/apache2/passwd/site-access
Require valid-user
ProxyPass ajp://localhost:8050/
ProxyPassReverse ajp://localhost:8050/
</Location>
</IfModule>
SO my thinking is that if http://www.example.com/uploader is called then the first location config is should be matched and no auth is required.
This does not seem to work i always get asked for auth. Any ideas ?
regards
Peter Delahunty
Add Satisfy Any to the uploader location:
<Location /uploader>
Order allow,deny
Satisfy Any
Allow from all
ProxyPass ajp://localhost:8050/uploader
ProxyPassReverse ajp://localhost:8050/uploader
</Location>
This is documented in the Apache docs, but under the description of the Require directive.

Resources