phpBB 3.2 nginx config

Hi I’m fairly new (again) to phpBB forum, why? because I never use it since 14years ago.

For those who are looking for the nginx configuration, i’m sharing mine below

I’ve omitted the part of the installer location block.

To those who will be installing from scratch, you will need to add the installer location block, please google it.

Please take note as well on the “# rewrite for SEO PLugin” part , .

rewrite ^/(.*)-f([0-9]*)/(.*)-t([0-9]*)-s([0-9]*).html /viewtopic.php?f=$2&t=$4&start=$5&$query_string last;
rewrite ^/(.*)-f([0-9]*)/(.*)-t([0-9]*).html /viewtopic.php?f=$2&t=$4&$query_string last;
rewrite ^/(.*)-f([0-9]*)/index-s([0-9]*).html /viewforum.php?f=$2&start=$3&$query_string last;
rewrite ^/(.*)-f([0-9]*)/ /viewforum.php?f=$2&$query_string last;
rewrite ^/(.*)-f([0-9]*) /viewforum.php?f=$2&$query_string last;

This is for the requirement for SEO url extension from https://github.com/tas2580/seourls, therefore remove it if you don’t plan to use the extension.

   # The actual board domain.
    server {
        #listen 80;
        server_name yourdomain.com;
        client_max_body_size 20m;

        root /path/to/your/phpbb;

        location / {
           # phpBB uses index.htm
           index index.php index.htm index.html;
           # rewrite for SEO PLugin
           rewrite ^/(.*)-f([0-9]*)/(.*)-t([0-9]*)-s([0-9]*).html /viewtopic.php?f=$2&t=$4&start=$5&$query_string last;
           rewrite ^/(.*)-f([0-9]*)/(.*)-t([0-9]*).html /viewtopic.php?f=$2&t=$4&$query_string last;
           rewrite ^/(.*)-f([0-9]*)/index-s([0-9]*).html /viewforum.php?f=$2&start=$3&$query_string last;
           rewrite ^/(.*)-f([0-9]*)/ /viewforum.php?f=$2&$query_string last;
           rewrite ^/(.*)-f([0-9]*) /viewforum.php?f=$2&$query_string last;
           try_files $uri $uri/ @rewriteapp;
        }

        location @rewriteapp {
            rewrite ^(.*)$ /app.php/$1 last;
        }

        # Deny access to internal phpbb files.
        location ~ /(config\.php|common\.php|includes|cache|files|store|images/avatars/upload) {
            deny all;
            # deny was ignored before 0.8.40 for connections over IPv6.
            # Use internal directive to prohibit access on older versions.
            internal;
        }

        # Pass the php scripts to fastcgi server specified in upstream declaration.
        location ~ \.php(/|$) {
            # Unmodified fastcgi_params from nginx distribution.
            include fastcgi_params;
            # Necessary for php.
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            try_files $uri $uri/ /app.php$is_args$args;
            fastcgi_pass 127.0.0.1:9000;
        }

        # Deny access to version control system directories.
        location ~ /\.svn|/\.git {
            deny all;
            internal;
        }
    }

How to determine the VMWare ESX Version from commandline Linux.

Simple!

1. Ensure you have dmidecode installed. if not install it, for CentOS (yum install dmidecode).
2. Type in commandline dmidecode and it will throw a list information about your hardware recorded in the BIOS for you. Since you want only the ESX Version, you can filter info by issuing “dmidecode -t bios” (without the quote)
bios
3. just look at “Address”
address
4. You can see from the pic above, I have Address: 0xEA050, compare it on the version mapping below

“0xE8480” = “ESX 2.5”
“0xE7C70” = “ESX 3.0”
“0xE7910” = “ESX 3.5”
“0xE7910” = “ESX 4”
“0xEA550” = “ESX 4U1”
“0xEA2E0” = “ESX 4.1”
“0xE72C0” = “ESXi 5”
“0xEA0C0” = “ESXi 5.1”
“0xEA050” = “ESXi 5.5”

5. so in my case I’m using ESXi 5.5!

That’s it!

Amazon EC2 storage attached Volume size is not same as configured

Newly setting up an Amazon instance was assigned with 30GB yet showing only less?

try checking the partition using df command.

[root@ip-xxxxx centos]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 666M 6.7G 9% /
tmpfs 498M 0 498M 0% /dev/shm
[root@ip-xxxxx centos]# resize2fs /dev/xvda1

then try issuing lsblk to check your total block size

You’ll see from that output what the name of the disk is of your root partition. For example, you probably see something like this:

xvde 202:64 0 30G 0 disk
└─xvda1 202:65 0 8G 0 part /

To make xvda1 use the whole available space from xvda. Here’s how to resize your partition:

fdisk /dev/xvda (the disk name, not your partition) This enters into the fdisk utility.

Choose the following options

u #Change the display to sectors
p #Print info
d #Delete the partition
n #New partition
p #Primary partition
1 #Partition number
2048 #First sector
Press Enter to accept the default
p #Print info
a #Toggle the bootable flag
1 #Select partition 1
w #Write table to disk and exit
Now, reboot your instance: reboot

once it’s back, verify the new disk size: df -h

How to setup gateway Centos 6 commandline

If you’ve just finished setting up your Centos and completed the network configuration from my previous post. You are probably wondering why your internet is down again after you have restarted your VM. Reason is, you probably haven’t setup any gateway yet. To set the gateway you need to open and edit the file with your favorite editor, in my case “vim” editor.

vi /etc/sysconfig/network

add the line

GATEWAY=

then issue an

/etc/init.d/network restart

make sure you are root user.

New VM – Centos no internet?

So you have finally completed setting up your first vm and installed Centos 6 (minimal version) but having problem with internet connection?

We’ll you might hit the same issue as mine. not to worry as you just need to do extra configuration for the network.

Steps:

1. Open this file with your favorite editor for my case im using vim editor

vi /etc/sysconfig/network-scripts/ifcfg-eth0

2. Change the values

ONBOOT=no
NM_CONTROLLED=yes

to

ONBOOT=yes
NM_CONTROLLED=no

Note: some distribution has quote, just follow the quote if yours got.

3. Save and exit the editor

4. restart the network service

/etc/init.d/network restart

5. ping any website and see if internet works.

ping google.com

include_path not working – php centos

Have you been banging your head on the wall for days, trying to figure out why your include_path in php.ini is not workin? and you have tried …

1. restarting your apache/nginx
2. and verified that you are editing correct file
3. and doubled check the phpinfo() and include path is correctly set
4. and tried checking the get_include_path() whether it’s including it at run time?

Well there’s one more thing you haven’t done!

late that i know that this is not a PHP nor apache/nginx issue.

happenss to be an OS issue! for my case im using Centos 6 and i happen to discover from a friend that Centos ships with SELinux. what’s SELinux?? check out here for the explanation => http://www.cyberciti.biz/faq/howto-turn-off-selinux/

You have to disable the SELinux for apache to be able to work outside the public path!

Give it a try!

eclipse mars Unhandled event loop exception

Can’t make your newly downloaded eclipse mars to work?

Are you facing an error “Unhandled event loop exception No more handles” prompt when focusing on the texteditor area of eclipse?

error1

then followed by SWT error asking you to close the workbench?

error2

You are not alone, last time I got this error, some say it’s related to multiple monitor configuration, however for my case I notice it went away after I had closed my Teamviewer application but I the problem is need the Teamviewer on all the time. So after googling around, I manage to find the solution and it was only a simple windows update!

Seems like it’s a windows related bug. after the update eclipse worked, even with my teamviewer is on.

where / what is the root password on mysql 5.7?

If you are facing issue like the root access denied and mysql_secure_installation doesn’t work after fresh install of mysql 5.7

the answer is … it wont work!

Check article from mysql documentation… https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html

to cut the long story … the root password is randomly generated this time for 5.7 and can be found on the log file /var/log/mysqld.log!


A superuser account 'root'@'localhost is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:

shell> sudo grep 'temporary password' /var/log/mysqld.log
Change the root password as soon as possible by logging in with the generated, temporary password and set a custom password for the superuser account:

shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

How to set up nginx load balancer

Load balancer is a very useful feature in distributing incoming traffic to several servers. why would you want to do that?

By splitting load or by redirecting visitors to several active machines in a round robin effect, redundancy is achieved. (this ensures users/visitors doesn’t experience downtime on your server) . The Round Robin algorithm for load balancing sends visitors to one of a set of IPs.

A basic Round Robin feature is fairly easy to implement, it distributes server load without the worry of user experiencing server response time and server downtime. A sample below could help you setup a basic load balancing feature.

First this is you need to have nginx installed.

Setup
1. open you website’s nginx conf file

2. include the upstream module which looks like this:

upstream backend  {
  server vps1.example.com;
  server vps2.example.com;
  server vps3.example.com;
}

3. reference the module in the configuration:

server {
  location / {
    proxy_pass  http://backend;
  }
}

4. Restart nginx

Load Weight
If you have several server of different specs that will be load balanced, and wanting to distribute the user in proportion. Nginx can assign a number specifying the proportion of traffic that should be directed to each server.

A load balanced setup that included server weight can look like this:

upstream backend  {
  server vps1.example.com weight=1;
  server vps2.example.com weight=2;
  server vps3.example.com weight=4;
}

IP Hash
IP hash allows servers to respond to visitors according to their IP address, then sending visitors back to the same server each time they visit (unless the server is down). If a server is not active it will be marked as down. All users that were supposed to connect to the down server will be then directed to an alternate active/alive servers.

upstream backend {
  ip_hash;
  server   vps1.example.com;
  server   vps2.example.com;
  server   vps3.example.com  down;
 }

Max Fails

Max Fail helps instructs nginx to redirect user to a new server with certain conditions met. In the example below I will be sharing 2 basic directives max_fails and fall_timeout.

max_fails – refers to the maximum number of failed attempts to connect to a server should occur before it is considered inactive.
fail_timeout – sets the time during which the specified number of unsuccessful attempts to communicate with the server should happen to consider the server inactive, By default, the parameter is set to 10 seconds. definitions from http://nginx.org/en/docs/http/ngx_http_upstream_module.html

A sample configuration might look like this:

upstream backend  {
  server vps1.example.com max_fails=3  fail_timeout=15s;
  server vps2.example.com weight=2;
  server vps3.example.com weight=4;
}

Error Trapping – Err Number- Visual Basic for Applications

On Error Statement

The On Error statement causes Visual Basic for Applications to start or stop error trapping.
The On Error statement also specifies a set of statements to execute if an error is encountered.

Err Function

The Err function returns the number of the error encountered.

Msgbox “The most recent error number is ” & Err & _
“. Its message text is: ” & Error(Err)

The following table contains a list of the trappable error codes you may encounter when you use the Err function.

Error code Error message
———- ————-
3 Return without GoSub
5 Invalid procedure call
6 Overflow
7 Out of memory
9 Subscript out of range
10 Duplicate definition (versions 5.0 and 7.0)
10 This array is fixed or temporarily locked (version97)
11 Division by zero
13 Type mismatch
14 Out of string space
16 String formula too complex (versions 5.0 and 7.0)
16 Expression too complex (version 97)
17 Can’t perform requested operation
18 User interrupt occurred
20 Resume without error
28 Out of stack space
35 Sub or function not defined (versions 5.0 and 7.0)
35 Sub, function, or property not defined (version 97)
47 Too many DLL application clients (version 97)
48 Error in loading DLL
49 Bad DLL calling convention
51 Internal error
52 Bad file name or number
53 File not found
54 Bad file mode
55 File already open
57 Device I/O error
58 File already exists
59 Bad record length
61 Disk full
62 Input past end of line
63 Bad record number
67 Too many files
68 Device unavailable
70 Permission denied
71 Disk not ready
74 Can’t rename with different drive
75 Path/File access error
76 Path not found
91 Object variable not set (versions 5.0 and 7.0)
91 Object variable or With block variable not set
(version 97)
92 For Loop not initialized
93 Invalid pattern string
94 Invalid use of Null
95 User-defined error (versions 5.0 and 7.0 only)
298 System DLL could not be loaded (version 97)
320 Can’t use character device names in specified file names
(version 97)
321 Invalid file format (version 97)
322 Can’t create necessary temporary file (version 97)
323 Can’t load module; invalid format (versions 5.0 and 7.0)
325 Invalid format in resource file (version 97)
327 Data value named was not found (version 97)
328 Illegal parameter; can’t write arrays (version 97)
335 Could not access system registry (version 97)
336 ActiveX component not correctly registered (version 97)
337 ActiveX component not found (version 97)
338 ActiveX component did not correctly run (version 97)
360 Object already loaded (version 97)
361 Can’t load or unload this object (version 97)
363 Specified ActiveX control not found (version 97)
364 Object was unloaded (version 97)
365 Unable to unload within this context (version 97)
368 The specified file is out of date. This program requires
a newer version (version 97)
371 The specified object can’t be used as an owner form for
Show (version 97)
380 Invalid property value (version 97)
381 Invalid property-array index (version 97)
382 Property Set can’t be executed at run time (version 97)
383 Property Set can’t be used with a read-only property
(version 97)
385 Need property-array index (version 97)
387 Property Set not permitted (version 97)
393 Property Get can’t be executed at run time (version 97)
394 Property Get can’t be executed on write-only property
(version 97)
400 Form already displayed; can’t show modally (version 97)
402 Code must close topmost modal form first (version 97)
419 Permission to use object denied (version 97)
422 Property not found (version 97)
423 Property or method not found
424 Object required
425 Invalid object use (version 97)
429 ActiveX component can’t create object or return
reference to this object (version 97)
430 Class doesn’t support OLE Automation
430 Class doesn’t support Automation (version 97)
432 File name or class name not found during Automation
operation (version 97)

438 Object doesn’t support this property or method
440 OLE Automation error
440 Automation error (version 97)
442 Connection to type library or object library for remote
process has been lost (version 97)
443 Automation object doesn’t have a default value
(version 97)
445 Object doesn’t support this action
446 Object doesn’t support named arguments
447 Object doesn’t support current locale settings
448 Named argument not found
449 Argument not optional
449 Argument not optional or invalid property assignment
(version 97)
450 Wrong number of arguments
450 Wrong number of arguments or invalid property assignment
(version 97)
451 Object not a collection
452 Invalid ordinal
453 Specified DLL function not found
454 Code resource not found
455 Code resource lock error
457 This key is already associated with an element of this
collection (version 97)
458 Variable uses a type not supported in Visual Basic
(version 97)
459 This component doesn’t support events (version 97)
460 Invalid clipboard format (version 97)
461 Specified format doesn’t match format of data
(version 97)
480 Can’t create AutoRedraw image (version 97)
481 Invalid picture (version 97)
482 Printer error (version 97)
483 Printer driver does not support specified property
(version 97)
484 Problem getting printer information from the system.
Make sure the printer is set up correctly (version 97)
485 Invalid picture type (version 97)
486 Can’t print form image to this type of printer
(version 97)
735 Can’t save file to Temp directory (version 97)
744 Search text not found (version 97)
746 Replacements too long (version 97)
1000 Classname does not have propertyname property
(versions 5.0 and 7.0)
1001 Classname does not have methodname method
(versions 5.0 and 7.0)
1002 Missing required argument argumentname
(versions 5.0 and 7.0)
1003 Invalid number of arguments (versions 5.0 and 7.0)
1004 Methodname method of classname class failed
(versions 5.0 and 7.0)
1005 Unable to set the propertyname property of the classname
class (versions 5.0 and 7.0)
1006 Unable to get the propertyname property of the classname

class (versions 5.0 and 7.0)
31001 Out of memory (version 97)
31004 No object (version 97)
31018 Class is not set (version 97)
31027 Unable to activate object (version 97)
31032 Unable to create embedded object (version 97)
31036 Error saving to file (version 97)
31037 Error loading from file (version 97)