How to fix PHP compile errors
Some library errors when compile Php 5 on CentOS
checking for BZip2 support… yes
checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution
Fix:
yum install bzip2-devel
checking for cURL support… yes
checking if we should use cURL for url streams… no
checking for cURL in default path… not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in/include/curl/
Fix:
yum install curl-devel
Check Linux HDD using smartmontools
The step by step command example below show the process of using SMART disk monitoring tool that provide us with the information of overall hard disk health status.
To install smartmontools:
yum install smartmontools
Enabling SMART Monitoring Tools on HDD (turn on SMART):
Read more…
Network Stats with Iptables
Most of the time we use iptables to set up a firewall on a machine, but iptables is also able to do network statistics reporting. the -v (–verbose) option makes the list command (-L) show the packet and byte counters. Network stats are available on a per rule basis. Here’s an example on the INPUT chain:
[root@server]# /sbin/iptables -n -v -L INPUT
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
2589 3295K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
62 3720 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
57 2896 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8443
46 2460 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:21
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:587
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:25
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:465
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:106
26 1835 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:53
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 code 0
Read more…
How to detect a DDoS attack? Find out with netstat!
Your server running very slow could be many things from wrong configs, scripts and fail hardware – but sometimes it could be because someone is flooding your server with traffic known as DoS ( Denial of Service ) or DDoS ( Distributed Denial of Service ) it could also be that your server itself is part of a botnet and is being used to attack other networks, in this case its always a good idea to run scans with software such as ClamAV and RootKit Hunter as a precaution or even higher a professional to check it out for you if your not confident enough to do it on your own.
Furthermore whenever a client connects to a server via network, a connection is established and opened on the system. On a busy high load server, the number of connections connected to the server can be run into large amount till hundreds if not thousands. Find out and get a list of connections on the server by each node, client or IP address is useful for system scaling planning, and in most cases, detect and determine whether a web server is under DoS or DDoS attack
Take a look at these handy netstat commands below that will surely help you determine wether your under attack or are part of an attack.
Display all active Internet connections to the server and only established connections are included.
netstat -na
Show active Internet connections to the server on port 80 and sort the results. Useful in detecting a single flood by allowing you to recognize many connections coming from one IP.
netstat -an | grep :80 | sort
Read more…
Installing iftop on CentOS to monitor network traffic
To install iftop on the CENTOS Server login to the server and use the following commands:
Be sure you have the latest version by looking at http://pkgs.repoforge.org/iftop
wget http://pkgs.repoforge.org/iftop/iftop-0.17-1.el6.rf.i686.rpm # for CentOs 32bit
# for CentOs 64bit http://pkgs.repoforge.org/iftop/iftop-0.17-1.el6.rf.x86_64.rpm
rpm -if iftop-0.17-1.el6.rf.i686.rpm
Usage
The default iftop command displays the bandwidth usage of the first ethernet device.
iftop
Read more…
MySQL Import Command
How do I import data stored in a “.sql” file (created by mysqldump command) under UNIX or Linux operating systems?
The syntax is as follows to import the data created by mysqldump command:
mysql -u{DB-USER-NAME} -p{DB-PASSWORD} {DB-NAME} < {db.file.sql}
mysql -h{MySQL-SERVER-HOST-NAME} -u{DB-USER-NAME} -p{DB-PASSWORD} {DB-NAME} < {db.file.sql}
In this example import a file called sales.sql for salesdb1 user and sales db, enter:
$ mysql -u123tweak -p123password 123tweak < 123tweak.sql
Read more…
CentOS / Red Hat IPv6 Network Configuration
Setting up IPv6 on CentOS, and for that matter RHEL and Fedora Linux, is quite straight forward. You need to edit just two files:
1. /etc/sysconfig/network-scripts/ifcfg-
2. /etc/sysconfig/network
- Configure the IP address. For example, for interface eth0, edit /etc/sysconfig/network-scripts/ifcfg-eth0 and make the necessary changes as below.
DEVICE=eth0
HWADDR=00:22:15:17:CC:C1
BOOTPROTO=static
IPADDR=192.168.1.2
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6ADDR=<ipv6 address>
ONBOOT=yes
Reset MySQL root Password
To reset MySQL root user’s password, follow the following steps.
- Terminate all running instances of MySQL server. You can do that either via the RC script (/etc/init.d/<script_name> stop or /user/local/etc/rc.d/<script_name> stop for FreeBSD) or using the tools like kill and pkill. To use kill or pkill, you will have to use ps or pgrep to find out the process names or process ID (PID).
Using the RC script to do a proper shutdown is safer than using kill or pkill.
- Start the MySQL server in safe mode
mysqld_safe --skip-grant-tables --user=mysql - On another terminal, login to the MySQL server as the root user
mysql -u root
Read more…
Turn on MySQL query cache to speed up query performance?
Many times developers looking for ways to speed up query, in mysql we can enable query cache to speed up query performance. Whenever query cache is enable, it will cache the query in memory and boost query performance.
As we know, speed is always the most important element in developing a website especially for those high traffic database driven website. You can try to turn on query cache to speed up query.
To speed up query, enable the MySQL query cache, before that you need to set few variables in mysql configuration file (usually is /etc/my.cnf or my.ini)
- 1st, set query_cache_type to 1. (There are 3 possible settings: 0 (disable / off), 1 (enable / on) and 2 (on demand).
query-cache-type = 1
Read more…
How to find large files in Linux
At the command line as root enter:
find / -size +102400k
This will find all files on the entire system that are bigger than 100 MB.
Use this one to see the sizes:
find / -size +103400k | xargs ls -laAh
Use “find .” to look only in the current directory.
find . -size +103400k | xargs ls -laAh
Read more…