I have wanting to install nginx to run sarnworld forum for a very long time now. Previously, there were other sites that were on the same machine so finally the past summer I moved sarnworld to its own machine. Now I finally have done it although with a few bumps along the way which I know alot of members probably were irritated by
. I say that because really I don’t need to install anything. The default setting is fine (with apache) because I have alot of resources to throw at the site but as a geek you want to just try to milk more out of your system so I went ahead and did this. Some of the roadblocks that I ran into were because SW was now running on invision forum version 3 which was a bit more picky and had some things which took some work to get it to work on nginx.
These are the road blocks I ran into in order
1.) forum wouldn’t work due to me not including the reflection option in the php compile
2.) nginx had permission problem with the graphics on the forum and the base domain couldn’t load up.
3.) nginx had an issue with the new FURL which uses htaccess so nginx config had to be modified
4.) The wiki also needed a bit of modification on nginx config to work
5.) Ran into a problem in compiling the modules
6.) nginx had 502 errors after loading up the caching modules
First I referenced an old post I made before (SW video site link)
I did the php-fpm install. Edit the php-fpm.conf file and make sure to change the user and group.
Of course on the php compile you should do it your way just make sure you include –enable-fpm and –enable-reflection
./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --disable-debug --enable-pic --enable-inline-optimization --with-xml --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable-memcache --enable-zip --with-pcre-regex --with-mysql --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --without-sqlite --enable-reflection
I then compile nginx in the default folder and modules
Along the way I referenced This Site
But when I ran the pecl command I got this error
ran into the "pecl.php.net is using a unsupported protocal - This should never happen." error
To fix this error I found this link
Found the 2 channels and deleted them
/usr/local/lib/php/.channels/ /usr/share/pear/.channels/
Then I ran
pear update-channels
Now I go onto to install the 3 modules on the other link.
/usr/local/bin/pecl install memcache Build process completed successfully Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so' install ok: channel://pecl.php.net/memcache-2.2.5 configuration option "php_ini" is not set to php.ini location You should add "extension=memcache.so" to php.ini
/usr/local/bin/pecl install apc Build process completed successfully Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so' install ok: channel://pecl.php.net/APC-3.0.19 configuration option "php_ini" is not set to php.ini location You should add "extension=apc.so" to php.ini
I ran into an error on the 3rd module.
/usr/local/bin/pecl install syck-beta checking for syck files in default path... not found configure: error: Please reinstall the syck distribution ERROR: `/tmp/pear/temp/syck/configure' failed
Found the solution on this link.
I followed the instructions.
http://rubyforge.org/frs/?group_id=224&release_id=2202
wget http://rubyforge.org/frs/download.php/4492/syck-0.55.tar.gz
untar, ./configure, make, make install.
ran the command again
/usr/local/bin/pecl install syck-beta configuration option "php_ini" is not set to php.ini location You should add "extension=syck.so" to php.ini
I then edited php.ini and added all the modules
Now I discovered Nginx had permission issue (403 error) with loading up the graphics on the forum. I posted here and here.
I wished I saw the latter post which gave me the correct because it took me a bit of time to figure it out. It was basically a counter intutitive solution. Initially I thought it was php-fpm which was the issue but it was actually nginx. Basically it was the user line that I had to add.
I also had to add extra stuff to get mediawiki to work with nginx. I used this link as a reference.
Here is my nginx config
Make sure you include
user usertim usergroup;
if the files in the domains are owned by the user and group.
On the top of the nginx.conf file
domains part of the config. Note that I had to include both /discuzz and discuzz/ just in case some people include a / at the end. This setting is with FURL enabled with .htaccess in IPB3.
$INFO['use_friendly_urls'] = '1';
server {
listen 80;
server_name www.sarnworld.com;
root /blah/blah;
location / {
index index.php index.html index.htm;
}
# This is your php-fpm section. Replace it accordingly (For example if you decide to run it on a different port).
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /discuzz/ {
index index.php index.htm index.html;
try_files $uri $uri/ /discuzz/index.php?q=$uri;
}
location /discuzz {
index index.php index.htm index.html;
try_files $uri $uri/ /discuzz/index.php?q=$uri;
}
# This is for nginx to deny access to .htaccess file.
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
server_name wiki.sarnworld.com;
root /blah/blah/blah;
location / {
index index.php index.html index.htm;
}
# This is your php-fpm section. Replace it accordingly (For example if you decide to run it on a different port).
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#without this mediawiki wouldn't work
location ~ ^/index.php/(.+) {
rewrite ^/index.php/(.+) /index.php?title=$1 last;
}
# This is for nginx to deny access to .htaccess file.
location ~ /\.ht {
deny all;
}
}I ran into another issue where if i load the APC extension in php.ini, nginx gives a 502 error and everything dies.
I found this thread but it didn’t give me any clues.
Finally I found this thread which let me know that Zend optimizer was conflicting with APC. Great clue. I needed ioncube loaded for some encrypted mod I was using on the forum but I didn’t need zend optimizer so I edited php.ini and commented all lines with zend_extension_ except for the one that loads ioncube. Restarted php-fpm with apc extension loaded and the site wasn’t throwing the 502 errors anymore.
WOOHOO
Now to install memcache and get it to work you need a dependency (libevent). Found link for a reference.
installed memcache according to that and ran using this command.
/usr/local/bin/memcached -u root -d -l 127.0.0.1 -p 11000 -m 128
It runs on port 11000 and uses up to 128 megs of ram and localhost
Now I activate APC and Memcache on sarnworld
edited conf_global.php file in IPB to enable the 2 caching softwares. I had to send a ticket in IPB customer service to ask how to do it. It turned out to be pretty simple as the support is built in.
For APC add in.
$INFO['use_apc'] = '1';
for Memcache
$INFO['use_memcache'] = '1'; $INFO['memcache_server_1'] = 'localhost'; $INFO['memcache_port_1'] = '11000';
According to the IPB tech if you have more the 1 memcache server, just duplicate the last 2 lines, increasing the server and port numbers.. server_2, server_3, etc…
Now to get into APC settings in detail I found this link for a reference.
edit php.ini and I added these entries.
[apc] apc.enabled = 1 apc.shm_segments = 1 apc.shm_size = 30 apc.optimization = 0 apc.ttl = 7200 apc.user_ttl = 7200 apc.num_files_hint = 2000 apc.mmap_file_mask = /tmp/apc.XXXXXX
Then make a symlink to the apc.php to a web accessible location to see the statistics.
ln -s /usr/local/lib/php/apc.php /blahblah/apc.php
It seems that I don’t really need memcache so I may just close it off in the future. Most recommendations seem to be just to enable APC and it would be good enough but for now why the heck not. Just run it all since I have all the resources. I want to improve the speed of the forum
On a side note I found this memcache link for mediawiki but I will work on that later
