Archive for the tag 'Scripts'

How to resolve Suexec problems with cgi scripts

Run the following script:

/scripts/fixsuexeccgiscripts

This reads /usr/local/apache/logs/suexec_log and looks for errors and tries to fix them.

Cpanel software update scripts description

In addition to /scripts/upcp

/scripts/rpmup2

Update System Software Updates your system software. This script is essentially the same as running yum update.

/scripts/sysup

Update Server Software Updates software dependencies required by cPanel that are provided by the operating system.

/scripts/*up

There are a number of scripts that update applications installed with cPanel.

How do I enable error logging for PHP scripts which helps in debugging application?

PHP errors are by default logged to the web server’s error log file (at least they are with the default setup on most Linux distros) but it is also possible to instead log PHP errors to a file of your choice. This is useful on production websites so you can periodically check for errors and fix them in a location other than the default webserver error log file.

If you do not currently have a php.ini, make one and place it in the same folder(s) as the PHP script(s) that you want to track errors for. You will need to add the following 2 lines:

log_errors = On
error_log = error_log

If we choose to enable error logging, then we MUST check the error_log often and take corrective actions for persistent errors, it’s recommend having it disabled for security reasons.

Whenever possible place any executable scripts inside the cgi-bin directory.

When uploading scripts via FTP make sure to always use ASCII mode. If you are doing a server to server FTP transfer use BINARY mode.

The first line in all PERL scripts must contain the path to PERL which is: #!/usr/bin/perl

Directories and scripts should both executable. Usually the permission level 755 is the best. All files and directories where CGI will be executed must NOT be world or group writeable and must be at least user executable.

Data files that scripts will read/write must NOT be group or world writeable.

Make sure that you DO NOT modify the permissions of the cgi-bin itself. This will cause all scripts to fail. If the permissions have be altered, chmod the cgi-bin back to 755.

Check the code. Frequently there may be a line not closed with “;” or a routine that is not closed.

Make sure that all modules and ‘include files’ required by the scripts are located on the server and are in the proper locations.

Check that your CGI/Perl script is outputting the necessary HTTP headers. To do that in Perl, just below the “shebang” line (#!/usr/bin/perl), type the following line.


#!/usr/bin/perl
print "Content-type: text/html\n\n"


Add a “-w” to the first line of your script. (Example: # !/usr/bin/perl

Most FTP programs allow you to change the permissions of files on the server. You may also use the command shell (SSH) and use the command directly. Example: chmod 755 myscript.cgi

Running CGI scripts in the httpdocs directory without mod_perl in Plesk

To accomplish this on a per domain basis you will need to create a vhost.conf in the conf directory at /var/www/vhosts/serverbuddies.com/ with the following code.

<Directory /var/www/vhosts/mt-example.com/httpdocs>
<Files ~ (\.cgi$)>
SetHandler cgi-script
Options ExecCGI
allow from all
</Files>
</Directory>

Then run the following command to enable the change.

/usr/local/psa/admin/sbin/websrvmng -v -a

Now, all files with ‘.cgi’ extension will be executed as usual CGI scripts in /cgi-bin/.

To enable CGI in httpdocs for the whole server just uncomment the “AddHandler cgi-script .cgi” directive in httpd.conf and restart Apache.

Reference: http://parallels.com/

Next »