LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-10-2015, 10:19 AM   #1
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Rep: Reputation: Disabled
The best way of setting up compression / caching on Apache / CentOS 7


I am fairly new to Linux and I've been running a website on a self-managed hosting for around a month and a half. I just realized that I would need to set up gzip compression for better performance results.

So far I've been reading that there are two ways of doing it (mod_deflate ad mod_gzip) and that there is also other things like "Web caching strategies", things like this. I would like to find out what would be the best and most standard way of doing this as of now / 2016. What would I look into, what would I need to research, and how would I set it up? I've been also reading to cache only JavaScript, CSS and HTML files, as images and other types of content are already compressed. Would I not want to compress something like php files too?

I read around 10 the best books about Linux (including a separate one about Apache Web server) and it was not described there. Also, would there be any other things like this that I could look into that I may not be aware of, at this point (like I was not aware of this caching turned off for over a month)?

Thanks.
 
Old 12-10-2015, 03:18 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Maybe you've posted this in one of your earlier threads (do link there then I'd say) but none posted here, so:
- How many hosts do you currently use?
- What resources do you currently use (CPU, RAM, disk, bandwidth)?
- What's the OS and version?
- What software do you run (Apache, Nginx, Varnish, Redis, Elastic Search, Mariadb, PostGreSQL, Kibana, etc, etc)?
- What website software do you use?
- What kind of web site(s) or services do you provide?
- How many visitors do you have at peak time?
- Would you have any money to spend (from ad revenue perhaps)?
- What have you optimized already?
 
Old 12-10-2015, 04:03 PM   #3
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Original Poster
Rep: Reputation: Disabled
1) I have just one hosting account from ovh.com
2) It will be around 1 core / 2 threads, 1.8 GHz+, 2GB of RAM, 500GB of disk space, 100 Mbps Network, dedicated hosting plan.
3) The OS is the latest release of CentOS7
4) Software is Apache and Maria DB, nothing else on there. It is a fresh and clean installation.
5) Website software is picture website script, Wordpress, vBulleting forum, pinboard website, and I will add video sites (something like YouTube.com, but a lot smaller, like 10,000 vids max to begin with, and video site will be added later on, so it would not really count for what is needed here, video may get more complicated as far as this too, so I will be looking into this later on).
6) picture and video sites, forum, pinboard
7) I dont have a lot of visitors now, but I am planning to grow it. It is / will be something like 1,500 people a day, lets say. Like 3-4 people at the same time, max, probably.
8) I dont want to spend any money on this. I learned Linux to save on hosting (I actually get a good dedicated server for less than shared hosting plan that I used to have), and I would like to figure out the best way to do it for free, for right now. Like I said, this is slow sites, not a lot of traffic, no income...
9) I have not optimized anything yet. I am planning to do this gzip compression, but as far as I've been looking there is more things involved into this (like caching / compressing strategy, something like this). I've heard about Varnish cache before, I am not sure whether I should install it. The picture gallery php script that I am using is doing some caching too. This is the only site that I have there right now, but I will be adding more.
 
Old 12-11-2015, 02:24 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Thanks for responding in detail, appreciated.

Quote:
Originally Posted by AdultFoundry View Post
1) I have just one hosting account from ovh.com
2) It will be around 1 core / 2 threads, 1.8 GHz+, 2GB of RAM, 500GB of disk space, 100 Mbps Network, dedicated hosting plan.
3) The OS is the latest release of CentOS7
4) Software is Apache and Maria DB, nothing else on there. It is a fresh and clean installation.
So an average basic hosting plan. OK.

Be aware that:
- OVH, like Hetzner and other such providers are cheap for a reason. Ensure you know the reasons and if that fits your ideas.
- CentOS, like RHEL, caters to a different market than other Linux distributions, which shows for example in its longevity of supported releases, Quality Assurance and patch practices and the amount of packages in the distro repo. The latter can be partially overcome by adding EPEL and such 3rd party repos but unless you have specific reasons to use CentOS 7 I'd rather suggest say Debian 8.
- any just installed OS, network stack (and anything running in the web stack) requires hardening. See your distribution of choices documentation new user, admin and security sections first then particular product vendors documentation (web server, database server etc, etc).
- Ensure everything you install is updated when (security) updates become available.
- ensure you partition the machine like you would any server: have a separate /tmp (temp files obviously) and /var (logs) and preferably a separate partition where databases and uploads reside.
- anything needs processing which in turn requires memory. Some daemons won't be easy to fixate but at least your MySQL database is. With 2 GB that'll be a trade-off but realize that everything you can put and keep in RAM will be quicker due to caching. Also see mysqltuner output. And also understand the different ways processes offer caching from the web server to MySQL to Zend to daemons like Varnish and Redis.
- use VirtualBox or any other virtualization solution in another location (home?) and practice / develop / stage / update there first. Always restrict access to what you test.
- Create a fitting automated backup scheme (and test it! maybe in a virtual machine?).


Quote:
Originally Posted by AdultFoundry View Post
5) Website software is picture website script, Wordpress, vBulleting forum, pinboard website, and I will add video sites (something like YouTube.com, but a lot smaller, like 10,000 vids max to begin with, and video site will be added later on, so it would not really count for what is needed here, video may get more complicated as far as this too, so I will be looking into this later on).
6) picture and video sites, forum, pinboard
7) I dont have a lot of visitors now, but I am planning to grow it. It is / will be something like 1,500 people a day, lets say. Like 3-4 people at the same time, max, probably.
- Since you'll be running WordPress ensure you know the WordPress Codex and especially the part about getting your WP install hacked.
- Don't go overboard immediately adding all sorts of themes and plugins to WordPress: stabilize the system first.
- Run Firefox with Firebug on your website and follow its recommendations as best as you can.
- Since you have much static files but little RAM you should look into using a CDN (best option) or a strategy that will serve PHP (Apache?) and static files differently (Nginx?) or a strategy that at least serves the most requested static files from cache.
- Accept recommendations but never trust people on their word alone: always start with your baseline benchmark and always test changes so you can actually confirm they work for you.


G/L. Any questions? Ask!
 
1 members found this post helpful.
Old 12-11-2015, 05:43 AM   #5
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Original Poster
Rep: Reputation: Disabled
Thanks for the info, I will go over all the topics listed. I read quite a lot of good books, but I am probablt still not aware of a lot of things (on a "deeper level") and the worst thing would be to mess something up (I want to do it all by myself to save on hosting, and then waste like 6 or 12 months of full time work because of something that I did not know, this sounds like it could be a possibility at this point).

a) What makes OVH.com / SoYouStar.com different than more expensive hosts? I know that it is based on virtualization and may not be able to modify a kernel (I heard that mentioned before somewhere), but I may not need it anyway.
b) So would I just do the mod_deflate and leave it as is? Or would I look into other things like Varnish cache (I heard about it before, it was used as one of my previous jobs, but I am not familair with it at all). I guess I will read several articles that I have in my bookmarks, and I will go from there:

https://www.digitalocean.com/communi...te-on-centos-7 (How to install and configure mod_deflate on CentOS7)
https://www.digitalocean.com/communi...ing-strategies (Web caching basics terminology http headers and caching strategies)
https://www.digitalocean.com/communi...ng-on-centos-7 (How to configure apache content caching on CentOS7)

Last edited by AdultFoundry; 12-11-2015 at 05:44 AM.
 
Old 12-11-2015, 05:58 AM   #6
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Original Poster
Rep: Reputation: Disabled
@UnSpawn - I already got some info that is needed for this, but maybe you could give me some keywords of things that I could look into before doing something like this. I want to move my sites to https://www.kimsufi.com/us/en/, probably the $6.99 plan and then the $13.99 one (nothing more than this at this point, then possibly one of the plans here - https://www.soyoustart.com/us/essential-servers/).

This will be CentOS7 based, the latest release (I know that you mentioned Debian, but I will stick to this; I want to go the most good and standard way, so to speak). I have some websites that are like 3 years old, and they already have some value and I would not want to mess anything up. I would like to have the sites there, and possibly move them over somewhere else, or do whatever may be needed for this.

What things would I look into / research / be aware of, in order for it to be good and work, and dont mess anything up? Some kind of keywords that I could put into google would be the best, as I am already familiar with Linux, but I will be working on getting to the next level, as far as working on this, practially. I will be rsyncing database and files from one hosting plan to another, setting up good backup strategy (detailed, good, taking into consideration that I may mess something up), setting up an email server (this should not be hard), and then isntalling more advanced video site scripts (like xxx tube sites like PornHub.com).

Reading books is one thing, but doing advanced server administration (like video sites lets say) is another thing. I dont have a good perspective of this, so if somebody could give me some angles and keywords to research, this will be very good. I will ready the manual pages mentioned above, and so on, but there may be more... I already installed some log monitoring tools (it sends me an email once per day) and a program that records the state of the server once per hour through cron (I have it running, but I did not look into this yet). I have some time now, so I could learn all these things...

Last edited by AdultFoundry; 12-11-2015 at 06:42 AM.
 
Old 12-12-2015, 07:48 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Quote:
Originally Posted by AdultFoundry View Post
Thanks for the info, I will go over all the topics listed. I read quite a lot of good books, but I am probablt still not aware of a lot of things (on a "deeper level") and the worst thing would be to mess something up (I want to do it all by myself to save on hosting, and then waste like 6 or 12 months of full time work because of something that I did not know, this sounds like it could be a possibility at this point).
That's why I suggested you set up virtualization at home or work to safely practice getting the skills you need and test procedures.


Quote:
Originally Posted by AdultFoundry View Post
a) What makes OVH.com / SoYouStar.com different than more expensive hosts?
Not a question for me: your decision to do research, ask them questions and decide.


Quote:
Originally Posted by AdultFoundry View Post
b) So would I just do the mod_deflate and leave it as is? Or would I look into other things like Varnish cache
Adding gzip compression is almost always a Good Thing. I don't get the "leave it as is" part though? If it was meant to say "I don't have to research further for optimal settings" then that's your decision. Personally I'd rather try to see what stuff means (see the Apache documentation mod_deflate page) so I can make informed decisions and be able to troubleshoot things more easily later on.


Quote:
Originally Posted by AdultFoundry View Post
This will be CentOS7 based, the latest release (I know that you mentioned Debian, but I will stick to this; I want to go the most good and standard way, so to speak).
There's nothing wrong with using CentOS 7 if its application and library versions and configuration works with all your web stack applications all. (Another reason for using virtualization to test and ensure.) If you never had any application, library or configuration conflicts then good, but if you never came across any while doing admin work then you'll probably learn some more on the fly...


Quote:
Originally Posted by AdultFoundry View Post
I have some websites that are like 3 years old, and they already have some value and I would not want to mess anything up.
What does "mess anything up" mean? No outages? No downtime? Working with and migrating deprecated themes, plugins and software versions from one host to another and expect things to work automagically? Every project starts with planning and proper planning starts with a thorough analysis of the current situation, testing the new situation (virtualization again, not going to repeat this anymore ;-p) and fixing or mitigating any problems.


Quote:
Originally Posted by AdultFoundry View Post
I would like to have the sites there, and possibly move them over somewhere else, or do whatever may be needed for this.
Sure, once you've migrated things, learn from mistakes and get the hang of things you're free to migrate anywhere you want.


Quote:
Originally Posted by AdultFoundry View Post
What things would I look into / research / be aware of, in order for it to be good and work, and dont mess anything up? Some kind of keywords that I could put into google would be the best, as I am already familiar with Linux, but I will be working on getting to the next level, as far as working on this, practially. I will be rsyncing database and files from one hosting plan to another, setting up good backup strategy (detailed, good, taking into consideration that I may mess something up), setting up an email server (this should not be hard), and then isntalling more advanced video site scripts (like xxx tube sites like PornHub.com).

Reading books is one thing, but doing advanced server administration (like video sites lets say) is another thing. I dont have a good perspective of this, so if somebody could give me some angles and keywords to research, this will be very good. I will ready the manual pages mentioned above, and so on, but there may be more... I already installed some log monitoring tools (it sends me an email once per day) and a program that records the state of the server once per hour through cron (I have it running, but I did not look into this yet). I have some time now, so I could learn all these things...
Not sure what I can help with here. Admin tasks usually involve periodic updating of the OS and applications, checking backups don't fail, checking logs for security incidents and errors and fixing those, keeping a tab on server performance and fixing that...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up SSD caching enkrypted Linux - Server 1 12-08-2013 05:08 AM
[SOLVED] xz 9'th level of compression as system-wide setting Mr. Alex Linux - Software 1 05-25-2012 09:11 AM
Centos 6.2 revert Apache web setting to default tbaror Linux - Newbie 1 05-02-2012 01:14 PM
issues with setting up apache, fcgid, php on CentOS ppostma1 Linux - Server 8 02-03-2012 04:16 PM
Setting up caching DNS tarballedtux Linux - Networking 2 03-21-2002 10:48 PM


All times are GMT -5. The time now is 08:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration