Skip to main content

Linux

FAQs/HOW-TO's related to Linux and/or BSD server administration.

Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable.

if you try running the following:

phpize

and get this error

$PHP_PREFIX/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

Then it's because you don't have autoconf installed.

To fix this error, do the following:

yum install autoconf

or you can install from source (if you want to use the latest version)


cd /usr/local/src/

/* find latest version of m4 here: http://ftp.gnu.org/gnu/m4/ */

How to search for text inside files in Linux

To search for a text pattern in files in linux, do the following:

find / -type f -print0 | xargs -0 grep -i 'your pattern'

phpMyAdmin database export "Save as file" template

Whenever you do a database backup using phpMyAdmin, you are presented with a default file name structure for saves, usually like so:

__DB__

which basically gives you the name of the database you just backed up. Which is ok, however, most people would also like the date and time stamp included as well...

So...

This is how it's done... replace the above with :

__DB__-%F-%T

__DB__ = name of database Example: my_database
%F = Same as "%Y-%m-%d" (year-month-day) Example: 2009-11-25
%T = time stamp . (24 hour format, hour_minute_second) Example: 11_07_31

which will save a file with the naming structure similar to:

my_database-2009-11-25-11_07_31.sql

You can easily use other date/time structure, to suit your personal preference.

chmod directories only

To chmod only directories within the directory you're in...

find ./ -type d -exec chmod 755 {} \;

To chmod only files within the directory you're in...

find . -type f -exec chmod 644 {} \;

RESOLVED: mysqld won't start

In case your mysqld won't work with

# service mysqld restart
or
# service mysqld start
or
# service mysqld stop

do this:

# killall mysqld

followed by:

Linux server: Set date and time

Set your correct timezone:

# timeconfig

* You may need to install timeconfig 'yum install tzdata'

select your timezone.. select "system clock uses UTC"

Using SSH with Screen for Session Management

Customize your ~/.screenrc

source: http://magazine.redhat.com/2007/09/27/a-guide-to-gnu-screen/

update server with custombuild

source: http://www.directadmin.com/forum/showthread.php?t=19221


cd /usr/local/directadmin
wget http://files.directadmin.com/services/custombuild/1.2/custombuild.tar.gz

Dovecot Problems

We use dovecot on our servers to process email. However, with IMAP it keep freezings so here are possible solutions.

# vi /etc/dovecot.conf

change and/or uncomment :

How to enable SpamAssassin on DirectAdmin

Source

How to change IP address on Linux server

1. IP
/etc/sysconfig/network-scripts/ifcfg-eth0

2. DNS
/etc/resolv.conf
/etc/hosts

3. Router
/etc/sysconfig/network

4. Restart the network
/etc/rc.d/init.d/network restart

How to override open_basedir settings in Plesk

Plesk will overwrite any httpd.conf settings unless you include them in...

/home/httpd/vhosts/DOMAIN/conf/vhost.conf

How to use install and use Iperf

Install iperf

cd /usr/local/src
wget http://internap.dl.sourceforge.net/sourceforge/iperf/iperf-2.0.4.tar.gz
tar xvfz iperf-2.0.4.tar.gz
cd iperf-2.0.4

How to install ImageMagick from source

Go into /usr/local/src directory

cd /usr/local/src

First, we need to get all the required libraries...

yum search ImageMagick-devel

Install ffmpeg on CentOS/RHEL i386 via rpm

Source: Vikrant

This actually was the only thing that worked exactly like i wanted.

install ffmpeg via ffmpeginstall.2.X series

source

directadmin yum.conf

vi /etc/yum.conf

[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=centos-release
tolerant=1
exactarch=1
retries=20
obsoletes=1

How to install ffmpeg on centos/rhel via YUM

source

I seen where a lot of server management companies are charging big bucks for this, so this might save you some time and money.

First

How to upgrade to PHP5.x and Apache 2.X

source: http://www.directadmin.com/forum/showthread.php?s=78bb4e8b8b5deb41fdc7275bb87a051a&threadid=13173&perpage=20&pagenumber=1

http://www.directadmin.com/forum/showthread.php?s=70864a5c335e7705f268e661e0a6d78f&threadid=14285

Linux IP management

# ifconfig eth1 192.168.10.12 netmask 255.255.255.0

# cd /etc/sysconfig/network-scripts

Edit the NETMASK lines in the ifcfg-eth0* and in the ifcfg-eth1* files as required.

Exim with SSL POP/SMTP/IMAP (using stunnel)

Source

DirectAdmin Checklist (incase something doesn't work)

If email is not being received, but you're able to log in, it may be a permission's problem
(This may occur when restoring backup accounts)

# /usr/local/directadmin/scripts/set_permissions.sh email 

If you're unable to su to root, even if inputing the correct password

SSL help

SSL Location:

SSH to the old server and go to /usr/share/ssl/certs/, here you find the www.domain.com.crt (SSL Certificate) and the www.domain.com.cabundle (Cabundle), You will find the key www.domain.com.key at /usr/share/ssl/private/ path.

Linux: User Commands

source: http://www.ahinc.com/linux101/users.htm

Close Open DNS Servers

Source: http://www.webhostgear.com/321.html


For those of you who check your nameservers and other DNS related issues using the popular site dnsreport you're probbaly seeing Fail Open DNS Servers. We'll show you have to fixed named to close open dns servers.

How-to: Secure tmp directories on linux

source: www.eth0.us: How-To: Secure your temp directories

Every system needs temporary folders that any user is able to read and write BUT these directories should not be able to execute programs or scripts. Though this will only protect you from somebody running the script directly it will help with a large portion of the automated rootkits and trojans that script kiddies use. They will still be able to put the files on the system but they will be unable to execute them and create the back door. One of the biggest problems is php injection via apache in which people will have apache download and then run an exploit. Securing the temp directories is probably the single biggest thing you can do towards securing your server.

Securing SSH: protocol SSH2 and hiding the direct access of root

RKHunter Install

Source: http://forums.cpanel.net/showpost.php?p=211290&postcount=102

1. Login to your server via SSH as root.

Then Type: cd /usr/local/src/

HOW-TO: Change Exim IP Address

If you are in the danger of getting your main server IP block by SpamCop because you had a few anoying spamers abusing your server then you could simply change your exim mailserver IP to avoid the effect of your main IP beeing blacklisted.

Preventing DDoS Attacks

source: http://www.linuxsecurity.com/content/view/121960/49/

In this article I am trying to explain what DDOS is and how it can be prevented. DDOS happens due to lack of security awareness of the network/server owners. On a daily basis we hear that a particular machine is under DDOS attack or NOC has unplugged the machine due to DDOS attack . So DDOS has become one of the common issues in this electronics world. DDOS is like a disease which doesn't have an anti-viral developed. So we should be carefull while dealing with it . Never take it lightly. In this article i am trying to explain the steps/measures which will help us defend from DDOS attack ,up to a certain extend .