Magento not accessible since tried to move to multi website setup. Apache issue? - apache

I wish I had never seen this article:
http://www.magentocommerce.com/knowledge-base/entry/tutorial-multi-site-multi-domain-setup
I have Apache 2.2 installed on my XP machine and until a while ago I had a Magento site that I could test the development of a custom module on. I decided that I wanted to have multiple websites and multiple stores so that I could test that my modules configuration variables set at the different scopes (global, website, and store) were working as expected.
So I followed the instructions in the above Magento article. I created a website and gave it a name of “paulsplace.com”. I created a couple of Stores under that website. I then went to System/Configuration/General/Web and, with the scope set to paulsplace.com, I set the unsecured and secured URLs to http://paulsplace.com/ and https://paulsplace.com/ and hit Save Config - what a mistake!!
I got a 404 error. And now I can’t get to my magento front end or back end.
I tried a couple of things:
I added these lines to my hosts lookup file:
127.0.0.1 paulsplace.com
127.0.0.1 www.paulsplace.com
I then uncommented this line in my httpd,conf file:
Include conf/extra/httpd-hosts.conf
and added the following to the conf/extra/httpd-hosts.conf file:
<VirtualHost *:80>
ServerAdmin me#myemail.com
DocumentRoot "C:/Applications/Apache Software Foundation/Apache2.2/htdocs"
ServerName paulsplace.com
ErrorLog "logs/paulsplace.com-error.log"
CustomLog "logs/paulsplace.com-access.log" common
</VirtualHost>
and restarted Apache.
If I browse to “http://www.paulsplace.com” I now get a page that just says “It works!”. Same for “http://paulsplace.com” and “http://www.paulsplace.com/magento/index.php”.
I tried a few more things - I added this line to httpd.conf:
AccessFileName htaccess
(I did this because Windows Explorer didn’t let me create a file starting with a dot; I could do it from the command prompt, but I believe what I have done should be ok).
I changed AllowOverride to All from None:
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
<Directory "C:/Applications/Apache Software Foundation/Apache2.2/htdocs">
AllowOverride All
</Directory>
and in C:\Applications\Apache Software Foundation\Apache2.2\htdocs\htaccess (a file that I created), I entered:
SetEnvIf Host www\.paulsplace\.com MAGE_RUN_CODE=pws1
SetEnvIf Host www\.paulsplace\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^paulsplace\.com MAGE_RUN_CODE=pws1
SetEnvIf Host ^paulsplace\.com MAGE_RUN_TYPE=website
(pws was the value I used for the “Code” when creating my store).
Please tell me how I can put this right. I feel like I’m taking one step forward and three backward at the moment.
Any help really would be greatly appreciated.

<VirtualHost *:80>
ServerAdmin me#myemail.com
DocumentRoot "Change this to point at your magento install"
ServerName paulsplace.com
ErrorLog "logs/paulsplace.com-error.log"
CustomLog "logs/paulsplace.com-access.log" common
SetEnv MAGE_RUN_TYPE website
SetEnv MAGE_RUN_CODE pws1
</VirtualHost>

If changing anything in System Configuration borks your system, you can always clear out the bad values in the database directly, and clear your Magento cache. Do a
select * from core_config_data where value LIKE '%paulsplace.com%'
This will give you the two rows that were added when you clicked save. Remove the rows. Next, clear out all the files in
var/cache/*
to clear your cache. Then restore your Apache config to what it was before you started monkeying around. This should restore your site back to its previous state, and you can continue to experiment with things.

Related

Apache showing empty "index of /", after dist upgrade

I'm working on a Debian 7 server which I did a dist upgrade on so it is Debian 8 now.
The only thing I am having trouble with is the apache2 which got updated from 2.2 to 2.4. the problem that is that now it shows me an empty "Index of /" although there are a lot of files in the specified folders.
vHost Conf:
<VirtualHost *:80>
ServerAdmin some#email
ServerName some.server
ServerAlias some.server
DocumentRoot "/data/apt/public_html"
<Directory "/data/apt/public_html">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Require all granted
</Directory>
</VirtualHost>
How can I get it working again?
mixing 2.2 and 2.4 access directives is not recommended. Look at http://httpd.apache.org/docs/current/upgrading.html. You will see that they never mix Order allow,deny with Require all granted. So remove your Order line.
Mixing old and new directives
Mixing old directives like Order, Allow or Deny with new ones like
Require is technically possible but discouraged. mod_access_compat was
created to support configurations containing only old directives to
facilitate the 2.4 upgrade. Please check the examples below to get a
better idea about issues that might arise.
Also, you do not specify a DocumentIndex file so Apache does not know which file it should return a client when he asks for http://some.server/.
Let's assume the default page is index.html, add this in your VirtualHost:
DocumentIndex index.html
Note 1: ServerAlias has the same value as ServerName, and is therefore not required.
Note 2: you should setup access and error log files for this VirtualHost. It might not be useful if you have only 1 VirtualHost, but you will thank me if you have a large site (with multiple VH later).

VirtualBox Ubuntu 16.04 apache2 vhost jumping to https or not showing the page

I am trying to set up some vhosts on a Virtual Box with Ubuntu 16.04 Apache2 PHP 7.0 to start moving the code to PHP7.
I have moved the v-host file from the older VBox which looked like this
<VirtualHost 192.168.2.174:80>
ServerName admin.ubuntu16.de
ServerAlias admin.ubuntu16.de
ServerAdmin email#company.de
DocumentRoot /home/www/public_html/workspace/admin
php_value auto_prepend_file '/home/www/public_html/workspace/admin/administration/conf/register_globals.php'
<Directory /home/www/public_html/workspace/admin>
Options Indexes FollowSymLinks MultiViews ExecCGI
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
But it kept on trying to load the page with https or saying that there is no access to site root folder
These settings work perfectly on Ubuntu 14 Virtuall Box with apache2 and PHP 5.5.something
So I followed the tutorial and changed it to simply
<VirtualHost 192.168.2.174:80>
ServerName admin.ubuntu16.de
ServerAlias admin.ubuntu16.de
ServerAdmin email#company.de
DocumentRoot /home/www/public_html/workspace/admin
</VirtualHost>
But now it just jumps straight to https mode
I obviously ran a2ensite
I also switched off the default site by running "a2dissite 000-default.conf"
I also enable modules to do with proxying and a bunch of others while getting appache to actuallly start :-)
Any ideas on things I might off missed are greatly appreciated.
Just a little edit:
All the files for the sites are situated on the main Windows machine and are imported through /media/sf-workspace
The symbolic link is then created as /home/www/public_html/workspace
I would first eliminate the symbolic links and just make a copy of all the files inside the virtual box to remove that variable.
Apache can be screwy with symlinks.

Local website not working

I'm having a lot of trouble setting up a local website that I need to do some work on.
I have 2 local sites: "first_training" and "resus_skills"
The former, first_training, works. I have it set up that first_training.loc/ takes me to the local site. resus_skills is set up in the exact same way, but when I try to access resus_skills.loc/ all I get is:
Here are the details of my setup, as well as some screenshots of it:
/etc/apache2/sites-available/resus_skills.conf :
<VirtualHost *:80>
ServerName resus_skills.loc
ServerAlias www.resus_skills.loc
DocumentRoot "/var/www/resus_skills"
<Directory "/var/www/resus_skills">
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I made sure to enable it with sudo a2ensite resus_skills.conf and have confirmed that it's symlink is present in ``/etc/apache2/sites-enabled`
I've made sure my apache server is running:
and I've run apachectl -S to get this result:
I am able to reach first_training.loc/ with no issues, but cannot reach resus_skills.loc/.
I'm unsure how to troubleshoot this - the apache error.log isn't showing me anything.
Before anyone points out what an idiot I've been - I never updated the /etc/hosts file, which was the only missing step.

Rails: Vhost config for Apache and Passenger

I'm trying to get a simple Rails 4 app deployed on my server which already has Apache2 and is hosting several other sites and services (ie there are several vhost configs under sites-enabled). I've had some problems doing this on my local machine as well as my test server so I'm trying first to get it working on an AWS t1.micro instance with only one vhost config. I've written a script to do most of the heavy lifting for me which is on my github at rails-apache-passenger.
I have two vhost config files in the repo and have tried to get one or the other working. The script just copies over and enables one at a time.
Using the my-ruby-app-basic or the my-ruby-app vhost config I navigate to http://54.xxx.xxx.xxx/my-ruby-app/ but all I see is "The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved." When I go to ttp://54.xxx.xxx.xxx/ I just get the default apache2 page ("It works!").
My /var/www/my-ruby-app/log/production.log shows
I, [2014-01-24T10:47:36.900542 #9612] INFO -- : Started GET "/my-ruby-app" for 80.81.17.94 at 2014-01-24 10:47:36 +0000
F, [2014-01-24T10:47:36.902169 #9612] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/my-ruby-app"):
So clearly I need to modify my routes.rb file, but what am I supposed to change? As you can see from the script in the git repo, it's just the default routes.rb from rails new. I just want to see the default rails app landing page at this point so I'm not sure what to do to the routes.rb file.
Here are the vhost configs
my-ruby-app-basic
#This is the config suggested by the passenger module after it finishes compiling, modified for 'my-ruby-app'
<VirtualHost *:80>
ServerName www.my-ruby-app-host.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/my-ruby-app/public
<Directory /var/www/my-ruby-app/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
my-ruby-app
#Based on Apache section of Passenger documents
<VirtualHost *:80>
ServerName www.my-ruby-app-host.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /var/www/
<Directory /var/www/>
Allow from all
</Directory>
Alias /my-ruby-app /var/www/my-ruby-app/public
<Location /my-ruby-app>
PassengerBaseURI /my-ruby-app
PassengerAppRoot /var/www/my-ruby-app
</Location>
<Directory /var/www/my-ruby-app/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
Using Apache and Passenger is a short term solution but I want to know how to do it in any case (The long term view is that I want to maintain compatibility with Jruby and just run our app through Tomcat or Glassfish, which will no doubt be another Apache config debacle ;-) )

Setup Dynamic Virtual Host (Apache2 on Ubuntu)

I want to set up a single virtual host that can dynamically handle all requests based on the hostname used to access it. If %{HTTP_HOST} could be used in a DocumentRoot, this is probably exactly what I want:
<VirtualHost *:80>
ServerAdmin me#example.com
DocumentRoot /var/www/live/%{HTTP_HOST}/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/live/%{HTTP_HOST}/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
ErrorLog /var/www/live/%{HTTP_HOST}/logs/error.log
CustomLog /var/www/live/%{HTTP_HOST}/logs/access.log combined
</VirtualHost>
...unfortunately, %{HTTP_HOST} is not allowed in the DocumentRoot (Warning: DocumentRoot [/var/www/live/%{HTTP_HOST}/public] does not exist). How else can I achieve my goal?
Update: I thought of pointing a catch-all vhost to a single directory and having a .htaccess use mod_rewrite to dynamically select the path but (honestly) I'm exhausted. I'll try at it again in the morning, but in the meantime, if anyone has good ideas, I'd love to hear them! Thank you!
Maybe you can try the following solution from this article: Apache: Dynamic Virtual Hosts
A few months back I looked for a solution to overcome the problem of
creating individual Virtual Hosts in Apache every time I wanted to
configure a new site on a development machine (something that is a big
issue in work where we have a lot of websites). Apache is able to
support this functionality relatively easy using a module and a few
lines in the configuration file. I set this up on Fedora 14, so
results may be slightly different for other OS's (different paths,
configuration file setup, etc)
Open up the main Apache conf (/etc/httpd/conf/httpd.conf), and ensure
the module mod_vhost_alias is enabled. There should be a line in the
configuration like
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Next, add the
following lines to the bottom of this file. You'll need to edit the
file with sudo privileges.
NameVirtualHost *:80
UseCanonicalName Off
<VirtualHost *:80>
VirtualDocumentRoot /var/www/html/domains/%0
</VirtualHost>
This sets up a catch all for any domain coming in over port 80 (the
default port for http traffic, if your using https you will need to
use 443 - alternatively you could remove the port restriction). The
important line here is the VirtualDocumentRoot. The tells Apache where
your files will reside on disk. The %0 part takes the whole domain
name and inserts it into the path. To illustrate this if we went to a
domain testing.com.dev the VirtualDocumentRoot would be:
/var/www/html/domains/testing.com.dev
This type of configuration might
be suitable for most situations, however I didn't want to have the
.dev part of the domain in my folders on disk. I was able to achieve
this by setting the VirtualDocumentRoot to:
VirtualDocumentRoot /var/www/html/domains/%-2+
The above example of testing.com.dev would now point to:
/var/www/html/domains/testing.com
Remember to add the domain to your
hosts file (/etc/hosts)
For a full list of options see the mod_vhost_alias documentation.
Additional documentation can be found here.
The official methods for achieving dynamic virtual hosts are explained in the Apache documentation:
http://httpd.apache.org/docs/2.0/vhosts/mass.html