Thursday, June 4, 2009

Yum

Useful Yum Commands

yum install package_name download and install a rpm package

yum localinstall package_name.rpm That will install an RPM, and try to resolve all the dependencies for you using your repositories.

yum update update all rpm packages installed on the system

yum update package_name upgrade a rpm package

yum remove package_name remove a rpm package

yum list list all packages installed on the system

yum search package_name find a package on rpm repository

yum clean packages clean up rpm cache erasing downloaded packages

yum clean headers remove all files headers that the system uses to resolve dependency

yum clean all remove from the cache packages and headers files

Monday, May 25, 2009

Installing FFmpeg and FFmpeg-php

System Configuration/Prerequisites

The server that I had to install on was running:

  • Centos 5.x
  • cPanel 11 (but of course, you don’t need cPanel to install FFmpeg and ffmpeg-php)
  • Yum (or anything of the likes would do)
  • And I presume you have root access

Getting the required Files

Firstly, we would have to download all the required files to a folder. For me, I picked /usr/local/src, but it could be just any other folder you’d like.

Move into the directory that you’d like to download the source files to and run the following commands:

wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
wget http://www4.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc2.tar.bz2
wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://easynews.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.3.1.tbz2

This is what I used in my setup. Additional libraries should be downloaded if you need them. Also, I wouldn’t say that these are the latest binaries, but they work for me for now - you should check for updates if you wish. You may also want to change the location of the SourceForge downloads.

Now extract all the files you’ve downloaded:

bunzip2 essential-20061022.tar.bz2; tar xvf essential-20061022.tar
bunzip2 MPlayer-1.0rc2.tar.bz2 ; tar -xvf MPlayer-1.0rc2.tar
tar zxvf flvtool2-1.0.6.tgz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
tar zxvf lame-3.97.tar.gz
bunzip2 ffmpeg-php-0.5.3.1.tbz2; tar xvf ffmpeg-php-0.5.3.1.tar

Along with the additional libraries you could have possibly downloaded.

Installation

Now that we’re done downloading the files we need, it’s time to start the installation.

Codecs

Create a folder to store the Codecs that ffmpeg will need:

mkdir /usr/local/lib/codecs/
mv essential-20061022/* /usr/local/lib/codecs/
chmod -Rf 755 /usr/local/lib/codecs/

Subversion/Ruby/

yum install subversion
yum install ruby
yum install ncurses-devel

LAME

cd lame-3.97
export LD_LIBRARY_PATH=/usr/local/lib
./configure
make
make install

libogg

cd libogg-1.1.3
./configure
make
make install

libvorbis

cd libvorbis-1.1.2
./configure
make
make install

flvtool2

cd flvtool2-1.0.6
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

MPlayer

cd MPlayer-1.0rc2
./configure
make
make install

Now for the big one, ffmpeg.

Installing FFmpeg

Generally, we would install the latest version of ffmpeg. But as of the date of this post, the latest version of ffmpeg does not wok with ffmpeg-php. We will need to checkout a previous version from the SVN.

Inside your src folder, run the following to checkout this version of ffmpeg which works.

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk/ ffmpeg -r15261

Once it is done downloading, go into the ffmpeg folder

Note: If a version of ffmpeg was previously installed, run the following command in the ffmpeg folder first:

make uninstall
make clean

Start the installation. You may need to add/enable additional libraries into ./configure.

cd ffmpeg
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared
make
make install

During installation, you may get an error like:

Unable to create and execute files in /tmp. Set the TMPDIR environment
variable to another directory and make sure that /tmp is not mounted
noexec.
Sanity test failed.

To fix this, run the following commands to create a temporary tmp directory:

mkdir tmp
chmod 777 tmp
export TMPDIR=./tmp

After installation, remember to change the tmp directory back to your server’s tmp disk by doing the following:

export TMPDIR=/tmp

Check if ffmpeg is working by running the following:

ffmpeg -version

It should return something similar to:

FFmpeg version SVN-r15261, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared
libavutil 49.10. 0 / 49.10. 0
libavcodec 51.71. 0 / 51.71. 0
libavformat 52.22. 1 / 52.22. 1
libavdevice 52. 1. 0 / 52. 1. 0

If the version isn’t “SVN-r15261″, then there is something wrong and you may need to reinstall ffmpeg.

If something like the following is returned:

ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory

Search for the missing library (in this case libaddevice.so.52) with the following:

find / -name 'libavdevice.so.*'

The returned results may look something like this. The one that we want is the one in the lib folder and not the src folder.

/usr/local/src/ffmpeg/libavdevice/libavdevice.so.52
/usr/local/lib/libavdevice.so.52
/usr/local/lib/libavdevice.so.52.1.0

With that, since the libraries are in the /usr/local/lib/ folder, we run the following:

export LD_LIBRARY_PATH=/usr/local/lib/

Otherwise, simply change the stuff after “=” to the path where the library is.

Sweet! Now that we’ve got FFmpeg working successfully, time to install ffmpeg-php.

Installing ffmpeg-php

Start the installation by running the following (again, run make clean as necessary):

cd ffmpeg-php-0.5.3.1
phpize
./configure
make
make install

You may meet the following errors during installation:

checking for ffmpeg headers… configure: error: ffmpeg headers not found. Make sure you’ve built ffmpeg as shared libs using the –enable-shared option

Solution: Simply create a ffmpeg folder in /usr/local/include/ and run the following to copy all the header files:

cp /usr/local/include/libavcodec/* /usr/local/include/ffmpeg
cp /usr/local/include/libavdevice/* /usr/local/include/ffmpeg
cp /usr/local/include/libavformat/* /usr/local/include/ffmpeg
cp /usr/local/include/libavutil/* /usr/local/include/ffmpeg
cp /usr/local/include/libswscale/* /usr/local/include/ffmpeg

make: *** [ffmpeg_frame.lo] Error 1

Solution: Execute the following in the ffmpeg-php folder. I’ve no idea why the files are named wrongly too.

cp ffmpeg_frame.loT ffmpeg_frame.lo

Upon successful installation, the installer will give you a very long sting to tell you where the extension was installed to. This is a unique string. The following is what I got:

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/

This has to be added to into php.ini.
In cPanel Servers, the php.ini file is located in /usr/local/lib. Otherwise, it should be in etc/php.ini.

Add the following line into php.ini (at the bottom or wherever you want):

extension=ffmpeg.so

Finalizing Installation

Restart Apache on the server.

service httpd restart

Check that ffmpeg is running on the server:

php -i | grep ffmpeg

The following should be returned:

ffmpeg
ffmpeg support (ffmpeg-php) => enabled
ffmpeg-php version => 0.5.3.1
ffmpeg-php gd support => enabled
ffmpeg.allow_persistent => 0 => 0

If an error like the following appears:

php: symbol lookup error: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so: undefined symbol: av_free_static

Simply rebuild ffmpeg-php and it should work again.

And you’re done!

You have just successfully installed FFmpeg and ffmpeg-php on your server!

Tuesday, May 12, 2009

SSH key- passwordless login

On the source server do the following

ssh-keygen -t dsa -f filename

It will prompt for a passphrace, it is desirable to leave it empty.
Two files will be created

filename
filename.pub

copy the filename.pub file to the destination server to the location /root/.ssh add the public key entry into authorized_keys as follows

cat filename.pub >> authorized_keys

/etc/init.d/sshd restart

Thursday, April 30, 2009

Install cPanel


    In order to run the cPanel software you must first be running a supported OS like RedHat or CentOS.
cPanel lists their supported operating systems on their website at http://www.cpanel.net.   cPanel also recommends that the server it is being installed on is a clean and fresh install.  This means that if you previously had done any configuring or ran another control panel software that they recommend you reinstall the server. 

IMPORTANT: If the server you plan to install cPanel on is a live production server, STOP.  cPanel's installer may overwrite your previous configurations and cause downtime for you or your customers!

cPanel has made the installation process a simple one and only takes a few commands to get the install going.  Below are the steps:

1.  Log into your server as root via the console or SSH.


2.  Ensure your resolvers are working by trying to resolve cpanel.net (cmd: nslookup cpanel.net).
2.1.   If nslookup does not work, giving a 'command not found' error, you can use yum to install the necessary packages (cmd: yum install bind-utils.i386).
2.2.   If you get an error about not being able to resolve the host, you need to edit your /etc/resolv.conf and add proper resolvers ( eg; 8.8.8.8 )
3.  Change directory into your /home (cmd: cd /home).

4.  Download cPanel's installer (cmd: wget -N http://httpupdate.cpanel.net/latest ).

4.1.   If you get a 'command not found' error, you need to install wget. (cmd: yum install -y wget).
5.  Now run the installer using sh or bash (cmd: sh latest).
5.1.   If you get another 'command not found' error, you need to install Perl. (cmd: yum install perl).
The installer is now running and may take a hour to two depending on your servers hardware, OS, connection speed, etc.
Once the installation is complete it's not time to log into the WebHostManager (WHM) and go through the wizard. Point your browser to http://your_ip_here/whm or http://your_ip_here:2086/ . You will be prompted for a user/pass, enter root as the user and enter your root password in the password field.  The wizard will now launch and ask you a few questions.  

Once complete your system is ready to use! Good Luck ;)

Sunday, March 15, 2009

How can I configure multiple Web sites using Host Headers?

Microsoft Internet Information Services (IIS) permits you to map multiple Web sites to a single IP address using a feature called Host Header Names. By assigning a unique host header name to each Web site, this feature permits you to map more than one Web site to an IP address.

Configure Web Sites by Using Host Header Names

To configure Web sites by using the Host Header Names feature, follow these steps:
1. Click Start, point to Administrative Tools, and then click Internet Information Services.
2. Expand * server name (where server name is the name of the server), and then expand Web Sites.
3. Right-click the Web site that you want, and then click Properties.

The Web site name Properties dialog box appears (where Web site name is the name of the Web site that you selected).
4. Click the Web Site tab, and then in the IP Address list, select the IP address that you want assigned to this Web site.
5. Click Advanced.
6. Under Multiple identities for this Web Site, click the IP address, and then click Edit.

The Advanced Web Site Identification dialog box appears.
7. In the Host Header Name box, type the host header that you want. For example, type www.example1.com. Add the port number, select the IP address in the list, and then click OK.

NOTE: If you want to configure this Web site with additional identities, click Add. Use the same IP address and TCP port, but enter a unique Host Header Name, and then click OK. For example, if you want to access the same Web site from both the Internet and a local intranet, you can configure the Web site identity in the manner shown in the following example:

IP Address TCP Port Host Header Name

192.168.0.100 80 www.example1.com
192.168.0.100 80 example1.com


8. In the Advanced Multiple Web Site Configuration dialog box, click OK.
9. In the Web site name Properties dialog box, click OK.

You return to the IIS window.
10. Right-click the next Web site that you want, and then click Properties.
11. In the IP Address list, select the same IP address that you selected in step 4, and then click Advanced.
12. Under Multiple identities for this Web Site, click the IP address, and then click Edit.

The Advanced Web Site Identification dialog box appears.
13. In the Host Header Name box, type a unique host header for this Web site. For example, type www.example2.com, add the port number, select the IP address in the list, and then click OK.
14. In the Advanced Multiple Web Site Configuration dialog box, click OK.
15. In the Web site name Properties dialog box, click OK.

You return to the IIS window.
16. Repeat steps 10 through 15 for each Web site that you want hosted on this IP address.
17. Register the host header names with the appropriate name resolution system -- for example, a Domain Name System (DNS) server or, in the case of a small network, a Hosts file.
The Web sites are now configured to accept incoming Web requests, based on their host header names.
More Information

Do not assign a host header name to the Default Web Site. Many programs expect the Default Web Site to use an IP address of (All Unassigned), TCP Port 80, and no host header name.
Troubleshooting

• Clients cannot connect to the Web sites by using the IP address:

Because there is more than one Web site configured to the IP address, you must connect to the Web site by using the host header name. When you try to connect to the Web site by using the IP address, you receive the following error message:
The page cannot be found.

The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
• Clients cannot connect to the Web sites by using host header names:

Multiple host names must be mapped to the single IP address by using a DNS server or a Hosts file.

How to Connect to the Console Session

In Windows Server 2003, when you use Terminal Services, you can connect to the console session (session 0), and at the same time, open a shadow session to it (as long as you connect from a session other than the console). With this added functionality, you can log on to a Windows Server 2003-based server that is running Terminal Services remotely and interact with session 0 as if you were sitting at the physical console of the computer. This session can also be shadowed so that the remote user and the local user at the physical console can see and interact with the same session.


Connecting to the Console Session

When you connect to the console session of a Windows Server 2003-based server, no other user has to be already logged on to the console session. Even if no one is logged on to the console, you are logged on just as if you were sitting at the physical console.

To connect from the remote Windows Server 2003-based computer, open a command prompt, and then type the following command:

mstsc -v:servername /F -console

where mstsc is the Remote Desktop connection executable file, -v indicates a server to connect to, /F indicates full screen mode, and -console is the instruction to connect to the console session.

How can I create a file of a certain size in Windows?

If you need to create a file of a certain size and the file contents don't matter, you can use the Fsutil command as follows:

fsutil createnew

For example,

fsutil file createnew d:\temp\1mbfile.txt 1000000

creates a 1MB file named 1mbfile.txt in the d:\temp folder.

Thunderbird configuration

1.Open Thunderbird

2.Open the "New Account" dialog box. This is accessible from the menus by going to "File", "New", then clicking on Account ...".

3.Select "Email Account" as the New Account type, then click "Next".

4.When asked to enter your identity information, type in your full name and email address in the boxes provided. Then click next.

5.For server information, choose IMAP. Enter "linus.it.uts.edu.au" as both incoming and outgoing servers. Click next

6.For user names, your incoming user name should be filled out for you. If not, enter your FIT username and click next

7.You account name can be set to any name you want to refer to the account by. In this case, we'll keep it to the default and use the email address as the name of the account. Click next when you're done.

8.The next screen will display the list of settings which you have just entered. Make sure you haven't misspelled any of the settings. If you have, you'll need to keep clicking on "Back" until you reach the screen with the typographical error, then "Next" until you reach this screen again. Click "Finish" when you are okay with settings that you have entered.

9.You should now be prompted to enter a mail server password. Click Cancel. We still need to configure a few more settings before we connect.

10. On the main thunderbird window, you should now see your account name on the left hand side. Right click it and select "Properties" to access the "Account Settings" window. You can also access this window by going to the "Edit" menu and selecting "Account settings".

11. Click on "Server Settings" under your account name on the left hand side of the window. In the security settings area, click on the option box next to SSL. Make sure the box next to "Use secure authentication" is not checked. Click on the "Advanced" button to open the "Advanced settings" dialog.

12. In the "Advanced settings" dialog, type in "mail/" as the IMAP server directory and uncheck Server supports folders that contain sub-folders and messages. Click "OK" when finished.

13. On the left hand side of the "Account settings" window, select "Outgoing Server (SMTP)". Select the staff server (the one with linus.it.uts.edu.au in it's name) and click on "Edit".

14. Under "Use secure connection" select "TLS". You can also include a description of the server, e.g. "FIT Staff Outgoing" in the "Description" input box. Click "OK".

15. Back in the "Account settings" window, select the account name from the left hand side. The "Outgoing Server" should match the one you have just edited. Click "OK" when done.

16. You may be asked to accept a website certificate for "linus.it.uts.edu.au". Choose the option for accepting the certificate permanently.

17. You're now set up and ready to go.

Outlook Configuration

For Outlook

1. In Outlook, go to the Tools menu and click on Email Accounts.
2. Select Add a new email account and then click Next.
3. Select POP3 and then click Next.
4. Enter your email information:

Your Name: your name
Email Address: matt@castleman.net (the email address the messages will be sent from)
Incoming Mail server (POP3): mail.castleman.net
Outgoing Mail server (SMTP): mail.castleman.net
User Name: matt@castleman.net
Password: the password for the email address

5. Click on More Settings and Select the Outgoing Server Tab. Check My outgoing server (SMTP) requires authentication. Select Use same settings as my incoming mail server.

6.Click Ok. Click Next. Click Finish.

If you cannot send email using mail.yourdomainname.com as your SMTP server,
it may be because your ISP is blocking port 25 on their network, used for sending outoing mail via the SMTP protocol. In this instance, we recommend using your ISPs outgoing mail server, which can be obtained from your ISP.

the coming posts

the coming posts will be about troubleshooting various issues in web hosting.