Hi, guys!
I am testing opencart v1.4.4 under nginx web-server and trying to enable seo-urls.
I translated apache rewrite rules into nginx ones and get ruined template, totally ruined.
Here is what i entered in rewrite directive under location in nginx config file:
rewrite ^/(.*)\?*$ /index.php?_route_=$1 last;
So, does anybody uses nginx with opencart and got working seo-urls?
I am testing opencart v1.4.4 under nginx web-server and trying to enable seo-urls.
I translated apache rewrite rules into nginx ones and get ruined template, totally ruined.
Here is what i entered in rewrite directive under location in nginx config file:
rewrite ^/(.*)\?*$ /index.php?_route_=$1 last;
So, does anybody uses nginx with opencart and got working seo-urls?
Ramelito, have you found something on the subject? On the Nginx forum there are only a post in russian: http://forum.nginx.org/search.php?2,sea ... _threads=0
Regards,
Rogerio Madureira
http://atipico.com.br
Regards,
Rogerio Madureira
http://atipico.com.br
Using nginx 0.7.x, it has a good technique for testing for existing files (better than apache), use the 'try_files' option, something like this if you are using php with fast-cgi.
Code: Select all
server {
...
...
location / {
try_files $uri @opencart;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location ~* (\.(tpl|ini))$ {
deny all;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fastcgi/php-fpm.sock;
include fastcgi_params;
}
}
!! EDIT !! EDIT: See following post for admin fix.
!! EDIT: I was unable to access the admin page with the below configuration. It does work for the other SEO urls but apparently not for admin. DO NOT USE IT YET!
I am using nginx and this works for me. Replace example.com with your domain of course:
location / {
if ($host != 'www.example.com') {
rewrite ^/(.*)$ http://www.example.com/$1 permanent;
}
try_files $uri @opencart;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location /admin/ {
index index.php;
}
location ~* (\.(tpl|ini))$ {
deny all;
}
!! EDIT: I was unable to access the admin page with the below configuration. It does work for the other SEO urls but apparently not for admin. DO NOT USE IT YET!
I am using nginx and this works for me. Replace example.com with your domain of course:
location / {
if ($host != 'www.example.com') {
rewrite ^/(.*)$ http://www.example.com/$1 permanent;
}
try_files $uri @opencart;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location /admin/ {
index index.php;
}
location ~* (\.(tpl|ini))$ {
deny all;
}
Last edited by jiblett1000 on Sun Jul 22, 2012 4:03 am, edited 1 time in total.
I was experiencing issues accessing the admin panel after using the above rewrite rules. However after spending way, way too much time on this, I typed in mydomain.com/admin/ with the trailing slash and I could access it.
Before:
Before:
After:This one works.location /admin/ {
index index.php;
}
Simple.....just remove the trailing slash from the rewrite rules and it will match it with or without the trailing slash! Hope this helps someone.location /admin {
index index.php;
}
Here's another version for the nginx + seo URL's setup which works for me. All the others stated here and elsewhere on the internet didn't do the trick on my opencart, so I thought I might share this for others to see.
It's for nginx + php-fpm and it also has tweaks for the database.
The link :
http://www.sellyea.com/step-by-step-ins ... ce-system/
And the code in case the link stops working :
Please note that you shouldn't copy paste the exact code onto your configuration, only the pieces that might seem useful because every setup is different and you might end up breaking things. Always keep a backup first.
It's for nginx + php-fpm and it also has tweaks for the database.
The link :
http://www.sellyea.com/step-by-step-ins ... ce-system/
And the code in case the link stops working :
Code: Select all
Edit Nginx /etc/nginx/nginx.conf
user www-data;
worker_processes 1;
timer_resolution 100ms;
worker_priority -5;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 8192;
events {
worker_connections 1024;
}
http {
#ограничения на одновременное подключение
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
index index.php;
sendfile on;
send_timeout 60;
proxy_read_timeout 200;
proxy_buffers 8 16k;
proxy_buffer_size 16k;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 70;
reset_timedout_connection on;
server_tokens off;
client_body_buffer_size 1K;
client_header_buffer_size 1k;
client_max_body_size 50M;
large_client_header_buffers 2 1k;
client_body_timeout 60;
client_header_timeout 60;
gzip on;
gzip_buffers 64 8k;
gzip_comp_level 3;
gzip_proxied any;
gzip_min_length 1000;
gzip_types text/plain text/css text/xml application/x-javascript application/xml application/xhtml+xml;
types_hash_max_size 2048;
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”‘;
include /etc/nginx/sites-enabled/site.com;
}
Now Lets edit Site config file vi /etc/nginx/sites-enabled/site.com
server {
listen 10.0.0.11:80;
server_name www.site.com;
access_log /var/log/nginx/site.access.log;
error_log /var/log/nginx/site.error.log;
charset utf8;
index index.php;
root /home/user/data/www/site.com/;
limit_conn perip 20;
limit_conn perserver 150;
location / {
server_tokens off;
client_max_body_size 10m;
client_body_buffer_size 128k;
try_files $uri @opencart;
}
location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; }
location ~ /\.ht { deny all; }
location ~* (\.(tpl|ini))$ { deny all; }
if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?_route_=$1 last; }
location /admin {
index index.php;
}
location ~* .(js|css|ico|xml|swf|flv|eot|ttf|woff|pdf|xls|htc)$ {
add_header Pragma “public”;
add_header Cache-Control “public, must-revalidate, proxy-revalidate”;
access_log off;
log_not_found off;
expires 90d;
}
location ~* .(jpg|jpeg|gif|css|png)$ {
access_log off;
expires 10d;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/user/data/www/site.com$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_read_timeout 300;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param DOCUMENT_ROOT /home/user/data/www/site.com;
}
location /phpmyadmin/ {
root /usr/share/;
index index.php;
}
location ~ /\.ht {
deny all;
}
}
Configure php5-fpm vi /etc/php5/fpm/php-fpm.conf
[global] emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s
events.mechanism = epoll
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm-error.log
include = /etc/php5/fpm/pool.d/*.conf
Now edit fpm site config: vi /etc/php5/fpm/pool.d/www.conf
[www] user = www-data
group = www-data
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 3
Now lets tune up mysql config: /etc/mysql/my.cnf:
#With server ram 2GB and 1 CPU
[client] port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe] socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld] user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
skip-external-locking
key_buffer_size = 300M
max_allowed_packet = 32M
myisam-recover = BACKUP
myisam_sort_buffer_size = 500M
max_connections = 100
max_sort_length = 1024
max_heap_table_size = 32M
table_open_cache = 256
thread_concurrency = 8
thread_cache_size = 12
tmp_table_size = 64M
query_cache_limit = 1M
query_cache_size = 64M
read_buffer_size = 256K
read_rnd_buffer_size = 512K
thread_stack = 256K
sort_buffer_size = 10M
log_error = /var/log/mysql/error.log
general_log_file = /var/log/mysql/mysql.log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 2
expire_logs_days = 10
max_binlog_size = 100M
[mysqldump] quick
quote-names
max_allowed_packet = 32M
[mysql] no-auto-rehash
[isamchk] key_buffer = 16M
key_buffer_size = 32M
sort_buffer_size = 32M
read_buffer = 512K
write_buffer = 512K
[mysqlhotcopy] interactive-timeout
!includedir /etc/mysql/conf.d/
Thanks for sharing the information as I'm also planning to move to Nginx from Apache .Did you notice any speed improvements with this setup ?billkou wrote:Here's another version for the nginx + seo URL's setup which works for me. All the others stated here and elsewhere on the internet didn't do the trick on my opencart, so I thought I might share this for others to see.
It's for nginx + php-fpm and it also has tweaks for the database.
The link :
http://www.sellyea.com/step-by-step-ins ... ce-system/
Did you face any issues in OpenCart by using php-fpm ?
Thanks,
Sri.
Nginx is by far faster than Apache according to my experience. It has a much smaller footpring on memory as well which is important.srikanth496 wrote:Thanks for sharing the information as I'm also planning to move to Nginx from Apache .Did you notice any speed improvements with this setup ?billkou wrote:Here's another version for the nginx + seo URL's setup which works for me. All the others stated here and elsewhere on the internet didn't do the trick on my opencart, so I thought I might share this for others to see.
It's for nginx + php-fpm and it also has tweaks for the database.
The link :
http://www.sellyea.com/step-by-step-ins ... ce-system/
Did you face any issues in OpenCart by using php-fpm ?
Thanks,
Sri.
I've been using nginx + php-fpm for a year and a half now in numerous configurations and many of them are quite "big" websites with loads of daily traffic ( joomla, joomla+virtuemart, wordpress, drupal and now opencart ) and I haven't had any problems.
I suggest you add the apc or xcache extension for php and/or microcaching on nginx so that you get the best results possible in terms of performance.
Thanks a lot for your suggestion .
Thanks,
Sri.
As you have good experience on both Nginx & Apache,I have one doubt.I'm planning to use Ticketing System (OSTicket) as well and its folder will be along with my OC installation.It doesn't support Nginx because of the way it was coded .So can I have a setup that has both Nginx & Apache where Nginx will be used for OC & all requests to support folder will be forwarded by Nginx to apache so that Ticketing system can use Apache . ?How difficult is it to come up with setup ?Other alternative for me is to use Nginx as only reverse proxy for serving static content in case if the above setup doesn't work.billkou wrote:
I've been using nginx + php-fpm for a year and a half now in numerous configurations and many of them are quite "big" websites with loads of daily traffic ( joomla, joomla+virtuemart, wordpress, drupal and now opencart ) and I haven't had any problems.
Thanks,
Sri.
Why wouldn't the extension work? Was that something the developer told you?srikanth496 wrote:Thanks a lot for your suggestion .
As you have good experience on both Nginx & Apache,I have one doubt.I'm planning to use Ticketing System (OSTicket) as well and its folder will be along with my OC installation.It doesn't support Nginx because of the way it was coded .So can I have a setup that has both Nginx & Apache where Nginx will be used for OC & all requests to support folder will be forwarded by Nginx to apache so that Ticketing system can use Apache . ?How difficult is it to come up with setup ?Other alternative for me is to use Nginx as only reverse proxy for serving static content in case if the above setup doesn't work.billkou wrote:
I've been using nginx + php-fpm for a year and a half now in numerous configurations and many of them are quite "big" websites with loads of daily traffic ( joomla, joomla+virtuemart, wordpress, drupal and now opencart ) and I haven't had any problems.
Thanks,
Sri.
Yes,developers told that it wouldn't work because of way it was coded (some header issues) and I may get little support on it.So I don't want to take any chances.
Hey, sorry for the delay.srikanth496 wrote:Yes,developers told that it wouldn't work because of way it was coded (some header issues) and I may get little support on it.So I don't want to take any chances.
In this case, the best scenario is to use nginx as a reverse proxy. I haven't used it in such a configuration but I've read that it gives very good results.
The key to everything, I think, is caching. When you have lots of requests and the traffic heats up you have to have everything configured in a way that the content gets served from cache or to ensure that it leaves the least possible footprint in memory and cpu usage. Otherwise you'll end up with problems.
Thanks for the response .I'm trying out the reverse proxy solution .I will update my configuration & progress here.From a static contents perspective,I don't think there is any in-memory caching mechanism available as per my research on nginx.
I don't know if this applies to what you said, but nginx has microcaching capability which is blazing fast if you set it up correctly. Google for it and you will find a lot of articles discussing about it and you can also find some tutorials about it.srikanth496 wrote:Thanks for the response .I'm trying out the reverse proxy solution .I will update my configuration & progress here.From a static contents perspective,I don't think there is any in-memory caching mechanism available as per my research on nginx.
As a reverse proxy though, I'm not sure if it would work, but you can still give it a try.
hei, check this out
serverpilot.io
this apps helps me configure nginx + php5.5 . I can say, it helps me so much, shop running faster now. about 2 sec page load.
serverpilot.io
this apps helps me configure nginx + php5.5 . I can say, it helps me so much, shop running faster now. about 2 sec page load.
Selling Kristik - Jasa Foto Aura - Kapas Vapor - supplier baju anak -
Who is online
Users browsing this forum: No registered users and 26 guests