Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Thursday, March 21, 2013

Install RHEL Packages with yum from CD/DVD

You may want to install RHEL or CentOS packages before registering with RHN or without a network connection.  You can yum install packages from the installation CD/DVD by specifying a local ISO repo.

Mount your disc or image at /mnt/cdrom and create /etc/yum.repos.d/rhel-iso.repo with the following contents:

[rhel-debuginfo]
name=Red Hat Enterprise Linux ISO
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=0
You should now be able to yum install your package from the CD.

Monday, August 13, 2012

Combine multiple PNG files onto one PDF with ImageMagick

With ImageMagick you can easily convert multiple image files into one PDF.  Place all of your images into the same directory and name them something like: image001.png, image002.png, etc.  Then do:
convert *.png outfile.pdf
You should now have a pdf file comprised of your image files in the proper order.  Make sure you name the files correctly with leading zeros, or else image1.png will end up next to image100.png.


Wednesday, May 30, 2012

Install VMware Tools on RHEL 6 & Centos 6

This is a HOWTO for installing VMware Tools on RHEL 6 and Centos 6.  I'm mainly posting this since I never remember what the prerequisites are.

Install the VMware tools prerequisites:
yum install make gcc kernel-devel kernel-headers glibc-headers perl

Mount the VMware Tools CD (after inserting it into the VM)
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

Copy the install bundle from the CD and extract it.
cp /mnt/cdrom/VMware-Tools*.tar.gz /tmp/
cd /tmp/
tar xvfz VMwareTools*.tar.gz

Run the installer, default on all prompts works fine.
cd /tmp/vmware-tools-distrib
./vmware-install.pl  # add -d to auto accept defaults


Wednesday, February 22, 2012

Apache 2.4 vs Nginx Benchmark Showdown

Disclaimer: This test was highly unscientific, with a +/- 10% fabricated margin of error.  No maths were performed to gather proper averages and statistics.  No effort was made to ensure consistency of the two Apache builds and no legitimate effort was made with regard to proper scientific rigor during this test.  This test does not take into account memory usage, responsiveness of the server under load, or any other relevant metric that would be of more use than this test.  I highly encourage you to do your own testing and draw your own conclusions.

How the tests were performed: 
I wanted to simulate a VPS environment similar to a basic Linode.  A base install of Ubuntu Server 10.04 was installed in VMWare with an older/slower 7200RPM sata drive for storage.  This drive was not in use by any other system during the test, nor were any other VMs active on the host.  The guest was given 512MB of RAM and 1 CPU core of the host's 8 cores.  The host's CPUs are dual Xeon X5365 @ 3Ghz.

Apache 2.2 was installed along with nginx 0.7.65, later Apache 2.4 was compiled on this same system.

Testing was performed using Apache JMeter on an 8 core Xeon workstation running Windows 7 and 32GB of RAM  with a 1Gb/s link to the VMWare host.  Requests per second were determined by rounding off the throughput displayed in the Summary Report listener.  Each test was run until the requests per second stabilized.

The Apache 2.2 server was only tested with the Prefork MPM, while the Apache 2.4 server was tested with both Prefork and Event.  Apache's KeepAlive setting was on throughout the testing and set at 2 seconds.

Update:
I received several requests to post memory usage statistics so I've updated the Jquery test with memory results.  Again, care was not taken to keep the Apache builds consistent.  It concerns me that the Prefork build of Apache 2.4 was using so much memory compared to the other Apache builds.  Take these results with a grain of salt, but trust that Nginx definitely uses significantly less memory than Apache.

Update 2 - Nginx 1.0.12:
I received some flak for using an older version of Nginx, so I tested with Nginx 1.0.12 and it was around 4% slower than the results shown here.

Test 1 - 21KB text file
HTTP Server Req/s
Apache 2.2 Prefork 2220
Apache 2.4 Prefork 2250
Apache 2.4 Event 2300
Nginx 2600


Test 2 - 2B text file consisting of a single period.
HTTP Server Req/s
Apache 2.2 Prefork 4400
Apache 2.4 Prefork 4700
Apache 2.4 Event 4810
Nginx 6650


Test 3 - jquery.min.js (92KB)

HTTP ServerReq/sMemory Usage
Apache 2.2 Prefork65012MB
Apache 2.4 Prefork77072MB
Apache 2.4 Event82020MB
Nginx10002MB


Test 4 - PHP output of phpinfo()
HTTP Server Req/s
Apache 2.2 Prefork 525
Apache 2.4 Prefork 575
Nginx FastCGI 450


Saturday, October 8, 2011

tar exclude svn directories

To exclude svn folders when using tar, do:
tar czf tarball.tgz --exclude=.svn mydirectory

Tuesday, April 12, 2011

Install PHP APC on RHEL and CentOS

Install prerequisites: (note that on RHEL you need to enable the Optional server repo for php-devel, rhn-channel --add --channel=rhel-x86_64-server-optional-6)
yum install gcc php-pear php-devel httpd-devel pcre pcre-devel

Install APC with pear:
pear install pecl/apc

Tell PHP to load the APC module. Create /etc/php.d/apc.ini
echo "extension=apc.so" > /etc/php.d/apc.ini

Restart Apache

Thursday, April 7, 2011

Install MongoDB on RHEL or CentOS

Edit /etc/yum.repos.d/10gen-mongodb.repo and add the appropriate repo.

32bit:
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0

64bit:
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0

Install MongoDB client and server
yum install mongo-10gen mongo-10gen-server

Check the settings in /etc/mongod.conf . To bind mongod to a specific ip, add something like:
bind_ip = 127.0.0.1

Ensure correct permissions on /var/lib/mongo
chown -R mongod:mongod /var/lib/mongo/

Start mongodb with the init script:
/etc/init.d/mongod start

Tuesday, December 14, 2010

X-Authentication-Warning: Apache set sender using -f

This is commonly seen in mail headers from emails sent by PHP applications running on Apache through sendmail. To get rid of it, edit /etc/mail/trusted-users, add apache to the list, and restart sendmail.

Tuesday, July 20, 2010

Recursively count lines of code in Linux

( find ./ -name '*.php' -print0 | xargs -0 cat ) | wc -l

Sunday, June 13, 2010

Dell latitude: Enable middle click scroll on Ubuntu

It seems by default most, if not all, laptops with a pointing stick and a middle mouse button default to using paste for the middle mouse click assignment with XORG. You can change this so that it scrolls like it does on Windows.

Edit one of the files in /usr/lib/X11/xorg.conf.d/ or just create a new one and add:

Section "InputClass"
Identifier "Trackpoint Wheel Emulation"
MatchProduct "PS/2 ALPS DualPoint TouchPad"
MatchDevicePath "/dev/input/event*"
Option "EmulateWheel" "true"
Option "EmulateWheelButton" "2"
Option "Emulate3Buttons" "false"
Option "XAxisMapping" "6 7"
Option "YAxisMapping" "4 5"
EndSection
Change MatchProduct to your pointing stick device. You can find the name of your device by running
xinput list
Log out and back in for it to take effect.



Saturday, May 29, 2010

Turn off Linux monitor via shell without XORG

I have an older laptop running as a test web server. I wanted to turn off the lcd output to save however much electricity an lcd backlight uses. To do this you can do:
vbetool dpms off
You can even do this from a remote shell. To turn it back on, simply do
vbetool dpms on

Tuesday, May 26, 2009

Ubuntu: Use apt-get through a proxy

You can set proxy settings in the Synaptic package manager but these don't seem to affect apt-get. To get apt-get to work through a proxy do:
sudo nano /etc/bash.bashrc
At the end of the file add:
export http_proxy=http://username:password@proxyserver:port/
export ftp_proxy=http://username:password@proxyserver:port/
If your proxy server does not require authentication then leave out the username:password@

You'll need to open a new terminal for it to take effect.

Friday, April 24, 2009

Ubuntu equivalent of rc-update

The Ubuntu equivalent of Gentoo's rc-update is update-rc.d

Gentoo example:
rc-update add ssh default

Ubuntu example:
update-rc.d ssh defaults

Friday, February 27, 2009

cifs_mount failed w/return code = -13

This error usually indicates that Samba is not installed, although CIFS is compiled into the kernel. On Gentoo, either emerge samba, or emerge mount-cifs (much smaller).

Tuesday, February 17, 2009

Perl CGI scripts not executing on Apache

If your Perl CGI scripts are showing the code instead of executing on Apache, add or uncomment the following from your apache conf file, httpd.conf or apache2.conf:

AddHandler cgi-script .cgi

Sunday, December 7, 2008

Replacing network cards under Ubuntu: eth0 missing

If you change network adapters and are running Ubuntu you may notice that eth0 no longer exists but your new adapter shows up as eth1, or eth2, eth3, etc. To fix this, just clear the contents of /etc/udev/rules.d/70-persitent-net.rules and reboot.

Saturday, November 29, 2008

Mythtv xv port

You can work around xorg intel tearing issues by specifying the xv port for mplayer, but the internal player has to be patched to ignore the textured video port.  Instead, the latest drivers have an option to disable the textured video port.  See my previous post.

Intel video tearing in XORG

The latest Intel drivers (2:2.4.1-1 at this time) are using the textured video port for playback by default which causes tearing issues.  If your driver supports it, try:

Option "TexturedVideo" false

In your xorg.conf file under the device section.  This should elimate any tearing issues.

Tuesday, November 25, 2008

Mythbuntu MythTV MCE remote back button

Mythbuntu does not have the back button configured on the original MCE remote.  To remedy this, edit ~/.lirc/mythtv

Search for button = back and modify the config line so it says "config = Escape".  If you don't find the back button in the file, then just add:

 begin
    remote = mceusb
    prog = mythtv
    button = Back
    config = Escape
    repeat = 0
    delay = 0
end