Errore
  • JFile::read: Unable to open file: '/home/cultusit/public_html/assets/css/style.css'
Home / E-Commerce / Magento su server LEMP (OpenSuSE) - Configurazione del server
A+ R A-
08 Nov

Magento su server LEMP (OpenSuSE) - Configurazione del server

Rate this item
(0 Voti)

Installare Magento su un server LEMP

Installazione dei programmi necessari

Logghiamoci come root

su 

Installiamo prima tutti i pacchetti e poi provvederemo con tutta la configurazione

  yast2 -i mysql-client mysql-community-server nginx-0.8 php5-fpm php5-mysql php5-curl php5-gd php5-mcrypt php5-mbstring

yast provvederà a scaricarsi anche le dipendenze necessarie automaticamente come al solito.

Configurazione MySql

Configuriamo innanzitutto il server MySql digitanto il comando

mysql_secure_installation

e rispondete alle domande come descritto di seguito.

Per comodità username e password di mysql  in questa guida sono rispettivamente root e root

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!
CREARE IL DATABASE MAGENTO

Loggatevi in mysql

mysql -uroot -proot;
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.53-log SUSE MySQL RPM

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database magento;
Query OK, 1 row affected (0.00 sec)
(premiamo ctrl+d)
mysql> Bye
ABILITAZIONE MYSQL QUERY CACHE

apriamo il file /etc/my.conf

nano /etc/my.conf

impostiamo il file modificando e/o aggiungendo i seguenti valori

key_buffer= 512M
max_allowd_packet = 64M
table_cache= 512
sort_buffer_size = 4M
read_buffer_size = 4M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 64M
tmp_table_size = 128M
query-cache-type = 1
query-cache-size = 96M
thread_cache_size = 8
max_connections = 400
wait_timeout = 300

Uscite premendo CTRL+X e salvate dando Y e invio

Configurazione Php5

Prima di eseguire il programma digitiamo il seguente comando per configurare

mv /etc/php5/fpm/php-fpm.conf.default /etc/php5/fpm/php-fpm.conf

quindi andiamo a modificare alcuni parametri decommentate (cioè cancellate i ; precedenti ad ognuna delle seguenti righe)

sostituite, decommentandola, questa riga error_log = log/php-fpm.log con error_log = /var/log/php-fpm.log
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35

ctrl+x e Y per salvare e uscire facciamo quindi partire php-fpm digitando il comando

/etc/init.d/php-fpm start

otterrete questo risultato se tutto è stato configurato correttamente

Starting php-fpm                                                     done

Configurazione Nginx

Testiamo subito se nginx è stato installato correttamente ed è funzionante Da shell digitiamo il comando

/etc/init.d/nginx start

otterremo questo risultato se il server parte correttamente

Starting nginx                                                       done

Aprendo un browser web e digitando l'indirizzo localhost dovreste ottenere una pagina che da errore 403 Forbidden Perfetto! il server funziona Spegnamolo ora digitando il comando

/etc/init.d/nginx stop

Dobbiamo ora configurare php affinché funzioni con Nginx Per fare questo dobbiamo configurare Nginx come segue

 nano /etc/nginx/nginx.conf 

modificate queste rige come segue, sostituendo o aggiungendo i valori sotto riportati:

worker_processes  5;
keepalive_timeout  2;
  
  server {
  
      server_name  _;

      location / {
	  root   /srv/www/htdocs/;
	  index  index.php index.html index.htm;
      }

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      location ~ \.php$ {
	  root           /srv/www/htdocs;
	  fastcgi_pass   127.0.0.1:9000;
	  fastcgi_index  index.php;
	  fastcgi_param  SCRIPT_FILENAME  /srv/www/htdocs$fastcgi_script_name;
	  include        fastcgi_params;
      }

      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      location ~ /\.ht {
	  deny  all;
      }

      ##
      # Virtual Host Configs
      ##

      include /etc/nginx/conf.d/*.conf;
      include /etc/nginx/sites-enabled/*;

  }

CTRL+X e Y per salvare e uscire Creiamo le directory conf.d e sistes-enabled

mkdir -p /etc/nginx/conf.d /etc/nginx/sites-enabled

In sites-enabled andremo ad inserire i files di configurazione per gli host virtuali

Entriamo quindi in sites-enabled e creiamo il file di configurazione magentotest.com

cd /etc/nginx/sites-enabled
nano magentotest.com

incolliamo con ctrl + shift + v quanto segue, salviamo e usciamo

Configurazione server virtuale

server {
    listen 80;

    server_name www.magentotest.com magentotest.com;
    root /srv/www/htdocs/magento;

    gzip on;
    #gzip_comp_level 9;
    gzip_min_length  1000;
    gzip_proxied any;
    gzip_types       text/plain xml css js application/x-javascript;

    ## rewrites example.com to www.example.com
#    if ($http_host != "www.magentoatest.com") {
#        rewrite ^ $scheme://www.magentotest.com$request_uri permanent;
#    }

#    rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www

    location / {
        index index.html index.php; ## Allow a static html file to be shown first
        try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
        expires 30d; ## Assume all files are cachable
    }

    ## 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/ { ## Allow admins only to view export folder
        auth_basic           "Restricted"; ## Message shown in login window
        auth_basic_user_file /srv/www/htdocs/magento/.htpasswd; ## See /etc/nginx/htpassword
        autoindex            on;
    }

    ## Disable .htaccess and other hidden files
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }

    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;
    }

    location ~ \.php$ { ## Execute PHP scripts
        if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss

        expires        off; ## Do not cache dynamic content
        fastcgi_pass   127.0.0.1:9000;
        #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;
        include        fastcgi_params; ## See /etc/nginx/fastcgi_params
    }
}

Ultimi passi

Aggiungiamo al file hosts i due domini virtuali

nano /etc/hosts

e aggiungiamo la seguente riga alla fine del file

127.0.0.1		www.magentotest.com magentotest.com

salviamo e usciamo

Bene, ora riattiviamo il server nginx digitando il comando

/etc/init.d/nginx start
root's password:
Starting nginx                          done

Ora per controllare che sia tutto in regola, scarichiamo il magento-check file dal seguente indirizzo http://www.magentocommerce.com/_media/magento-check.zip

copiamo e incolliamo questo file all'interno della root del nostro webserver

cd /srv/www/htdocs
cp /home/utente/Scaricati/magento-check.zip .
unzip magento-check.zip

Ora apriamo il nostro browser web ed andiamo all'indirizzo http://localhost/magento-check

Se tutto è andato come dovrebbe, dovreste poter leggere una pagina di congratulazioni con il sunto delle caratteristiche del vostro server.

Nel mio caso visualizzo questa pagina:

Congratulations! Your server meets the requirements for Magento.

    You have PHP 5.2.0 (or greater)
    Safe Mode is off
    You have MySQL 4.1.20 (or greater)
    You have the curl extension
    You have the dom extension
    You have the gd extension
    You have the hash extension
    You have the iconv extension
    You have the mcrypt extension
    You have the pcre extension
    You have the pdo extension
    You have the pdo_mysql extension
    You have the simplexml extension
Commenti (0)Add Comment
Scrivi commento
 
  smaller | bigger
 

busy