3

I would like to summarize: I want to know if it is possible to install Magento on Linux with the following configuration:

  1. I do not have root access and so cannot modify the DocumentRoot directive to point anywhere other than /home/jsonderson/public_html .

  2. Magento is installed not in the web domain server root directory, public_html, but in a child directory of public_html, say magento1.

  3. Magento has server rewrites turned on (no index.php in URLs)

  4. THIS IS THE IMPORTANT PART: Magento frontend is accessible not as http://myhost.com/ and not not as http://myhost.com/magento1/ and backend is accessible as http://myhost.com/myadmin

NOTE: I couldn't specify http://myhost.com/ at install time for the base URL even though I seemed to have a suitable .htaccess in public_html at the time, so I had to enter http://myhost.com/magento1 for the URL at install time. Later on when I went to the System -> Configuration -> Web -> Secure URL and Unsecure URL I successfully changed the Secure URL but then could not change the Unsecure URL and Magento would direct me to a "Whoops..." page and wouldn't let me do any updates to the database via the web admin interface after that.


EDIT: Perhaps I should have chosen:

Skip Base URL Validation Before the Next Step Check this box only if it is not possible to automatically validate the Base URL.

during installation. But I'm not sure this is the answer and don't want to take chances with the store, plus why in the world wouldn't the URL validation not work from the install script?


If you can achieve this setup without any problems, please post an answer to this post.

(Ideally I would like to enter the URL at install time and not have any trouble).

Thanks.


EDIT: What follows is from a previous post.


I wonder whether someone can help me set up my .htaccess files on Linux as I cannot figure out exactly what is going wrong with my Magento install.

Here is my setup:

A) http://mydomain.com/ is served from the Unix directory /home/jsonderson/pulic_html/ which is the web server root directory for my domain.

B) For perfectly valid reasons (namely, I have different domains associated with the same IP address, and these are being served, say http://foo.com/ from the subdirectory /home/jsonderson/public_html/foo/. Hence to avoid making a mess with top level files in public_html I created another directory called /home/jsonderson/public_html/mydomain/ where the directory called mydomain is simply what I have renamed my magento freshly unzipped directory after unpacking the Magento 1.8.0.0 zip file.

C) OK, so here is what I want. I want http://mydomain.com/ to serve from public_html/mydomain/ instead of from public_html/. For this the hosting provider I used set me up with the following .htaccess script:

https://my.bluehost.com/cgi/help/000347

which seemed to be working fine when I went to install magento as when I typed http:/mydomain.com/ the index.php install file was opened from public_html/mydomain/ instead of public_html/ which is what I wanted.

D) But then, when I went to install Magento, I enabled server rewrites to make Magento SEO friendly, and it asked me for the URL, and whenever I gave it http://mydomain.com/ it complained saying something like it could not connect (sorry for the vagueness) so I was forced to supply: http://mydomain.com/mydomain/ which is the only thing which would bring the installation script forward.

So I installed it, and it ran, but it ran in an SEO-unfriendly manner. Accessing the domain at http://mydomain.com/ would make the http://mydomain.com/mydomain part appear, not what I wanted.

E) So here is what I don't understand. I can now save the Unsecure URL as http://mydomain.com/, and that works fine, SEO friendly all the way and without the extra mydomain directory appearing.

However, here is what is not working:

When I change the Secure URL to http://mydomain.com/mydomain, and save it (and I do have caching disabled), the UI brings me to the Magento standard "Ops... Not Found" page at: mydomain.com/index.php/admin/system_config/index/key/585f7925b5d04c630c4a7ec01340436d/ for instance (and note how the index.php magically and unwantedly reappears in there). And then to access the admin panel again I have to type: http://mydomain.com/mydomain/admin/ substituting the index.php part with mydomain. When I do this I can see under System -> Configuration -> Web -> Secure Magento totally discarded my change completely from the UI and kept the URL http://mydomain.com/mydomain/ as the Secure URL, with the extra mydomain/ directory, causing the admin panel to crash, screen after screen.

How can I fix this?

public_html/mydomain/.htaccess contains:

<IfModule mod_rewrite.c>
    Options +SymLinksIfOwnerMatch
    RewriteEngine on
    RewriteRule ^api/rest api.php?type=rest [QSA,L]
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [L]
</IfModule>

and public_html/.htaccess contains:

AddHandler application/x-httpd-php54 .php

# BlueHost.com
    # .htaccess main domain to subdirectory redirect
    # Copy and paste the following code into the .htaccess file
    # in the public_html folder of your hosting account
    # make the changes to the file according to the instructions.
    # Do not change this line.
    RewriteEngine on
    # Change example.com to be your main domain.
    RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
    # Change 'subdirectory' to be the directory you will use for your main domain.
    RewriteCond %{REQUEST_URI} !^/mydomain/
    # Don't change these line.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Change 'subdirectory' to be the directory you will use for your main domain.
    RewriteRule ^(.*)$ /mydomain/$1
    # Change example.com to be your main domain again.
    # Change 'subdirectory' to be the directory you will use for your main domain
    # followed by / then the main file for your site, index.php, index.html, etc.
    RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
    RewriteRule ^(/)?$ mydomain/index.php [L]

So, how can I overcome that Magento hicckup.

I don't understand why Magento just won't accept the secure URL.

What do I need to do to get this to work. I contacted support which were very good but never got a workaround for not getting errors in the admin panel, which is very frustrating.

Thanks for your advice.

2

What you are describing is normally done using the so-called document root of the domain. The document root is specified in the Apache server configuration files (e.g. when you are using PLESK it is under /var/www/vhosts/yourdomain.com/conf/vhost.conf). In that file you would just put something in the lines of:

DocumentRoot  /home/jsonderson/pulic_html/mydomain

and then restart the web server to load the new configuration. Afterwards, the domain.com will point exactly to that folder and that is all you have to do.

Have a look at the apache virtual host configuration: http://httpd.apache.org/docs/current/vhosts/examples.html

  • Thank you for your post. Here on bluehost for the time being I'm on a host which is supposed to be shared by various users although I'm not sure what the sysadmins have done with my account. First of all I used to see all other users under /home, then I found myself under a /home1 containing only my account, and now I'm on a /home directory containing only me, and when I run finger I can see no other users. The only thing is when I run ifconfig I can see a load of interfaces named say eth0:cp1 throug eth0:cp60, which must be private IPs of customers who bought the private IP option. – John Sonderson Oct 23 '13 at 22:14
  • In fact I can take the IPs from ifconfig and see their websites. But their usernames cannnot be seen any more. Anyways, the point being, if this host I'm shelled into has all these IPs, one would think it's more than a file server, and that it might work as a web server as well. – John Sonderson Oct 23 '13 at 22:15
  • But no, /etc/httpd is missing /var/www is missing. The hosts file must be hidden somewhere. However, I cannot edit the httpd.conf file and restart the server because I am on a shared host at the time being. – John Sonderson Oct 23 '13 at 22:18
  • Otherwise the directives seem interesting. But, the way bluehost operates, you cannot configure the server root of the primary domain to anywhere other than public_html. I've asked them and they've said no. – John Sonderson Oct 23 '13 at 22:21
  • Is there another solution out there, which does not involve modifying the DocumentRoot apache directive? – John Sonderson Oct 23 '13 at 22:22
2

I managed a site wherein we had a similar setup:

└── httpd
    ├── blog
    ├── cart
    ├── forum
    └── index.php

Wordpress, PHPbb, Magento; they were all installed in subfolders. To get Magento to grab and recognize the site from the root I copied index.php from /cart to the httpd root.

I then modified index.php to point to Mage.php:

require('cart/app/Mage.php');

After that all that is required is to symlink js, skin, media to the correct folder.

I put together a more detailed walk-through on StackOverflow some time ago:

https://stackoverflow.com/a/12750214/582138

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.