Tuesday 29 December 2015

example nginx file

Example NGINX file


#####################################################
#
# Provided by the Magento Support Center
# http://magentosupport.help/knowledgebase/configuring-nginx-to-work-with-magento-advanced/
#
# Your Magento Tutorial specialists
#
server {
    listen       66.155.YOURIPHERE;
    server_name  websitename.co.uk;
    root /var/www/htdocs/yourwebsiteroot;
   
    ##
    # redirect to www
    ##
    #if ($host !~* ^www\.) {
    #    rewrite ^(.*)$ http://www.$host$1 permanent;
    #}

    ##
    # dont log robots.txt requests
    ##
    location /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    ## These locations would be hidden by .htaccess normally
    location ^~ /app/                { deny all; }
    location ^~ /includes/           { deny all; }
    location ^~ /lib/                { deny all; }
    location ^~ /media/downloadable/ { deny all; }
    location ^~ /pkginfo/            { deny all; }
    location ^~ /report/config.xml   { deny all; }
    location ^~ /var/                { deny all; }
    location /var/export/            { deny all; }
    # deny htaccess files
    location ~ /\. {
        deny  all;
        access_log off;
        log_not_found off;
    }

    ##
    # Rewrite for versioned CSS+JS via filemtime
    ##
    location ~* ^.+\.(css|js)$ {
        rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
        expires 31536000s;
        access_log off;
        log_not_found off;
        add_header Pragma public;
        add_header Cache-Control "max-age=31536000, public";
    }
    ##
    # Aggressive caching for static files
    # If you alter static files often, please use
    # add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
    ##
    location ~* \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|otf|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|t?gz|tif|tiff|ttf|wav|webm|wma|woff|wri|xla|xls|xlsx|xlt|xlw|zip)$ {
        expires 31536000s;
        access_log off;
        log_not_found off;
        add_header Pragma public;
        add_header Cache-Control "max-age=31536000, public";
    }

    # error pages
    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
   
    location / {
        try_files /maintenance.html $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
        expires 30d; ## Assume all files are cachable
    }
    location @handler { ## Magento uses a common front handler
        rewrite / /index.php;
    }
    location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*.php)/ $1 last;
    }
   
    ##
    # pass the PHP scripts to FastCGI server listening at unix:/tmp/php5-fpm.sock
    ##
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/tmp/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SERVER_PORT 80;
        fastcgi_param  HTTPS $fastcgi_https;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
        fastcgi_param  MAGE_RUN_TYPE store;
    }


    rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
    rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
}

Friday 14 August 2015

Edit / add to your host file

Adding to a host file

right click your note pad and select "run as administrator"

Locate the following file: C:\Windows\System32\drivers\etc

add the following

00.000.000.00 yoursite.com www.yoursite.com
Adding to a host file

right click your note pad and select "run as administrator"

Locate the following file: C:\Windows\System32\drivers\etc

add the following

00.000.000.00 yoursite.com www.yoursite.com

Thursday 7 May 2015

Create Magento Site Nginx 2015

Make directory under var/vhosts/www  and add magento files
go to ect/php-fpm.d/  create config file
go to ect/nginx/conf  create config file
Putty, login.
Add the following commands:
mysql;
create database databasenamehere;
grant all privileges on databasenamehere.* to 'usernamehere'@'localhost' identified by "passwordhere";  
exit;
service php-fpm restart;
service nginx restart;

close putty if no errors.


When you did the php-fpm restart both answers which popup should say ok in green if not follow the error message given this will be in the root: ect/php-fpm.d/ folder and file uploaded earlier. If this has taken other sites on the server down, download (so you have a copy to ammend) then delete the new config file you made earlier from the server. Make sure you get the right config file other wise you will loose the other sites forever.
Visit the website you have just created.

Tuesday 5 May 2015

nginx putty commands

Putty -

su root (switches user to root)

have to put a semi-col after each command so that it recognizes it ;

service php-fpm restart;  (restarts any new php-fpm docs or edits)

service nginx restart;      (restarts nginx)

mysql;  (opens mysql)

create database typedatabasename;  (replace type databasename with your own database name - creates a new database)

grant all privileges on typedatabasename.* to 'typeusername'@'localhost' identified by "typepassword";   (creates a username and password for the named database)

flush privileges; (restarts mysql)

exit (quits mysql)

chown -R default.co.uk:default.co.uk /var/www/vhosts/default.co.uk (changes ownership of the route listed in the command)


If on the magneto installation wizard under the configuration tab you get: Database connection error. as a message use the following command:
grant all privileges on yourdatabasename.* to 'yourusername'@'localhost' identified by "yourpassword";
if the local host part hasnt been picked up it wont work.

Tuesday 23 September 2014

Apache server - adding another store view - magento multistore

1) added a new root category "test"


2) Created a new store view via configuration>manage stores

Create Website:
Name: newsite
Code: storecode
position: (left blank will autofill)

Create store:
Name: newsite
Root Category: "test" category made in previous step

Create Store View:
Drop down - select store from previous step
Name: newsite
Code: storecode
Enabled
left sort order blank.


3) Configuration > System > Web >

CHANGE STORE VIEW!!!!!! other wise you will have major problems with the next step it will lock you out of your website (if this happens see my other post: http://magento-myguide.blogspot.co.uk/2014/03/magento-mysql-base-urls-locked-out-of.html)

So... change the store view to your new one called "newsite"
go to the tab called "unsecure" and change the "Base URL"
you need to change the base url to the website you want this storeview to open at i.e. www.mysite.co.uk
also change the next tab which is default pages - you will need to make the new site its own homepage other wise the site will re direct to the default!!!

save and repeat the process (keep checking that store view)
go to the "secure" tab and again change the "Base URL"
as you did before.


4) to link the domain name to your new store view I edited the index.php file in my httpdocs where I found the similar code relating to the other store views.

The First "case" (red) is the new site name
The second "case" (green) is the main site name 
In the first part of the bracket (blue) you need to enter the store code. 

Code is as follows:



switch ($_SERVER['HTTP_HOST']){
case "newsite.co.uk":
case "www.mainsiteco.uk":
        Mage::run('storecode', 'website'); 
    break;
    default: 
       Mage::run($mageRunCode, $mageRunType);
}




Upload the index.php doc via ftp (make a backup of the original first) and test your sites domain.

Creating a multi store on an Apache server


Step 1: Create a New Store in Magento
The first step in setting up multi-store functionality is to create the new store(s) in the Magento Admin application. Follow the steps below to create a new store:

  1. Log in to the Magento Admin Panel.
    NOTE: If you want your stores to share the same catalog and products, you may skip to Step 7. 
  2. In the top menu, go to Catalog > Manage Categories .
  3. Click Add Root Category .      

·  In the Name field, enter your new store name.
·  Under Is Active , select Yes .
·  Click the Display Settings tab. Under Is Anchor , select Yes , and then select Save Category .
Go to System > Manage Stores .
Go to System > Manage Stores .
·  Click Create Website .
·  In the Name field, enter your new store name.
·  In the Code field, enter a unique string without spaces, and then click Save Website .
·  Click Create Store .
·  In the Website field, select the website that you just created.
·  In the Name field, enter a name for your store.
·  In the Root Category field, select the Root Category that you created above or use the default Root Category if you skipped ahead. Click Save Store .
·  Click Create Store View .
·  In the Store field, select the store you just created. In the Name field, give your view a name (typically "English").
·  In the Code field, enter a unique string to identify the store view. Change the Status to Enabled . Then click Save Store View .
·  Go to System > Configuration .
·  In the Current Configuration Scope , select the website that you just created. This is changing a store view

CHANGE STORE VIEW!!!!!! Make sure you do this other wise you will have major problems with the next step it will lock you out of your website (if this happens see my other post: http://magento-myguide.blogspot.co.uk/2014/03/magento-mysql-base-urls-locked-out-of.html)
·  Select the Web menu option, and then click to expand the Unsecure and Secure sections, respectively.
·  For each section, clear (deselect) the Use Default box next to the Base URL and enter the URL for your store, including the trailing slash. When you are done, click Save Config .





So... change the store view to your new one called "newsite"
go to the tab called "unsecure" and change the "Base URL"
you need to change the base url to the website you want this storeview to open at i.e. www.mysite.co.uk


Make sure you assign a home page under configuration > web > default pages other wise it will always re direct back to your original store view! 

save and repeat the process (keep checking that store view)
go to the "secure" tab and again change the "Base URL"
as you did before.


Step 2: The techy bit
to link the domain name to your new store view I edited the index.php file in my httpdocs where I found the similar code relating to the other store views.

The First "case" (red) is the new site name
The second "case" (green) is the main site name 
In the first part of the bracket (blue) you need to enter the store code. 

Code is as follows:



switch ($_SERVER['HTTP_HOST']){
case "newsite.co.uk":
case "www.mainsiteco.uk":
        Mage::run('storecode', 'website'); 
    break;
    default: 
       Mage::run($mageRunCode, $mageRunType);
}


Upload the index.php doc via ftp (make a backup of the original first) and test your sites domain.