{"id":18339,"date":"2015-12-22T15:48:42","date_gmt":"2015-12-22T21:48:42","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=18339"},"modified":"2022-12-14T04:39:00","modified_gmt":"2022-12-14T10:39:00","slug":"how-to-install-zen-cart-with-nginx-on-debian-8","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-zen-cart-with-nginx-on-debian-8\/","title":{"rendered":"How to Install Zen Cart with Nginx on Debian 8"},"content":{"rendered":"
This step by step tutorial will show you how to install Zen Cart with Nginx on a Debian 8 VPS<\/strong>. Zen Cart is an open source<\/span> PHP based shopping cart software. This tutorial was tested and written for a Debian 8 VPS<\/a>, but it should work on any Debian based Linux distribution. Make sure your package list and the OS packages are up to date by running the following commands:<\/p>\n Stop and remove Apache2 service:<\/p>\n Install Nginx on your virtual server:<\/p>\n Configure nginx to start on boot:<\/p>\n Install PHP and PHP modules required by Zen Cart:<\/p>\n Download the latest version of Zen Cart at https:\/\/www.zen-cart.com\/getit and upload it to the \/opt directory on your server:<\/p>\n Order an SSL certificate for your e-commerce website<\/a>. Save the SSL certificate and its private key to files named ‘file.crt’ and ‘private.key’ respectively and upload them to \/etc\/nginx directory. and add the following lines: server_name your-domain.com www.your-domain.com;<\/p>\n root \/var\/www\/your-domain.com;<\/p>\n index index.html index.htm index.php index.cgi index.pl index.xhtml;<\/p>\n error_page 400 \/error\/400.html; access_log \/var\/log\/nginx\/your-domain.com-access.log; ## Disable .htaccess and other hidden files location = \/favicon.ico { location = \/robots.txt { location ~ \\.php$ { # expires max on static content # Inaccessible locations # Locations only images should be served from location @imagesonly { location \/shop\/ location ~ \\.php$ { Do not forget to replace your-domain.com with your actual domain name.<\/p>\n Enable the new Nginx configuration file:<\/p>\n Open the \/etc\/php5\/fpm\/pool.d\/www.conf file and change the ‘listen’ variable from:<\/p>\n to<\/p>\n Test the nginx configuration:<\/p>\n Then, restart php5-fpm and Nginx services for the changes to take effect:<\/p>\n Set the proper permissions:<\/p>\n Create a new MySQL database:<\/p>\n Open http:\/\/your-domain.com\/zc_install\/index.php using a web browser and follow the easy instructions: confirm your acceptance of the license terms , enter MySQL database username , password and database name, select ‘Enable SSL’ and ‘Enable SSL in Admin Area’ , click ‘Save System Settings’, enter store information, click ‘Save Store Settings’ and enter administrator username and password.<\/p>\n Reset permissions on ‘configure.php’ files located in the \/admin\/includes\/ and \/includes\/ directories back to read-only mode:<\/p>\n Remove the \/zc_install directory:<\/p>\n Also, rename the ‘admin’ directory to a name less likely to be ‘guessed’ by someone probing your website for illegitimate access.<\/p>\n PS<\/span>.<\/strong> If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" This step by step tutorial will show you how to install Zen Cart with Nginx on a Debian 8 VPS. … <\/p>\n
\n<\/p>\nsudo apt-get update\r\nsudo apt-get upgrade<\/pre>\n
sudo service apache2 stop\r\nsudo apt-get remove apache2\r\nsudo apt-get autoremove<\/pre>\n
sudo apt-get update\r\nsudo apt-get install nginx<\/pre>\n
sudo update-rc.d -f nginx defaults<\/pre>\n
sudo apt-get install php5 php5-cli php5-fpm php5-mysql php5-gd php5-mcrypt \r\nsudo php5enmod mcrypt<\/pre>\n
cd \/opt\/\r\nwget http:\/\/downloads.sourceforge.net\/project\/zencart\/CURRENT%20-%20Zen%20Cart%201.5.x%20Series\/zen-cart-v1.5.4-12302014.zip\r\nunzip zen-cart-v1.5.4-12302014.zip\r\nmv zen-cart-v1.5.4-12302014 \/var\/www\/zen-cart\/<\/pre>\n
\nRemove the default Nginx server block, create a new Nginx configuration file and add the following virtual block for your domain name:<\/p>\nrm \/etc\/nginx\/sites-enabled\/default<\/pre>\n
vi \/etc\/nginx\/sites-available\/your-domain.com.conf<\/pre>\n
\nserver {
\nlisten 80;
\n# If you have an SSL certificate, uncomment the 3 lines below:
\n# listen 443 ssl;
\n# ssl_certificate \/etc\/nginx\/file.crt;
\n# ssl_certificate_key \/etc\/nginx\/private.key;<\/p>\n
\nerror_page 401 \/error\/401.html;
\nerror_page 403 \/error\/403.html;
\nerror_page 404 \/error\/404.html;
\nerror_page 405 \/error\/405.html;
\nerror_page 500 \/error\/500.html;
\nerror_page 502 \/error\/502.html;
\nerror_page 503 \/error\/503.html;<\/p>\n
\nerror_log \/var\/log\/nginx\/your-domain.com-error.log;
\ncharset en_us.UTF-8;<\/p>\n
\nlocation ~ \/\\. {
\ndeny all;
\naccess_log off;
\nlog_not_found off;
\n}<\/p>\n
\nlog_not_found off;
\naccess_log off;
\n}<\/p>\n
\nallow all;
\nlog_not_found off;
\naccess_log off;
\n}<\/p>\n
\ntry_files $uri =404;
\ninclude \/etc\/nginx\/fastcgi_params;
\nfastcgi_pass 127.0.0.1:9000;
\nfastcgi_index index.php;
\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
\nfastcgi_intercept_errors on;
\n}<\/p>\n
\nlocation ~* ^.+\\.(jpg|jpeg|gif)$ {
\naccess_log off;
\nexpires 30d;
\n}<\/p>\n
\nlocation ~ \/includes\/.*\\.php$ { return 403; }
\nlocation ~ \/backups { return 403; }
\nlocation ~ \/download { return 403; }
\nlocation ~ \/email { return 403; }
\nlocation ~ \/media { return 403; }
\nlocation ~ \/logs { return 403; }<\/p>\n
\nlocation ~ \/sqld { try_files nothing.txt @imagesonly; location ~ \\.php$ { return 403; } }
\nlocation ~ \/images { try_files nothing.txt @imagesonly; location ~ \\.php$ { return 403; } }
\nlocation ~ \/editors { try_files nothing.txt @imagesonly; location ~ \\.php$ { return 403; } }<\/p>\n
\ntypes {
\nimage\/gif gif;
\nimage\/jpeg jpeg jpg;
\nimage\/png png;
\n}
\ndefault_type application\/octet-stream;
\n}<\/p>\n
\n{
\nlocation ~ -p-(?<id>[0-9]+)\\.html$ { rewrite ^ \/shop\/index.php?main_page=product_info&products_id=$id; }
\nlocation ~ -c-(?<id>.*).html$ { rewrite ^ \/shop\/index.php?main_page=index&cPath=$id; }
\nlocation ~ -m-(?<id>[0-9]+).html$ { rewrite ^ \/shop\/index.php?main_page=index&manufacturers_id=$id; }
\nlocation ~ -pi-(?<id>[0-9]+).html$ { rewrite ^ \/shop\/index.php?main_page=popup_image&pID=$id; }
\nlocation ~ -pr-(?<id>[0-9]+).html$ { rewrite ^ \/shop\/index.php?main_page=product_reviews&products_id=$id; }
\nlocation ~ -pri-(?<id>[0-9]+).html$ { rewrite ^ \/shop\/index.php?main_page=product_reviews_info&products_id=$id; }
\nlocation ~ -ezp-(?<id>[0-9]+).html$ { rewrite ^ \/shop\/index.php?main_page=page&id=$id; }
\n}<\/p>\n
\ntry_files $uri =404;
\ninclude \/etc\/nginx\/fastcgi_params;
\nfastcgi_pass 127.0.0.1:9000;
\nfastcgi_index index.php;
\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
\nfastcgi_intercept_errors on;
\n}
\n}
\n}<\/p>\nln -sf \/etc\/nginx\/sites-available\/your-domain.com.conf \/etc\/nginx\/sites-enabled\/<\/pre>\n
listen = \/var\/run\/php5-fpm.sock<\/pre>\n
listen = 127.0.0.1:9000;<\/pre>\n
# nginx -t\r\nnginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful<\/pre>\n
sudo service php5-fpm restart\r\nsudo service nginx restart<\/pre>\n
sudo chown www-data:www-data -R \/var\/www\/your-domain.com\/<\/pre>\n
mysql -u root -p\r\nmysql> create database zencartdb;\r\nmysql> GRANT ALL PRIVILEGES ON zencartdb.* TO 'zencart'@'localhost' IDENTIFIED BY 'Y0UR-PASSW0RD';\r\nmysql> flush privileges;\r\nmysql> quit<\/pre>\n
chmod 440 \/var\/www\/your-domain.com\/admin\/includes\/configure.php\r\n\r\nchmod 440 \/var\/www\/your-domain.com\/includes\/configure.php<\/pre>\n
rm -rf \/var\/www\/your-domain.com\/zc_install<\/pre>\n
\nThat is it. The Zan Cart installation is complete.
\nOf course you don\u2019t have to do any of this if you use one of our Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install Zen Cart with Nginx<\/strong> for you. They are available 24×7 and will take care of your request immediately.<\/p>\n