Archive for the ‘Direct Admin’ Category

Increase the max upload filesize in apache/php

Sunday, April 22nd, 2007

edit: php.ini file on server

You can locate php.ini file using — php -i | grep php.ini

/usr/local/lib/php.ini

Search for

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
Change the 2M to whatever new value you want, then restart apache.

Running CGI script from any directory or via /~username/cgi-bin

Sunday, April 22nd, 2007

In order to force apache to allow cgi script to run, simply create a file called .htaccess inside the directory in which you wish to run the scripts. Inser this text into the file:

Options +ExecCGI
AddHandler cgi-script .cgi .pl

How to track which site is using the apache processes on Direct Admin Server

Sunday, April 22nd, 2007

Edit your /etc/httpd/conf/httpd.conf and add

ExtendedStatus On

SetHandler server-status

just after the code that says “ServerSignature On”. Save, exit, then restart apache. You can access the stats page by going to http://1.2.3.4/httpd-status where 1.2.3.4 is your server’s IP.

How to downgrade from apache 2 back to apache 1.3

Sunday, April 22nd, 2007

If you need to go back to apache 1.3 after installing apache 2, you’ll need to do the following:

1) Restore the old httpd.conf file:

cp -f /etc/httpd/conf/httpd.conf.1.3.backup /etc/httpd/conf/httpd.conf

2) Get DirectAdmin to use the old httpd.conf files for the users. Edit the /usr/local/directadmin/conf/directadmin.conf file and change apache_ver=2.0 to apache_ver=1.3. Then type

echo “action=rewrite&value=ips” >> /usr/local/directadmin/data/task.queue
echo “action=rewrite&value=httpd” >> /usr/local/directadmin/data/task.queue
echo “action=directadmin&value=restart” >> /usr/local/directadmin/data/task.queue

3) Now you can recompile apache 1.3

rm -f /usr/lib/apache/*
cd /usr/local/directadmin/customapache
./build clean
./build all

4) Fix the modules link:

cd /etc/httpd
rm -f modules
ln -s /usr/lib/apache modules

5) Restore the old boot script:
FreeBSD:

cp -f /usr/local/directadmin/customapache/httpd_freebsd /usr/local/etc/rc.d/httpd
chmod 755 /usr/local/etc/rc.d/httpd
/usr/local/etc/rc.d/httpd restart

RedHat:

cp -f /usr/local/directadmin/customapache/httpd /etc/init.d/httpd
chmod 755 /etc/init.d/httpd
/etc/init.d/httpd restart

How to update to php 5 on Direct Admin Server

Sunday, April 22nd, 2007

To update to php5, the build script will still work. All that you need to do is swap out the version, compile normally and make a few modifications to your /etc/httpd/conf/httpd.conf file.

1) download the php-5.2.1.tar.gz from php.net into your customapache directory:

cd /usr/local/directadmin/customapache
wget http://files.directadmin.com/services/customapache/php-5.2.1.tar.gz

2) change your build script for the new version:

nano build
change: PHP_VER=4.4.4
to: PHP_VER=5.2.1

3) build php normally:

./build clean
./build php n
If you’re using apache 2.x, use

./build clean
./build php_ap2 n
instead.

4) edit /etc/httpd/conf/httpd.conf
Remove any referce of:

LoadModule php4_module modules/libphp4.so

and make sure they’re replaced with:

LoadModule php5_module modules/libphp5.so

Remove any reference of:

AddModule mod_php4.c
and replace with:

AddModule mod_php5.c

5) find this piece of code:


DirectoryIndex index.html index.htm index.shtml index.php index.php4 index.php3 index.phtml index.cgi

replace with:


DirectoryIndex index.html index.htm index.shtml index.php index.php4 index.php5 index.php3 index.phtml index.cgi

Find this:


AddType application/x-httpd-php .inc .php .php4 .php3 .phtml
AddType application/x-httpd-php-source .phps

(it might have AddHandler instead of AddType)
replace with:


AddHandler application/x-httpd-php .inc .php .php5 .php4 .php3 .phtml
AddHandler application/x-httpd-php-source .phps

Then restart apache.

If you get the following error while compiling php:

checking whether to enable LIBXML support… yes
checking libxml2 install dir… no
checking for xml2-config path…
configure: error: xml2-config not found. Please check your libxml2
installation.

*** There was an error while trying to configure php. Check the configure.php file
Then edit the configure.php file (or configure.php_ap2 if you’re using apache 2), and change:

–with-xml \
to:

–disable-libxml \
–disable-dom \
–disable-xml \
–disable-simplexml \
–disable-xmlreader \
–disable-xmlwriter \
or else install the missing rpms/packages for xml. (libxml2-dev and libxml2-utils on debian). Redhats:

yum -y install libxml2-devel libxslt-devel

Updating Apache to the latest version on DirectAdmin

Sunday, April 22nd, 2007

You can check the current version of apache by running

httpd -v

If you wish to update your 1.3 version of apache to the most recent, run the following:

cd /usr/local/directadmin/customapache
./build clean
./build update
./build apache_mod_ssl
If you’re using apache 2.x, use “./build apache_2″ isntead of apache_mod_ssl.
This should update both the configure options and the version of apache to the most recent version. Once the update has completed, you’ll need to restart apache:

RedHat:

/sbin/service httpd restart

FreeBSD:

/usr/local/etc/rc.d/httpd restart

What ports do I need to open in my firewall ? DirectAdmin

Sunday, April 22nd, 2007

20,21: FTP. Note that ftp will use a “random high port number” if the client is in PORT mode, so you may need to add a port range into your /etc/proftpd.conf file to allow ftp connections, eg:

PassivePorts 32555 32565
and then open that port range as well in your firewall.

22: ssh access

25: smtp for exim to recieve email

53: dns (named), so your sites resolve

80, 443: apache traffic, http and https

110: client pop email access
143: clients imap email access

2222: DirectAdmin Access

3306: mysql acess. You don’t need to open this port if you don’t want to allow remote mysql access, as most mysql scripts are all accessed locally.

Installing Ioncube Loaders on your server..

Saturday, April 21st, 2007

You WILL require root access to the server in order to do this.

1. Download the latest loaders to your computer from http://www.ioncube.com/loaders.php and upload them to your webspace
2. Move the ioncube folder to a permanent location by entering:
mv ioncube /usr/local
3. Next, you need to locate the php.ini file, to do this enter:
locate php.ini
4. You should find it is in /usr/local/lib/php.ini. Now that you know the location of php.ini you need to edit it.
pico /usr/local/lib/php.ini
5. Now find where other zend extentions are in the file.
ctrl + w: zend_extension
6. Paste in your new line for ioncube loader
zend_extension = /usr/local/ioncube/ioncube_loader_lin_x.so (Replace x with your version of PHP eg. 4.4)
7. Save the changes
ctrl + X then Y and enter
8. Restart the web server to take effect.
/etc/init.d/httpd restart

That’s it! Ioncube is now installed on your server! You should now see a section in your PHP Info page that says:

Additional Modules
Module Name ionCube Loader

How can I enable Register Globals?

Saturday, April 21st, 2007

There are 3 methods —

1st : Enable on complete Server.

Code :

php -i | grep php.ini

This will give you exact path of php.ini file

Edit php.ini file — set

register_globals on

2nd : Enable on particular domain or folder using .htaccess

If you don’t want to turn Register Globals on for your whole server or don’t have access to as you are a reseller then you can enable them just on the particular folder and all subfolders below it. To do this, simply put the following line into a text file and save it as “.htaccess”. Then upload it to that folder.

php_value register_globals on

3rd : If .htacess fails

Sometimes, the .htaccess method will not work on your server and you’ll get an Internal Server Error message after trying that. In the event of this, you can try using a php.ini file. To do this, create a file named “php.ini” and insert the following line:

register_globals=On

Then upload the php.ini file to the folder for which you wish to enable register globals.

Simple Commad to detect DOSS attack

Thursday, April 19th, 2007

Try this command as one of the method to check if your server is under doss attack

netstat -anp |grep ‘tcp\|udp’ | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n

You can block ips using apf -d ipnumber