Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

some notes for those stuck on step two - virtual servers htaccess php.ini directive


code_warrior

Recommended Posts

Posted

There's many posts by those "stuck on step two" of the web-based install, and similar replies that these php directives must be "on" in /etc/php.ini:

 

register_globals on

 

register_long_arrays on

 

 

 

I'm writing this primarilly to help those that wish to perform this on a dedicated server running their store as a virtual host (you know who you are, or this is not for you :-) and need to set php directives using AllowOverride through the .htaccess file in the virtual host OSCommerce catalog directory. My environment is RH Core4 (fully updated with YUM repository) / Apache 2.0.54 / PHP 5.0.4 / OSC 2.2.

 

Some of the recommendations elsewhere include rolling back software to earlier versions and this is not necessary nor advisable, as earlier version may have conflicts and serious security vulnerabilities!

 

There's a couple ways to get the the php directives above to be in effect. The popular way described elsewhere is to manually edit the /etc/php.ini file, setting the server global defaults to "on" for those 2 directives. This is easy and effective, but then influences all the servers (main default server and all virtual servers) that may be running on the physical server, and may not be optimum for either security or performance, when all you really want is the directives to apply to the store.

 

 

 

One alternate is to run the store on the main default server /var/www/html/ and set the php directives through the .htaccess file in the catalog directory. This is how:

 

1) Edit the section of /etc/httpd.conf that defines the root web server directory from:

 

<Directory "/var/www/html">

Options Indexes FollowSymlinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

 

to:

 

<Directory "/var/www/html">

Options Indexes FollowSymlinks

AllowOverride Options

Order allow,deny

Allow from all

</Directory>

 

2) In the /var/www/html/catalog/.htaccess file, DO NOT uncomment the <IfModule> statement at the end (which is for php4) but add the following at the bottom (please note correct syntax is "On" not Boolean):

 

<IfModule mod_php5.c>

php_value register_globals On

php_value register_long_arrays On

</IfModule>

 

3) restart Apache from the command line:

 

httpd -k restart

 

 

 

Another alternative (my preference) is to run the store under its own virtual server. Creating a virtual server is outside the scope of this document, but to get it to pass the php.ini Override directives requires just some slight differences in editing the /etc/httpd.conf referenced above.

 

1) In /etc/httpd.conf DO NOT edit the default webserver (/var/www/html referenced above), but look for the <VirtualHost> section (usually near the bottom) which may look something like this:

 

<VirtualHost 10.0.0.5:80>

SuexecUserGroup "#501" "#501"

ServerName mystore.mydomain.com

ServerAlias www.mystore.mydomain.com

DocumentRoot /home/mystore/public_html

ErrorLog /home/mystore/logs/error_log

CustomLog /home/mystore/logs/access_log custom

ScriptAlias /cgi-bin/ /home/mystore/cgi-bin/

<Directory /home/mystore/public_html

Options Indexes IncludesNOEXEC FollowSymlinks

Allow from all

</Directory>

</VirtualHost>

 

And add the following line within the <Directory> section:

 

AllowOverride Options

 

like this:

 

<VirtualHost 10.0.0.5:80>

SuexecUserGroup "#501" "#501"

ServerName mystore.mydomain.com

ServerAlias www.mystore.mydomain.com

DocumentRoot /home/mystore/public_html

ErrorLog /home/mystore/logs/error_log

CustomLog /home/mystore/logs/access_log custom

ScriptAlias /cgi-bin/ /home/mystore/cgi-bin/

<Directory /home/mystore/public_html

Options Indexes IncludesNOEXEC FollowSymlinks

AllowOverride Options

Allow from all

</Directory>

</VirtualHost>

 

 

2) The root directory of your virtual server will actually be under the /home/*your_username*/public_html/ and should contain the catalog/.htaccess file, which you edit exactly as in step 2) above. DO NOT uncomment the <IfModule> statement at the end (which is for php4) but add the following at the bottom (please note correct syntax is "On" not Boolean):

 

<IfModule mod_php5.c>

php_value register_globals On

php_value register_long_arrays On

</IfModule>

 

3) restart Apache from the command line:

 

httpd -k restart

 

 

 

Enjoy!

Posted

Alternatively, use the following two lines in a .htaccess file in the root of your website:

 

php_flag register_globals on

php_flag register_long_arrays on

 

I appreciate what you are trying to say to people, but your advice is mostly dependent upon people running their own dedicated or virtual dedicated servers. Most people don't have access to httpd.conf, or even to a local copy of php.ini

 

Also, much of that advice is server specific.

 

Vger

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...