Archive

Archive for the ‘Dedicated Server’ Category

How to Enable PHP function for a one account ?

April 9th, 2009 6 comments

IF you disable PHP function in php.ini file and if you want to enable any particular function only one account .Then You can however use suhosin to enable a function for one domain only.

How can you do that ?

After installing suhosin, remove all functions from disable_functions in php.ini and add in php.ini suhosin.executor.func.blacklist = “exec,passthru,shell_exec” and all the functions that you want to disable globally.

After that for each domain in the virtual host section you can add suhosin.executor.func.blacklist again but without the function that you need to enable. And so you will enable that function only for one domain.

Example:

<VirtualHost 127.0.0.1>
………..
………..
<IfModule mod_php4.c>
php_admin_value open_basedir “/usr/lib/php”
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir “/usr/lib/php”
php_admin_value suhosin.executor.func.blacklist = “passthru,shell_exec”
</IfModule>
…….
……
</VirtualHost>

In this example exec has been enabled for the VirtualHost. This way it will be better as you do not neet to modify all the virtual hosts only the ones that you need to enable one or more functions.

Regard’s

Alex P

How to install mod_ruby and eruby on Linux server ?

April 8th, 2009 5 comments

What is mod_ruby?

mod_ruby embeds the Ruby interpreter into the Apache web server, allowing Ruby CGI scripts to be executed natively. These scripts will start up much faster than without mod_ruby.


1) Install eRuby

# wget http://www.modruby.net/archive/eruby-1.0.5.tar.gz

# tar -xzvf eruby-1.0.5.tar.gz

# cd eruby-1.0.5/

# ./configure.rb –with-charset=euc-jp –enable-shared

# make; make install

2) Install mod_ruby

i)Download latest mod_ruby tar file

# wget http://www.modruby.net/archive/mod_ruby-1.2.6.tar.gz

# tar -xzvf mod_ruby-1.2.6.tar.gz

# cd mod_ruby-1.2.6/

#  ./configure.rb –enable-eruby –with-apxs=/usr/local/apache/bin/apxs

# make; make install

ii)Edit apache configuration file ( httd.conf) and add following code

LoadModule ruby_module libexec/mod_ruby.so
ClearModuleList
AddModule mod_ruby.c
AddHandler cgi-script .rb
<IfModule mod_mime.c>

# for Ruby/eRuby
<IfModule mod_ruby.c>
# for Apache::RubyRun
RubyRequire apache/ruby-run
# for Apache::ERubyRun
RubyRequire apache/eruby-run
# for development
# RubyRequire auto-reload
# for add library
#RubyAddPath /usr/local/lib/ruby
# exec *.rbx as ruby scripts.
<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
# handle *.rhtml as eruby files.
<Files *.rhtml>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
</Files>
</IfModule>
</IfModule>

iii) Restart apache service on server


Regards

Alex P

Fixing Apache “No space left on device: Couldn’t create accept lock” errors

April 3rd, 2009 2 comments

Hello,

I was facing same error with one of my shared server last couple of week, apache was broke on server and getting following error in apache error logs file.

[emerg] (28)No space left on device: Couldn't create accept lock
[notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[notice] Digest: generating secret for digest authentication ...
[notice] Digest: done
[warn] pid file /etc/httpd/run/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[emerg] (28)No space left on device: Couldn't create accept lock

I checked disk space, or quota limit but everything was fine. I through it seem to apache semaphore problem

Apache can create the “accept lock” is with a semaphore. A semaphore is an inter-process communication tool that is used by Apache to communicate with it’s child processes. This error message may mean that Apache couldn’t create a new semaphore.

Check to see how many semaphores are currently in use. If Apache is running correctly, you should see something like this:

# ipcs -s

If Apache is stopped, and you still see these semaphores, then you can safely kill them by running this command for each semaphore id (in the second column)

$ ipcrm -s <semid>

To destroy all semaphores, you can run this from the command line (with “apache” being the apache-user:

for semid in `ipcs -s | grep apachec | cut -f2 -d" "`; do ipcrm -s $semid; done

OR

ipcs -s | grep apache | perl -e ‘while (<STDIN>) { @a=split(/\s+/); print `ipcrm sem $a[1]`}’

OR

ipcs -s | grep nobody | perl -e ‘while () { @a=split(/\s+/); print `ipcrm sem $a[1]`}’ ipcs -m | grep nobody | perl -e ‘while () { @a=split(/\s+/); print `ipcrm -m $a[1]`}’

OR

for i in `ipcs -s | awk ‘/httpd/ {print $2}’`; do (ipcrm -s $i); done

How to increase semaphore limit

To view the current parameters:

ipcs -l

To change these parameters, modify the file /etc/sysctl.conf and add the following lines:

kernel.msgmni = 1024
kernel.sem = 250 256000 32 1024

Then load these settings with the command:

sysctl -p

Regards

StacyM

System Administrator