如何在NGINX上安装和运行CS-Cart第4版,为了我们如何在sitename.com上安装CS-Cart,它假设您已经安装了一个正常的LEMP安装。
第一步:安装CS-Cart
www.sitename.com的文档根目录将是/var/www/www.sitename.com/public_html - 如果此文件夹不存在,则需要创建它:
mkdir -p /var/www/www.sitename.com/public_html
然后将CS-Cart版本4下载到您的计算机,将其上传到临时目录(例如:/ tmp / install)然后解压缩:
cd /tmp/cscart
tar xvfz cscart_v4.2.2.tgz
rm -f cscart_v4.2.2.tgz
mv * .htaccess /var/www/www.sitename.com/public_html/
您需要使文件root和CS-Cart文件可由nginx守护进程写入:
chown -R www-data:www-data /var/www/www.sitename.com/public_html
第二步:创建数据库
此步骤将创建名为cs-cart的数据库和名为cscart_user的用户,密码为xyz123
mysqladmin -u root -p create cs_cart
mysql -u root -p
GRANT ALL PRIVILEGES ON cs_cart.* TO 'cscart_user'@'localhost' IDENTIFIED BY 'xyz123';
GRANT ALL PRIVILEGES ON cs_cart.* TO 'cscart_user'@'localhost.localdomain' IDENTIFIED BY 'xyz123';
FLUSH PRIVILEGES;
quit;
第三步:nginx配置
停止nginx服务:
$ service nginx stop
将/etc/nginx/nginx.conf中的内容替换为以下内容:
user www-data;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
server_tokens off;
gzip on;
gzip_vary on;
gzip_disable “msie6?;
gzip_http_version 1.0;
gzip_comp_level 8;
gzip_proxied any;
gzip_types text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
client_body_temp_path /tmp/client_temp;
# proxy_temp_path /tmp/proxy_temp;
# proxy_cache_path /var/cache/nginx/proxy_cache levels=2 keys_zone=nginx:100m inactive=200m max_size=5000m;
include /etc/nginx/conf.d/*.conf;
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=cache:10m max_size=1000m inactive=60m;
fastcgi_cache_key “$scheme$request_method$host$request_uri”;
}
第三步:创建vhost配置
vi /etc/nginx/sites-available/www.sitename.com.vhost
server {
listen 80;
listen 443 default ssl;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
server_name www.www.sitename.com sitename.com;
location / {
root /var/www/www.sitename.com/public_html;
index index.php;
try_files $uri $uri/ /index.php?sef_rewrite=1&$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .php$ {
root /var/www/www.sitename.com/public_html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/www.sitename.com/public_html$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_cache_valid 200 302 10m;
fastcgi_cache_valid 301 1h;
fastcgi_cache_valid any 1m;
}
location ~* .(css|js|jpg|jpeg|png|swf|gif|svg|ttf|eot)$ {
root /var/www/www.sitename.com/public_html;
try_files $uri http://backend$1;
expires max;
add_header X-CDN “WCWS INTERNET”;
add_header ETag “”;
log_not_found off;
add_header Cache-Control “public”;
add_header Last-Modified “Sat, 30 Mar 2013 21:47:15 GMT”;
}
location ~ /.ht {
deny all;
}
}
要启用此vhost,请从/ etc / nginx / sites-enabled /目录创建一个符号链接:
cd /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/www.sitename.com.vhost www.sitename.com.vhost
使用以下命令测试配置:
nginx -t然后运行
service nginx restart
第四步:基于Web的安装程序
现在通过访问http://www.sitename.com启动CS-Cart安装程序,并继续正常安装
关于贡献者
史蒂夫是Pixel的Pixel电子商务开发商, Pixel是一名专门从事CS-Cart的电子商务开发商。