Jump to content

I need some tips on setting up VPS


Recommended Posts

I would like some advice on setting up a VPS. I think I use Debian Squeeze 6 + nginx + mysql + phpmyadmin and I don't know if it's enough? It should be something to work well IPB 3.3.2 ? Suppose we choose nginx, I would like someone to tell me how to configure the site or set configuration site to function properly FURLs and htaccess? For example, I studied a little internet and got to the that nginx conf file:


server {

	 listen 80;

	 server_name www.mydomain.com mydomain.com;

	 root /var/www/www.mydomain.com/public/;

	if ($http_host != "www.mydomain.com") {

				 rewrite ^ http://www.mydomain.com$request_uri permanent;

	 																				 }

	 index index.php index.html;

location = /favicon.ico {

			 log_not_found off;

			 access_log off;

	 										 }

	 location = /robots.txt {

			 allow all;

			 log_not_found off;

			 access_log off;

	 										 }

	 # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!

	 location ~* .(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(.php)?|xtmpl)$|^(..*|Entries.*|Repository|Root|Tag|Template)$|.php_ {

			 deny all;

	 }

	 # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).

	 location ~ /. {

			 deny all;

			 access_log off;

			 log_not_found off;

	 						 }

	 location ~* .(jpg|jpeg|png|gif|css|js|ico)$ {

			 expires max;

			 log_not_found off;

	 																				 }

	 location ~ .php$ {

			 try_files $uri =404;

			 include /etc/nginx/fastcgi_params;

			 fastcgi_pass 127.0.0.1:9000;

			 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

	 								 }

}


It's good (or secure) for host IPB 3.3.2 with IP Nexus, Content, Galllery, Blog, the configuration file above?

Link to comment
Share on other sites

  • Replies 112
  • Created
  • Last Reply

I run 3.3 on exactly that setup, though I add APC also for caching and have IPB use APC for its caching.

The VPS is a 1GB/2GB OpenVZ VPS with very fast disk (300MB/sec or so plus SSD cache for the node - buyvm rocks :-)

My nginx.conf - there's an example.com redirect, an https config, and then an http config:


server {

listen 80;

server_name example.com;

rewrite ^/(.*) http://www.example.com/ permanent;

}


server {

server_name www.example.com;

listen 443 ssl;

ssl_certificate /etc/ssl/www.example.com/www.example.com.combined.crt;

ssl_certificate_key /etc/ssl/www.example.com/www.example.com.key;

access_log /web/www.example.com/logs/access.log;

error_log /web/www.example.com/logs/error.log;


# set to match php.ini post_max_size parameter or you'll get 413 errors when uploading images or attachments

client_max_body_size 20M;


# Deny access (403) access to all perl or php scripts in certain locations.

location ~* /(?:cache|hooks|public/style_css|public/style_images|uploads)/.*\.(?:pl|php[345]*)$ {

return 403;

}


# Deny access (403) to all .ht{passwd|access|etc} files

location ~* /\.ht.*$ {

deny all;

}


# fastcgi

location ~ \.php$ {

fastcgi_split_path_info ^(.+\.php)(.*)$;

include /etc/nginx/fastcgi_params;

fastcgi_pass unix:/var/run/php-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /web/www.example.com/html$fastcgi_script_name;

# if you want htaccess

# auth_basic "example Dev Team";

# auth_basic_user_file /web/www.example.com/users/dev.users;

}


# main definition

location / {

root /web/www.example.com/html;

index index.php index.html;

try_files $uri $uri/ /index.php;

if (!-e $request_filename) {

rewrite . /index.php last;

}


# if you want htaccess

# auth_basic "example Dev Team";

# auth_basic_user_file /web/www.example.com/users/dev.users;

}

}


server {

server_name www.example.com;

listen 80;

access_log /web/www.example.com/logs/access.log;

error_log /web/www.example.com/logs/error.log;


# set to match php.ini post_max_size parameter or you'll get 413 errors when uploading images or attachments

client_max_body_size 20M;


# Deny access (403) access to all perl or php scripts in certain locations.

location ~* /(?:cache|hooks|public/style_css|public/style_images|uploads)/.*\.(?:pl|php[345]*)$ {

return 403;

}


# Deny access (403) to all .ht{passwd|access|etc} files

location ~* /\.ht.*$ {

deny all;

}


# fastcgi

location ~ \.php$ {

fastcgi_split_path_info ^(.+\.php)(.*)$;

include /etc/nginx/fastcgi_params;

fastcgi_pass unix:/var/run/php-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /web/www.example.com/html$fastcgi_script_name;

# if you want htaccess

# auth_basic "example Dev Team";

# auth_basic_user_file /web/www.example.com/users/dev.users;

}


# main definition

location / {

root /web/www.example.com/html;

index index.php index.html;

try_files $uri $uri/ /index.php;

if (!-e $request_filename) {

rewrite . /index.php last;

}


# if you want htaccess

# auth_basic "example Dev Team";

# auth_basic_user_file /web/www.example.com/users/dev.users;

}

}

My my.cnf...I think the debian my.cnf already turns off innodb:


symbolic-links=0

key_buffer_size = 64m

query_cache_size = 200m

table_cache = 1024

thread_cache = 16

tmp_table_size = 40m

max_heap_table_size = 40m

innodb_buffer_pool_size = 0

open-files-limit = 65535


My pool config for php-fpm:


[www]

listen = /var/run/php-fpm.sock

listen.backlog = 4096

pm = dynamic

pm.max_children = 30

pm.start_servers = 8

pm.min_spare_servers = 8

pm.max_spare_servers = 30

pm.max_requests = 500

access.format = %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%

request_terminate_timeout = 60s

request_slowlog_timeout = 10s

slowlog = /var/log/$pool.log.slow

Link to comment
Share on other sites

Thanks. A very good advice.

By the way, where better to upload web pages or my IPB Suite:

  • srv / www / mydomain.com / web
  • var / www / mydomain.com / web
  • home / public_html / mydomain.com / web

LATER EDIT:
Please, I want to tell me someone, let's say I installed Debian Squeeze minimal version on VPS with 1Gb RAM and 4Gb RAM burst, you which recommend me, to run both update command:

apt-get update and apt-get upgrade

or just

apt-get update

?
Link to comment
Share on other sites

Not to offend, but these are fairly elementary questions. If you don't have a systems administration background, you may wish to use a managed service provider who will assist you with configuration and administration.

Failing that, look in the Linode Library for a lot of good info.

As a side note...1GB RAM/4GB burst would be me uncomfortable...that's a pretty extreme ratio.

Link to comment
Share on other sites

I read library linode but I have not cleared, that's why I asked above. And yes, I'm a newbie VPS but in the last month I learned quite a lot. I have to clarify some issues, some quite simple, but remained less clear to me. For this reason I thought to ask here, that after having studied various online tutorials.

I ask the commands apt-get update and apt-get upgrade, because, for example if I run the first command, RAM increases from 8...9Mb to about 70MB ... and if I run and the second command, already reaches 280Mb. And know what the second command mean. This command installs many additional applications, such as 'libpcre' or 'gnu', and many others. Of course, I can install these add-ons library separately, but I do not think I need all, right? So, I could earn some RAM! For this reason I asked if it's to execute both commands or not.

Regarding the ratio of guaranteed RAM and burst RAM. Indeed, I do offer webhosting. I suspected as much SWAP not help me, because from what I read, when website starts to use swap RAM, that web site begin to be accessed increasingly more difficult. But as I said before, that looks like webhosting package.

Link to comment
Share on other sites

  • 2 weeks later...

Finally I chose a configuration Apache 2 and Debian Squeeze 6. I don't know if it is the best choice but I see moving well my website on 1Gb RAM and 4GB SWAP (with 2 cores of CPU Xenon E5140). For example, now I have 40 user online and usage RAM is only 402Mb. By the way, how many ipb connections you think can handle that hardware configuration?

And how I can implement in the config file apache, the next code nginx (or how to adapt):

# Deny access (403) access to all perl or php scripts in certain locations.

location ~* /(?:cache|hooks|public/style_css|public/style_images|uploads)/.*.(?:pl|php[345]*)$ {

return 403;

}



??

Link to comment
Share on other sites

You must take note that a VPS will never always give you the same resource day in day out, You always get someone on the box who would affect you.

Also the burst is not always there and you should never rely on it. To be honest I would never get a VPS, For the money you spend on what they advertise a XEON with 2GB memory is not what you actually get.. Those CPU's are limited and many other things are to including the connection, See they say 100MB/s yet if that server has no limits and someone decides to put a seedbox on there then your connection becomes unstable which causes other scripts to get back logged.

If I had no option but to get a VPS, Choose XEN and not open VZ.

Open VZ VPS = Unlimited users on the machine.
Xenx VPS are usually set to 50 accounts so you have a much greater chance of your website staying online and functioning better.

I do not mean to sound nasty in any way and I only intend to help but the main thing is if you want a stable VPS and get it optimized, Get off OPEN VZ and get on XEN and start there otherwise you will always encounter issues from a fault what will not be caused by yourself.

Link to comment
Share on other sites

yeah I am on an openvz right now ONLY because the owner is very meticulous about not loading it and also is very proactive about making sure nobody hogs stuff.
xen is, IMHO, better route to go on vps....which is why my node is getting migrated to xen in few days LOL

Link to comment
Share on other sites


You must take note that a VPS will never always give you the same resource day in day out, You always get someone on the box who would affect you.




"always"?

Also the burst is not always there and you should never rely on it. To be honest I would never get a VPS, For the money you spend on what they advertise a XEON with 2GB memory is not what you actually get.. Those CPU's are limited and many other things are to including the connection, See they say 100MB/s yet if that server has no limits and someone decides to put a seedbox on there then your connection becomes unstable which causes other scripts to get back logged.




A good provider monitors the network and it's easy enough to find providers that do not allow torrenting. Most providers cap or terminate resource abusers.


If I had no option but to get a VPS, Choose XEN and not open VZ.



Open VZ VPS = Unlimited users on the machine.


Xenx VPS are usually set to 50 accounts so you have a much greater chance of your website staying online and functioning better.




"Usually set to 50 accounts"? Where do you get this information?

There is some truth in the fact that Xen generally provides a better experience, but that's only because it's more difficult to oversell. The main determining factor in the user's experience is the quality of the provider, not the hardware. A good provider makes all the difference. I have used IPB under both Xen and OvZ and it works fine under each.


I do not mean to sound nasty in any way and I only intend to help but the main thing is if you want a stable VPS and get it optimized, Get off OPEN VZ and get on XEN and start there otherwise you will always encounter issues from a fault what will not be caused by yourself.




You simply cannot make categorical statements like this. There is high-performance OvZ out there and junky Xen.

BTW, KVM actually is probably the best virtualization system at the moment.
Link to comment
Share on other sites




"Usually set to 50 accounts"? Where do you get this information?





I worked in many DC's It's default standard for XEN on setup unless they are greedy, The ones we do at ( ** No Name ** ) are limited to 50 per box, The ones who usually choose XEN knows a little on how linux works and can manage it, The ones who go on OPEN VZ are probably less experienced, Hense the reason of the $5.00 a month option for such amount of memory and GHzzzz......

When you say "You simply cannot make categorical statements like this" , I manage hundreds of servers and it's always OPEN VZ with the issues from many different providers, Again this is my opinion, some listen and some do not but it's a community / section where people take note of each others posts and take into consideration that someone could actually be right or wrong and they either stick with them or learn from the small mistakes in which we all do from time to time.
Link to comment
Share on other sites

OpenVZ: Less overhead than Xen
Xen: Hard to oversell (thus less likely to end up in a cheap jam-packed host), more flexible.

They have pros and cons...
If the provider has your choice of os, jams same number of people per box, etc, it really doesn't matter which of the two controllers they use.

You can always ask the provider how many users they usually fit per box prior to signing up. Alternatively, you can ask if these resources are dedicated and not over sold.
There are even VPS providers who literally gives you dedicated resources. 1 cpu core (all yours, no one else will use any of it), X amount of ram (ditto) and even 1 single hard drive that's dedicated to you (unless u buy more ofc...). These are completely free of abuse from others and the question of xen vs openvz is irrelevant.

Link to comment
Share on other sites

By the way, Linux-VServer from here is the same thing with Open VZ?

Then, I found something. In the last hours I monitor CPU usage on VPS to perform certain activities on IPB suite. My website has home page the IP Content where I created a few pages. Suppose that at some point access forum. When browsing the forum, let's say moving from page to page of topics, CPU usage is low, usually below 15% (1%...15%). But if at some point want to go to the IP Content pages or my home page, then it increases response time (web page loads more slowly) and CPU utilization exceed 40 ... 50% for a short period. I would like to know if there are users who have found this problem? Because I don't think I'm the only one who found this issue!

Link to comment
Share on other sites


By the way, Linux-VServer from

here

is the same thing with Open VZ?



Then, I found something. In the last hours I monitor CPU usage on VPS to perform certain activities on IPB suite. My website has home page the IP Content where I created a few pages. Suppose that at some point access forum. When browsing the forum, let's say moving from page to page of topics, CPU usage is low, usually below 15% (1%...15%). But if at some point want to go to the IP Content pages or my home page, then it increases response time (web page loads more slowly) and CPU utilization exceed 40 ... 50% for a short period. I would like to know if there are users who have found this problem? Because I don't think I'm the only one who found this issue!



1. http://linux-vserver.org/Welcome_to_Linux-VServer.org
There are many virtualization methods beyond xen and openvz. The two are simply the most popular. If you care to see a fuller list...
http://en.wikipedia.org/wiki/Comparison_of_platform_virtual_machines

2. It's hard to say what because we're bringing ip.c into the equation. We don't really know what you're doing with it... Try turning debug level to 1 in your admin cp. It'll show you more stats (at the bottom of your IPB/IPC). It might shed some light. It might not. You can also try running mysqltuner to see if there's any issues with your current setup. It's also possible that you haven't indexed keys properly for ip.c (assuming you have custom content). There's just so many potential reasons. But, the ones listed could be a starting point. Also, when looking at top outputs, it's important to distinguish where specifically and how it uses cpu, not just how much. Does it have high iowait? does it have high software interrupt? etc. top shows all that info and all these things may be affecting or causing your user cpu to increase as well. More usage in cpu seldom mean you're doing more raw calculations.
Link to comment
Share on other sites

Please, can you explain in more detail problems quotes below:


Try turning debug level to 1 in your admin cp. It'll show you more stats (at the bottom of your IPB/IPC). It might shed some light. It might not.


[...]


It's also possible that you haven't indexed keys properly for ip.c (assuming you have custom content).



For example, where in the IPB ACP I can try turning debug level to 1 or how I can indexed ipc keys ?
Link to comment
Share on other sites


Please, can you explain in more detail problems quotes below:



For example, where in the IPB ACP I can try turning debug level to 1


ACP > System Settings > System > General Configuration > Debug level to 1

or how I can indexed ipc keys ?


1. Follow the line before it first. 2. Your question doesn't actually make sense from pure English point. 3. It may not even be relevant and we don't really know until you do #1.
Link to comment
Share on other sites

Excuse my english. I set Debug Level 1, I tried debug 1 + 2, and then in the website footer displays various statistics, such as statistics mysql attached below:
debug mysql.txt
and what should follow the above file for optimize the MySQL ?

On the other hand, is normally occupy more than 100 MB RAM one php5-cgi process ? For example,I have attached below a statistic where you can view the CPU used at a time. It's much, is less, what do you think?
post-115250-0-15505100-1340211619_thumb.

Link to comment
Share on other sites

1. You have lot of inefficient queries being made in your script, some which are even a repeat. I don't know for certain if this is your doing in IP.C, or invision power's own poor programming. But either way, they need to be optimized. This requires a simple re-programming... after learning what it means to be efficient. We can't help you in this regards, other than to say hire a good programmer.

2. Your disk usage is far too high. Likely to due #1 or due to a mix of someone else using too much disk as you are on a VPS.

Alternate way of solving things is to throw more money at the problem by getting yourself SSDs.

Link to comment
Share on other sites


I don't know for certain if this is your doing in IP.C, or invision power's own poor programming.



Issues or deficiencies mentioned above appeared on two different hosts. So, all issues above they came with the upgrade to IPB 3.2.X - 3.3.X. Before that, when I was IPB 3.1.2 or IPB 2.3.6, there was no problem. When I have IPB 3.1.2 - attention on a shared solution, not VPS - I could have a hundred online visitors and only then appeared overload problems. Now, I found that with 40 visitors on a VPS, with new IPB 3.3.3, overload problems are stronger than ever. And another thing, I don't made ​​any changes, even then (when I have IPB 2.3.6 or IPB 3.1.2), even now (with IPB 3.3.3).

Now, if these issues occur, they appear only because new IPB 3.3.X invision power's poor programming (I refer only to the problems of IPB overload/hight load). If new IPB go in this direction, then what? We buy dedicated servers for forums / portals with 50 user online ? This thing don't sound good! And from what I read in this forum are not the only one who said that.

So, if I buy a product as before was optimized correctly, why optimize it now? I mean, you tell me to hire someone to change my / optimize the IPB, I understand well? If so, do not seem right.


2. Your disk usage is far too high. Likely to due #1 or due to a mix of someone else using too much disk as you are on a VPS.


Alternate way of solving things is to throw more money at the problem by getting yourself SSDs.



I noticed this, but it is possible that this may be also due to the control panel? Very little, because when I don't have visitors, CPU and RAM use some normal reach.
Link to comment
Share on other sites

I find it hard to believe that IPB programmed it to behave like this. IPB stand alone rarely uses anymore than 20 queries per page. Certainly is not stupid enough to run same queries repeatedly. But yours has 83. Where is 63 come from? I don't know. It's possible you installed some bad plugins/addons. That is why I had assumed you did something with IPC to cause this.

A control panel such as cpanel can setup scheduled tasks such as backups. When these runs, they can consume a large amount of disk usage. But, control panel causing consistent serious hampering of performance does not exist. As that would mean th control panel is extremely terrible.

Link to comment
Share on other sites

Excuse me, but how you counted 83 queries? And I don't have cpanel, I have ispCP Omega. And are hook-ins that can cause issues? Could a hook out of date? I installed following hook's: Recent Post, Recent Blogs, Recent Download's, Recent Articles, Today's Birthday's, Last Gallery Image, Last Video Files, Last News (from IPC), Last FAQ (from IPC), Board Statistics and Last Users Online (IPC).

Link to comment
Share on other sites

# ./mysqltuner.pl

>> MySQLTuner 1.2.0 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.61-0+squeeze1
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 275M (Tables: 377)
[!!] InnoDB is enabled but isn't being used
[!!] Total fragmented tables: 37

-------- Security Recommendations -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 1d 2h 59m 59s (400K q [4.124 qps], 16K conn, TX: 17B, RX: 161M)
[--] Reads / Writes: 41% / 59%
[--] Total buffers: 290.0M global + 2.7M per thread (151 max threads)
[OK] Maximum possible memory usage: 695.8M (67% of installed RAM)
[OK] Slow queries: 0% (7/400K)
[OK] Highest usage of available connections: 7% (12/151)
[OK] Key buffer size / total MyISAM indexes: 64.0M/91.3M
[OK] Key buffer hit rate: 99.8% (9M cached / 14K reads)
[OK] Query cache efficiency: 60.4% (132K cached / 219K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (12 temp sorts / 7K sorts)
[!!] Temporary tables created on disk: 32% (4K on disk / 13K total)
[OK] Thread cache hit rate: 99% (12 created / 16K connections)
[!!] Table cache hit rate: 6% (195 open / 3K opened)
[OK] Open file limit used: 33% (346/1K)
[OK] Table locks acquired immediately: 99% (312K immediate / 312K locks)

-------- Recommendations -----------------------------------------------------
General recommendations:
Add skip-innodb to MySQL configuration to disable InnoDB
Run OPTIMIZE TABLE to defragment tables for better performance
Enable the slow query log to troubleshoot bad queries
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries without LIMIT clauses
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
tmp_table_size (> 16M)
max_heap_table_size (> 16M)
table_cache (> 196)

I looked in the file my.cnf for variables but I don't find tmp_table_size and max_heap_table_size ?

Link to comment
Share on other sites

In the index page where is it IPC application I found where result those 83 queries (now I have seen it 85 queries). Distribution of queries is the following:

- 7 queries - header and footer;
- 5 queries - IPC board statistics and active user(s);
- 36 queries - IPC right side bar hooks;
- 20 queries - IPC articles
- 6 queries - IP Content Glceasytabs

If I try to access the forum, the total number of queries is 9 (entire forum website).

Now, even with the forum that has those 9 queries, when the number of visitors to the site rises above 50, then show overload problems and the site loads harder. Why? How do you think will improve site access, after I remove those or some queries?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...