Suggestions regarding plan, stack and some practices for a newb

January 16, 2014 3k views
Hello everyone, I recently decided to move away from shared hosting and step into waters of VPS. I have many doubts and things I'm not sure how to do. I have no experience in the fields of maintaining server of my own, but given the community DO has and number of helpful tutorials, I'm feeling really good about this. Ofc, I don't think I will make it without your help. Current website has in average 190k page views and 58k visits per month. No logged in users. - WHAT WILL SERVER BE USED FOR: This is a travel agency's site. They hired me to develop a custom CMS for them. Nothing too fancy, has galleries, guides (articles about destinations), and naturally offes (again articles). As you can guess, it sits on top of PHP and MySQL. At first, CMS would generate a page from DB, thus hitting a DB on each request with 5 to 10 queries. Since articles are not being changed on daily basis, I was suggested to generate a static page of each article and store it in some folder and then just include it (like some sort of cache). That way I would reduce 4-10 queries per page load ending up with 0-2 queries per page load. Is that a good trade/practice? I'm worried that time/speed I get by not hitting the DB might be eaten bi PHP including those files. Anyway, back to topic, there wouldn't be much image processing except occasional on the fly thumbnail creation. I'm using .htaccess to cache static content and redirect all other requests to router.php. It'll have shoutbox so each visitor will hit server every 3s (Speaking of that, would you rather use file to store shoutbox messages or DB, thus hit DB every 3s per visitor?). ATM I can't think of any more information that might be useful about application. I'll add if anything comes to my mind. - oh, I plan on using CloudFlare, although free plan. 1) So, which plan would you suggest me? I'm pretty sure Apache will eat 512MB RAM plan easily. Could I get away with 1GB ? 2) What stack do you recommend? LAMP or LEMP? And why? I'm aware that NGINX consumes less resources, but I keep stumbling upon "nginx is good for static content". What about dynamic? Why do I need FastCGI with NGINX and PHP? I know how to configure virtual hosts on Apache, but it looks confusing on NGINX. Also, as I pointed out, I'm relying on .htaccess, if I pick NGINX, I'll have to learn and translate rules. And setting default error pages in NGINX? I'm also aware that NGINX increases my chances to get away with 1GB :P 3) What OS do you recommend and why? Ubuntu, CentOS? 4) I don't have to explain why I am especially afraid of deploying application to self managed server. Security is really important or I'm in big trouble. What measures do I have to take after I install the stack? Or what else should I install to secure my http and mysql servers? Any suggestions how to optimize them as well? 5) What about server side caching? Do I need it? Does MySQL have it's own caching capabilities or do I have to install something? I'm aware that maintaining own mail server is not a good idea unless you're experienced, so I'll just use shared hosting for that. I know this is a lot of questions, and I will be very grateful on any kind of help. Pointing out to related tutorials is also very welcomed.
4 Answers
well, as you know this is an endless talk and may never be summarized in one or two lines.

you have a lot of choices to go for, but let me start with the web server.

Yes, NGINX is a little faster than Apache. what make use of it really if Nginx+php-fpm is used to have super speed. also you can go for Apache+php-fpm which is really good, too. I believe that Apache consume more RAM in his case compared to Nginx.

I guess WordPress is a very good choice for you because it has a lot of plugins and easy to use.

Ubuntu is considered the most suitable OS for WP.

I guess all others questions have the answers under Ubuntu and WordPress work.

you can try 1GB plan to smooth your work since you have a lot of visits every month.

Good Luck!!
Hi, thanks for responding. I'm not interested in Wordpress, as my client has some "special" requirements regarding backend. Anyway, thanks for suggesting a plan and OS.

Wish you all the best.
1) So, which plan would you suggest me? I'm pretty sure Apache will eat 512MB RAM plan easily. Could I get away with 1GB ?
Apache uses tons of memory, especially when there is a high amount of concurrent users. I would suggest going with nginx instead.
2) What stack do you recommend? LAMP or LEMP? And why? I'm aware that NGINX consumes less resources, but I keep stumbling upon "nginx is good for static content". What about dynamic? Why do I need FastCGI with NGINX and PHP? I know how to configure virtual hosts on Apache, but it looks confusing on NGINX. Also, as I pointed out, I'm relying on .htaccess, if I pick NGINX, I'll have to learn and translate rules. And setting default error pages in NGINX? I'm also aware that NGINX increases my chances to get away with 1GB :P
but I keep stumbling upon "nginx is good for static content".Nginx is good for static content, but not just for static content. It actually serves dynamic pages faster than Apache.
Also, as I pointed out, I'm relying on .htaccess, if I pick NGINX, I'll have to learn and translate rules. Check out https://www.digitalocean.com/community/articles/how-to-migrate-from-an-apache-web-server-to-nginx-on-an-ubuntu-vps.
3) What OS do you recommend and why? Ubuntu, CentOS?
I personally use Ubuntu Server.
4) I don't have to explain why I am especially afraid of deploying application to self managed server. Security is really important or I'm in big trouble. What measures do I have to take after I install the stack? Or what else should I install to secure my http and mysql servers? Any suggestions how to optimize them as well?
Check out https://www.digitalocean.com/community/community_tags/security.
5) What about server side caching? Do I need it? Does MySQL have it's own caching capabilities or do I have to install something?
Try starting off without cache as to not overengineer it and see whether you actually need it or not.

I hope that helps! :]
by Justin Ellingwood
Apache and Nginx are both powerful web servers that can reliably host web content on the internet. While Apache is the currently the most popular web server in the world, Nginx is rapidly gaining converts due to its low resource usage. In this guide, we will discuss how to migrate from Apache to Nginx.
Thanks, Kamal, I appreciate it :)
Have another answer? Share your knowledge.