- Joined
- Sep 15, 2014
- Messages
- 4,342
- Likes
- 8,855
- Degree
- 8
Alrighty - (Related to my SAAS Journal), where we're building the new platform on Nginx. Now obviously building on a new platform you have not mastered or are a completely newbie to is never a good idea. When problems occur you are out of your depth and element. When big problems occur, pray to god Stackoverflow is there to help you or the Google hasn't been compromised (Yes, you might even have to hit page 2, 3, or even 4 to figure out your problem). You might want to pick up this book too in your programming journey:
But when it comes down to the main server of your operation the foundation of everything needs to be solid, and Apache2's speed pales in comparison to Nginx, so it's time to embrace the future.
"Apache is like Microsoft Word. It has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache." - Chris Lea
I know most of you are going to be like
You might as well move on, cause this is me getting nerdy...
Apache and Nginx memory comparison usage (lower is better):
Requests Per Second (higher is better obviously):
Some sources:
Web Server Performance Comparison
--
Nginx's popularity continues to rise, largely I believe due to it's simplicity:
More and more of the topg websites are using Nginx:
Nginx vs. Apache: Our View of a Decade-Old Question
--
So what I did is see how hard it would be to install a wordpress blog under the /blog/ URL. It wasn't too hard actually, in fact the hardest part was getting SSL to run, which took about 10 mins.
First thing you'll need to know is where you'll be storing your html files for your website (you know the exact location where you plan on putting your wordpress). Once you know that open the commandline and visit the /etc/nginx/sites-available/ folder and edit the example.com.conf file (might be example.com). You might also have to delete the "default" file cause that shit will cause problems and a permanent "Welcome to Nginx" screen.
Example of my example.com.conf file:
^^ Now this forces SSL on, and that's a problem if you are using a self signed certificate like I am cause it will create warnings. to Turn off SSL, comment our the "ssl on" lines "#ssl on;" as well as the last two fastcgi_parm lines at the end there.
Now obviously being a newbie at Nginx I welcome ALL and every criticism as I continue figuring out Nginx. But from the above code, SSL is enabled, Wordpress runs on /blog/ with custom permalinks enabled, and that's that.
Remember there is no .htaccess mates, but there sort of is, but that's way is retarded cause it's just mudding up the speed.
Another thing to note, this forces non-www to 301 www. That's why there are two sections. The first section is to 301 anything to the correct scheme ($scheme = http or https) to the www version of that same scheme and add the url you were going to ($request_uri).
Obviously when we get some sexy SSL going we'll replace this self signed certificate with our own, but for now that's the current setup as we continue building the platform. If I find corrections or anything else I'll keep coming back and adding them to this thread. If anyone has any other Nginx tricks feel free to drop them in.
Also, a ton of trial and error made this nginx + wordpress possible, this book also came in handy:
I can't wait to have Nginx meet Redis...
But when it comes down to the main server of your operation the foundation of everything needs to be solid, and Apache2's speed pales in comparison to Nginx, so it's time to embrace the future.
"Apache is like Microsoft Word. It has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache." - Chris Lea
I know most of you are going to be like
You might as well move on, cause this is me getting nerdy...
Apache and Nginx memory comparison usage (lower is better):
Requests Per Second (higher is better obviously):
Some sources:
Web Server Performance Comparison
Caveat: Remember, Apache supports a larger toolbox of things it can do immediately and is probably the most compatible across all web software out there today. Furthermore, most websites really don't get so many concurrent hits as to gain large performance/memory benefits from Lighttpd or Nginx – but you can check them out to see if they work best for your needs.
--
Nginx's popularity continues to rise, largely I believe due to it's simplicity:
More and more of the topg websites are using Nginx:
Nginx vs. Apache: Our View of a Decade-Old Question
--
So what I did is see how hard it would be to install a wordpress blog under the /blog/ URL. It wasn't too hard actually, in fact the hardest part was getting SSL to run, which took about 10 mins.
First thing you'll need to know is where you'll be storing your html files for your website (you know the exact location where you plan on putting your wordpress). Once you know that open the commandline and visit the /etc/nginx/sites-available/ folder and edit the example.com.conf file (might be example.com). You might also have to delete the "default" file cause that shit will cause problems and a permanent "Welcome to Nginx" screen.
Example of my example.com.conf file:
Code:
server {
ssl on;
listen 80;
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/Nginx/ssl/Nginx.crt;
ssl_certificate_key /etc/Nginx/ssl/Nginx.key;
return 301 $scheme://www.example.com$request_uri;
}
server {
server_name www.example.com;
listen 80;
listen 443 ssl;
ssl_certificate /etc/Nginx/ssl/Nginx.crt;
ssl_certificate_key /etc/Nginx/ssl/Nginx.key;
ssl on;
access_log /var/log/Nginx/example.com.access.log;
error_log /var/log/Nginx/example.com.error.log;
root /var/www/example.com/htdocs;
index index.php index.html index.htm index.shtml;
location / {
index index.php index.html index.htm index.shtml;
}
location /blog/ {
try_files $uri $uri/ /blog/index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
}
^^ Now this forces SSL on, and that's a problem if you are using a self signed certificate like I am cause it will create warnings. to Turn off SSL, comment our the "ssl on" lines "#ssl on;" as well as the last two fastcgi_parm lines at the end there.
Now obviously being a newbie at Nginx I welcome ALL and every criticism as I continue figuring out Nginx. But from the above code, SSL is enabled, Wordpress runs on /blog/ with custom permalinks enabled, and that's that.
Remember there is no .htaccess mates, but there sort of is, but that's way is retarded cause it's just mudding up the speed.
Another thing to note, this forces non-www to 301 www. That's why there are two sections. The first section is to 301 anything to the correct scheme ($scheme = http or https) to the www version of that same scheme and add the url you were going to ($request_uri).
Obviously when we get some sexy SSL going we'll replace this self signed certificate with our own, but for now that's the current setup as we continue building the platform. If I find corrections or anything else I'll keep coming back and adding them to this thread. If anyone has any other Nginx tricks feel free to drop them in.
Also, a ton of trial and error made this nginx + wordpress possible, this book also came in handy:
I can't wait to have Nginx meet Redis...