In questo tutorial spiegheremo come installare OpenCart 2 su un VPS Ubuntu 14.04 con MariaDB, PHP-FPM e Nginx. OpenCart è una soluzione di e-commerce basata su PHP open source, ricca di funzionalità, facile da usare e compatibile con i motori di ricerca. Questa guida dovrebbe funzionare anche su altri sistemi Linux VPS, ma è stata testata e scritta per Ubuntu 14.04 VPS.
Accedi al tuo VPS tramite SSH
ssh your_user@myVPS
Aggiorna il sistema e installa i pacchetti necessari
user@myVPS:~# sudo apt-get update && sudo apt-get -y upgrade user@myVPS:~# sudo apt-get install python-software-properties software-properties-common git curl openssl vim
Installa MariaDB 10.0
user@myVPS:~# sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db user@myVPS:~# sudo add-apt-repository 'deb http://mirror.pw/mariadb/repo/10.0/ubuntu trusty main' user@myVPS:~# sudo apt-get install mariadb-server
Al termine dell'installazione, eseguire il comando seguente per proteggere l'installazione:
mysql_secure_installation
Successivamente, dobbiamo creare un database per la nostra installazione di OpenCart.
mysql -uroot -p MariaDB [(none)]> CREATE DATABASE opencart; MariaDB [(none)]> GRANT ALL PRIVILEGES ON opencart.* TO 'opencartuser'@'localhost' IDENTIFIED BY 'opencartuser_passwd'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> \q
Scarica ed estrai OpenCart 2
Crea una directory principale per il tuo sito web ed estrai il file zip OpenCart 2
user@myVPS:~# mkdir -p ~/your_shop.com user@myVPS:~# cd ~/your_shop.com user@myVPS:~# wget https://github.com/opencart/opencart/archive/2.0.1.1.zip user@myVPS:~# unzip 2.0.1.1.zip user@myVPS:~# mv opencart-2.0.1.1/upload/* . user@myVPS:~# rm -rf opencart-2.0.1.1 2.0.1.1.zip
Installa e configura PHP e Nginx
Installare PHP e Nginx è abbastanza semplice, basta eseguire il seguente comando:
user@myVPS:~# sudo apt-get install nginx php5-fpm php5-cli php5-mcrypt php5-gd php5-mysqlnd php5-curl user@myVPS:~# sudo php5enmod mcrypt
Crea un nuovo pool PHP-FPM per il tuo utente:
user@myVPS:~# sudo vim /etc/php5/fpm/pool.d/your_user.conf
[your_user] user = your_user group = your_user listen = /var/run/php5-fpm-your_user.sock listen.owner = your_user listen.group = your_user listen.mode = 0666 pm = ondemand pm.max_children = 5 pm.process_idle_timeout = 10s; pm.max_requests = 200 chdir = /
Non dimenticare di cambiare tuo_utente con il tuo nome utente.
Riavvia PHP-FPM
user@myVPS:~# sudo service php5-fpm restart
Genera certificato SSL:
user@myVPS:~# sudo mkdir -p /etc/nginx/ssl user@myVPS:~# cd /etc/nginx/ssl user@myVPS:~# sudo openssl genrsa -des3 -passout pass:x -out opencart.pass.key 2048 user@myVPS:~# sudo openssl rsa -passin pass:x -in opencart.pass.key -out opencart.key user@myVPS:~# sudo rm opencart.pass.key user@myVPS:~# sudo openssl req -new -key opencart.key -out opencart.csr user@myVPS:~# sudo openssl x509 -req -days 365 -in opencart.csr -signkey opencart.key -out opencart.crt
Quindi, crea un nuovo blocco del server Nginx:
user@myVPS:~# sudo vim /etc/nginx/sites-available/your_shop.com
server { listen 80; server_name www.your_shop.com; add_header Strict-Transport-Security max-age=2592000; return 301 http://your-shop.com$request_uri; } server { listen 80; server_name your_shop.com; root /home/your_user/your_shop.com; index index.html index.htm index.php; charset utf-8; access_log /var/log/nginx/your_shop.com.access.log; error_log /var/log/nginx/your_shop.com.error.log; rewrite /admin$ $scheme://$host$uri/ permanent; location / { try_files $uri @opencart; } location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; } location /admin { index index.php; } rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last; rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last; rewrite ^/download/(.*) /index.php?route=error/not_found last; location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } sendfile off; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm-your_user.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors off; fastcgi_buffer_size 16k; fastcgi_buffers 4 16k; } location ~ /\.ht { deny all; } } server { listen 443 ssl spdy; server_name www.your_shop.com; ssl on; ssl_certificate /etc/nginx/ssl/opencart.crt; ssl_certificate_key /etc/nginx/ssl/opencart.key; return 301 https://your-shop.com$request_uri; } server { listen 443 ssl spdy; server_name your_shop.com; ssl on; ssl_certificate /etc/nginx/ssl/opencart.crt; ssl_certificate_key /etc/nginx/ssl/opencart.key; ssl_session_timeout 5m; ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL'; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; root /home/your_user/your_shop.com; index index.html index.htm index.php; charset utf-8; access_log /var/log/nginx/your_shop.com.ssl.access.log; error_log /var/log/nginx/your_shop.com.ssl.error.log; rewrite /admin$ $scheme://$host$uri/ permanent; location / { try_files $uri @opencart; } location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; } location /admin { index index.php; } rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last; rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last; rewrite ^/download/(.*) /index.php?route=error/not_found last; location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } sendfile off; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm-your_user.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors off; fastcgi_buffer_size 16k; fastcgi_buffers 4 16k; } location ~ /\.ht { deny all; } }
Non dimenticare di cambiare tuo_utente con il tuo nome utente.
Attiva il blocco del server creando un collegamento simbolico e riavvia Nginx:
user@myVPS:~# sudo ln -s /etc/nginx/sites-available/your_shop.com /etc/nginx/sites-enabled/your_shop.com user@myVPS:~# sudo /etc/init.d/nginx restart
Installa OpenCart 2
Crea file di configurazione vuoti:
user@myVPS:~# cd ~/your_shop.com user@myVPS:~# touch {admin,.}/config.php
Apri il browser, digita l'indirizzo e segui la procedura guidata di installazione. Durante il processo di installazione, ti verrà chiesto di fornire il database mysql, il nome utente e la password (inserisci il database mysql, il nome utente e la password che hai creato nel passaggio precedente).
Abilita SSL
Al termine dell'installazione per abilitare SSL, accedi alla dashboard dell'amministratore e vai su System -> Settings -> Server Tab and select Use SSL
e fai clic su Salva. Devi anche apportare la seguente modifica nel file config.php.
user@myVPS:~# vim ~/your_shop.com/config.php
Modifica define('HTTPS_SERVER', 'http://your_shop.com/');
a define('HTTPS_SERVER', 'https://your_shop.com/');
Questo è tutto. Hai installato con successo OpenCart 2 sul tuo Ubuntu VPS. Per ulteriori informazioni su OpenCart 2, fare riferimento al sito Web di OpenCart.
Ovviamente non devi fare nulla di tutto ciò se utilizzi uno dei nostri servizi di hosting VPS Linux, nel qual caso puoi semplicemente chiedere ai nostri esperti amministratori Linux di configurarlo per te. Sono disponibili 24 ore su 24, 7 giorni su 7 e si prenderanno immediatamente cura della tua richiesta.
PS . Se questo post ti è piaciuto condividilo con i tuoi amici sui social network utilizzando i pulsanti a sinistra o semplicemente lascia una risposta qui sotto. Grazie.