Jump to content

User:Misterhaan/Linux Server Install: Difference between revisions

From auWiki
No edit summary
Line 6: Line 6:
a dvd drive and several gigabytes of hard drive space are required for installing fedora 8.  there are cd images available as well, but this guide uses a dvd image.
a dvd drive and several gigabytes of hard drive space are required for installing fedora 8.  there are cd images available as well, but this guide uses a dvd image.


fedora install disc images are available at [url]http://fedoraproject.org/get-fedora[/url].  i use the i386 install dvd — i recommend using bittorrent to get the image faster, provided you’re comfortable using a bittorrent client.  once downloaded, burn the disc image to a dvd.
fedora install disc images are available at [url=http://fedoraproject.org/get-fedora]fedoraproject.org[/url].  i use the i386 install dvd — i recommend using bittorrent to get the image faster, provided you’re comfortable using a bittorrent client.  once downloaded, burn the disc image to a dvd.


the fedora install dvd is bootable, so unless your machine is incredibly old, you should be able to simply put the fedora dvd in the dvd drive and boot up the machine to start the fedora installer.
the fedora install dvd is bootable, so unless your machine is incredibly old, you should be able to simply put the fedora dvd in the dvd drive and boot up the machine to start the fedora installer.
Line 28: Line 28:
create a group with the id you want (i’m using 700 here) and the name you want (i’m using people):
create a group with the id you want (i’m using 700 here) and the name you want (i’m using people):


[code]# groupadd -g 700 people[/code]
[code]
# groupadd -g 700 people[/code]


create the user(s) using that group as the default, and set a password or the user(s):
create the user(s) using that group as the default, and set a password or the user(s):
Line 37: Line 38:
log all the way out, then log in as one of the new users so you can remove the temp user:
log all the way out, then log in as one of the new users so you can remove the temp user:


[code]# userdel tempuser[/code]
[code]
# userdel tempuser[/code]


also turn off services that aren’t needed.  my server doesn’t use bluetooth or ipv6, and i will find and apply updates manually:   
also turn off services that aren’t needed.  my server doesn’t use bluetooth or ipv6, and i will find and apply updates manually:   
Line 67: Line 69:
for nfs, edit [code]/etc/exports[/code] and add one line per directory to share, in the following format:
for nfs, edit [code]/etc/exports[/code] and add one line per directory to share, in the following format:


[code]/path/to/share 192.168.1.0/24(rw,insecure,sync)[/code]
[code]
/path/to/share 192.168.1.0/24(rw,insecure,sync)[/code]


again, the 192.168.1.0/24 may need to change.  run [code]exportfs -ra[/code] to apply the changes made in [code]/etc/exports[/code].  parts of nfs use ports that change when restarted, so the following changes can make force them to use a static port.  edit [code]/etc/sysconfig/nfs[/code] and add the following lines (note some of these may only need to be uncommented):
again, the 192.168.1.0/24 may need to change.  run [code]exportfs -ra[/code] to apply the changes made in [code]/etc/exports[/code].  parts of nfs use ports that change when restarted, so the following changes can make force them to use a static port.  edit [code]/etc/sysconfig/nfs[/code] and add the following lines (note some of these may only need to be uncommented):
Line 85: Line 88:


[code]# service iptables restart
[code]# service iptables restart
#service nfs start
# service nfs start
# chkconfig --level 345 nfs on[/code]
# chkconfig --level 345 nfs on[/code]


Line 93: Line 96:
i put things i build and install under [code]/opt/[/code], so the next step is to create [code]/opt/src/[/code] and then cd into it.  extract the pure-ftpd source:
i put things i build and install under [code]/opt/[/code], so the next step is to create [code]/opt/src/[/code] and then cd into it.  extract the pure-ftpd source:


[code]# tar xjvf /path/to/pure-ftpd-1.0.21.tar.bz2[/code]
[code]
# tar xjvf /path/to/pure-ftpd-1.0.21.tar.bz2[/code]


the source will extract into a directory named pure-ftpd-1.0.21, so cd into that and run these two commands to configure and install pure-ftpd:
the source will extract into a directory named pure-ftpd-1.0.21, so cd into that and run these two commands to configure and install pure-ftpd:
Line 116: Line 120:
this ftp configuration will only allow passive mode connections, and users will only see the contents of their home directory.  for ftp-only users, i create a directory [code]/ftphome/[/code] with subdirectory [code]std/[/code] and other subdirectories for users that should see other directories.  i then create ftp-only users with a command like the following:
this ftp configuration will only allow passive mode connections, and users will only see the contents of their home directory.  for ftp-only users, i create a directory [code]/ftphome/[/code] with subdirectory [code]std/[/code] and other subdirectories for users that should see other directories.  i then create ftp-only users with a command like the following:


[code]# useradd -g ftpgroupname -u ### -d /ftphome/std -s /sbin/nologin username[/code]
[code]
# useradd -g ftpgroupname -u ### -d /ftphome/std -s /sbin/nologin username[/code]


after creating ftp users, give them passwords with [code]passwd username[/code].  the -d specifies the user’s home directory.  i create symlinks in /ftphome/std/ to whatever directories i want to make accessible.  the -s is the shell, and /sbin/nologin means that these users cannot login over ssh.  i also created an ftp group with [code]groupadd -g ### ftpgroupname[/code] and put all my ftp-only users with that as the default group.
after creating ftp users, give them passwords with [code]passwd username[/code].  the -d specifies the user’s home directory.  i create symlinks in /ftphome/std/ to whatever directories i want to make accessible.  the -s is the shell, and /sbin/nologin means that these users cannot login over ssh.  i also created an ftp group with [code]groupadd -g ### ftpgroupname[/code] and put all my ftp-only users with that as the default group.
Line 137: Line 142:
download the latest apache httpd server from [url=http://httpd.apache.org/download.cgi]apache.org[/url].  you want the unix source bz2 file.  change directory to [code]/opt/src/[/code] (create it if it doesn’t exist) and extract the source with the following command:
download the latest apache httpd server from [url=http://httpd.apache.org/download.cgi]apache.org[/url].  you want the unix source bz2 file.  change directory to [code]/opt/src/[/code] (create it if it doesn’t exist) and extract the source with the following command:


[code]# tar xjvf /path/to/httpd-2.2.6.tar.bz2[/code]
[code]
# tar xjvf /path/to/httpd-2.2.6.tar.bz2[/code]


change directory into the newly-created [code]httpd-2.2.6[/code] and run these commands to compile and install apache httpd server:
change directory into the newly-created [code]httpd-2.2.6[/code] and run these commands to compile and install apache httpd server:
Line 147: Line 153:
create an apache user:
create an apache user:


[code]# useradd -g groupname -u 1## -s /dev/null -d /etc/httpd apache[/code]
[code]
# useradd -g groupname -u 1## -s /dev/null -d /etc/httpd apache[/code]


now create the file [code]/etc/rc.d/init.d/httpd[/code] with the following text:
now create the file [code]/etc/rc.d/init.d/httpd[/code] with the following text:
Line 215: Line 222:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80##:80## -j ACCEPT[/code]
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80##:80## -j ACCEPT[/code]


[code]# service iptables restart[/code]
[code]
# service iptables restart[/code]




for mysql, create a user named mysql and allow it to use the default group mysql:
for mysql, create a user named mysql and allow it to use the default group mysql:


[code]# useradd -r mysql[/code]
[code]
# useradd -r mysql[/code]


the mysql website seems to be trying to get you to pay for mysql with professional support, but i’m not a business and just want to download the source.  right now, source downloads can be found at [url=http://dev.mysql.com/downloads/mysql/5.0.html#source]this well-buried location[/url] — go with the compressed gnu tar archive.  it will want you to register, but there’s a small “no thanks” link below that will let you choose a mirror to download from.  once downloaded, change directory to [code]/opt/src/[/code] (create it if it doesn’t exist) and extract the archive:
the mysql website seems to be trying to get you to pay for mysql with professional support, but i’m not a business and just want to download the source.  right now, source downloads can be found at [url=http://dev.mysql.com/downloads/mysql/5.0.html#source]this well-buried location[/url] — go with the compressed gnu tar archive.  it will want you to register, but there’s a small “no thanks” link below that will let you choose a mirror to download from.  once downloaded, change directory to [code]/opt/src/[/code] (create it if it doesn’t exist) and extract the archive:


[code]# tar xzvf /path/to/mysql-5.0.51.tar.gz[/code]
[code]
# tar xzvf /path/to/mysql-5.0.51.tar.gz[/code]


change to the [code]mysql-5.0.51[/code] directory it extracted to, then run the following to configure and install it (make sure to set your own password instead of rootuserpassword):
change to the [code]mysql-5.0.51[/code] directory it extracted to, then run the following to configure and install it (make sure to set your own password instead of rootuserpassword):
Line 248: Line 258:


to enter mysql again (to create accounts for web sites, create databases) use [code]mysql -u root -p[/code] and exit with [code]exit[/code].
to enter mysql again (to create accounts for web sites, create databases) use [code]mysql -u root -p[/code] and exit with [code]exit[/code].


php’s gd library needs libjpeg, so download the jpegsrc package from [url=http://www.ijg.org/files/]ijg.org[/url].  run the following to install:
php’s gd library needs libjpeg, so download the jpegsrc package from [url=http://www.ijg.org/files/]ijg.org[/url].  run the following to install:
Line 270: Line 279:
install the freetype headers (for gd) with the following command:
install the freetype headers (for gd) with the following command:


[code]# yum install freetype-devel[/code]
[code]
# yum install freetype-devel[/code]


download the php source from [url=http://www.php.net/downloads.php]php.net[/url] — get the bz2 source code package.  run the following to install:
download the php source from [url=http://www.php.net/downloads.php]php.net[/url] — get the bz2 source code package.  run the following to install:
Line 283: Line 293:
# echo AddType application/x-httpd-php .php >> /etc/httpd/conf/httpd.conf
# echo AddType application/x-httpd-php .php >> /etc/httpd/conf/httpd.conf
# service httpd restart[/code]
# service httpd restart[/code]


== personal video recorder (mythtv) ==
== personal video recorder (mythtv) ==
Line 302: Line 310:
edit atrpms.repo and change 2 places to fedora 7 version (which also works for fedora 8 — see comments), then install mythtv from yum:
edit atrpms.repo and change 2 places to fedora 7 version (which also works for fedora 8 — see comments), then install mythtv from yum:


[code]# yum -y install mythtv-suite[/code]
[code]
# yum -y install mythtv-suite[/code]


install ivtv drivers (provided your tv card is supported).  make sure to have run [code]yum -y update[/code] recently and rebooted before this step:
install ivtv drivers (provided your tv card is supported).  make sure to have run [code]yum -y update[/code] recently and rebooted before this step:
Line 311: Line 320:
you may also want to install the ivtv package for utilities like ivtv-tune.  this is not required but may be helpful for troubleshooting:
you may also want to install the ivtv package for utilities like ivtv-tune.  this is not required but may be helpful for troubleshooting:


[code]# yum -y install ivtv[/code]
[code]
# yum -y install ivtv[/code]


if your tv card not installed, shut down, install the card, and start up.  otherwise just reboot.  verify that [code]/dev/video[/code] exists, symlinked to [code]/dev/video#[/code] (# is probably 0, but remember it in case it’s not).  test with the command [code]cat /dev/video > /tmp/test_capture.mpg[/code].  let that run for a while, then stop it with ctrl-c.  make sure you can play the file and it looks okay.
if your tv card not installed, shut down, install the card, and start up.  otherwise just reboot.  verify that [code]/dev/video[/code] exists, symlinked to [code]/dev/video#[/code] (# is probably 0, but remember it in case it’s not).  test with the command [code]cat /dev/video > /tmp/test_capture.mpg[/code].  let that run for a while, then stop it with ctrl-c.  make sure you can play the file and it looks okay.
Line 325: Line 335:
restart the mysql service if you added those lines to make sure the changes take effect:
restart the mysql service if you added those lines to make sure the changes take effect:


[code]# service mysqld restart[/code]
[code]
# service mysqld restart[/code]


set up the default mysql databases using the provided sql file:
set up the default mysql databases using the provided sql file:


[code]$ mysql -u root -p < /usr/share/doc/mythtv-docs-0.20.2/database/mc.sql[/code]
[code]
$ mysql -u root -p < /usr/share/doc/mythtv-docs-0.20.2/database/mc.sql[/code]


log into the server in a kde session, and run [i]mythtv setup[/i] from [i]multimedia[/i] in the k menu.  choose your language, then go through the options in order.
log into the server in a kde session, and run [i]mythtv setup[/i] from [i]multimedia[/i] in the k menu.  choose your language, then go through the options in order.
Line 356: Line 368:
now make sure the mythtv server starts automatically:
now make sure the mythtv server starts automatically:


[code]# chkconfig mythbackend on[/code]
[code]
# chkconfig mythbackend on[/code]


finally, make sure the convert to xvid job can actually run (install nuvexport):
finally, make sure the convert to xvid job can actually run (install nuvexport):

Revision as of 16:28, 21 January 2008

this guide is the steps i went through when i upgraded my “server” hecubus to fedora 8. hecubus serves as a file server (samba and nfs), ftp server (pure-ftp), web server (apache, mysql, and php), and personal video recorder (mythtv). setup for fedora 8 as well as these other packages are detailed.

gnu/linux (fedora)

this guide uses [url=/geek/computers.php#hecubus]hecubus[/url] as an example. in general, the hardware in hecubus is whatever is left over after i upgrade my main machine. it’s not a server-class machine, but it keeps up okay in the server roles i use it for because there are really only 4 client machines that ever connect to it (the demand on it is relatively light). some may be able to get acceptable results with less powerful hardware, while others may need more powerful hardware. specific requirements are listed at the beginning of each section.

a dvd drive and several gigabytes of hard drive space are required for installing fedora 8. there are cd images available as well, but this guide uses a dvd image.

fedora install disc images are available at [url=http://fedoraproject.org/get-fedora]fedoraproject.org[/url]. i use the i386 install dvd — i recommend using bittorrent to get the image faster, provided you’re comfortable using a bittorrent client. once downloaded, burn the disc image to a dvd.

the fedora install dvd is bootable, so unless your machine is incredibly old, you should be able to simply put the fedora dvd in the dvd drive and boot up the machine to start the fedora installer.

once the fedora menu comes up, press enter to install in graphical mode, then choose install or upgrade an existing system. after a while it asks if you want to test your installation media. i generally do this the first time installing from a disc to ensure i had a good download. note that it takes a long time though. after this step, anaconda (the graphical install program) starts up.

choose your language and keyboard, then choose install fedora if given the choice between installing and upgrading. the next screen lists any hard disks found on the system and allows you to set partitioning options. i go with the default, then deselect all but my primary hard disk (the other two hold data that i don’t want to lose. also check the box for review and modify partitioning layout. upon clicking next, you will be warned that data will be lost, but that’s only on the primary disk since the others were deselected.

on the next screen i don’t want to use lvm, so i make a note of the size of swap, then remove the lvm group that was automatically set up (delete volgroup00, then the lvm pv partition). now create a partition with the type swap the same size as the one in the lvm group, then create an ext3 partition for the rest of the space, mounted at /. i select [i]force to be a primary partition[/i] on both of these. the other drives’ partitions should be given a mount point so that you don’t have to manually add them to [code]/etc/fstab[/code] later.

the next screen allows the boot loader (grub) options to be changed, but i just keep the defaults. after that is the networking screen (provided anaconda sees your network adapter). i change hostname to set the hostname manually and enter hecubus since that’s my server’s name. if you don’t use ipv6 (most people probably don’t), you can click the edit button and uncheck [i]enable ipv6 support[/i] — it may speed things up.

next is time zone selection, where i find it easiest to click on the map to choose my time zone. i also leave the [i]system clock uses utc[/i] box checked (note that some other operating systems, like windows, don’t let you do this so it may be a bad idea if your dual-booting your server for some reason). next it asks you to specify a password for the root user. since root can do anything this should be a strong password, but you will need it later so make sure you can remember it somehow.

after that is software package selection — i deselect everything here and then choose customize now near the bottom, then move on to the next screen. for desktop environments, deselect gnome and if you’re going to install mythtv, select kde. for applications, deselect graphical internet. under development, select development libraries and development tools. select windows file server from under servers, and deselect mail server. the other defaults are fine, so click next, wait a while, then click next again and fedora will start installing. this will likely take a very long time.

eventually it will ask you to reboot, and you’ll then get the post-install setup. on the firewall screen, leave SSH checked but don’t check any others — we’ll open those as we set up the servers. i disable selinux, but you may want it on (i’m not sure if it interferes with anything else). on the date and time screen, go to the network time protocol tab and check enable network time protocol. this means you won’t have to worry about your system time being off. on the create user page, i create tempuser with the same as the password — i’ll delete this later after creating users with the ids i want. the system will reboot again if you turned off selinux.

log in with tempuser. i do this over ssh from a different machine, but you can log into a gui session on the server if you prefer — just start a terminal after you do. i have my users share a default group so that they are better able to use each others’ files. to create users and groups, you need to become root. both [code]su[/code] and [code]su -[/code] will ask you for the root password and then let you become root, but [code]su -[/code] also gives you root’s context (this means you don’t have to specify the path for administrator commands). you should not log in as root directly. in the rest of this guide, lines starting with $ can be run by a normal user, but lines starting with # must be run as root.

create a group with the id you want (i’m using 700 here) and the name you want (i’m using people):

[code]

  1. groupadd -g 700 people[/code]

create the user(s) using that group as the default, and set a password or the user(s):

[code]# useradd -g people -u 703 misterhaan

  1. passwd misterhaan[/code]

log all the way out, then log in as one of the new users so you can remove the temp user:

[code]

  1. userdel tempuser[/code]

also turn off services that aren’t needed. my server doesn’t use bluetooth or ipv6, and i will find and apply updates manually:

[code]# chkconfig bluetooth off

  1. chkconfig ip6tables off
  2. chkconfig yum-updatesd off[/code]

file servers (samba and nfs)

samba server allows a linux machine to share some of its directories with windows machines. nfs allows a linux machine to share some of its directories with other linux machines. i set up both of these to be accessible only to my subnet, which is 192.168.x.* (in iptables, i write this as 192.168.x.0/24).

the requirements for running a file server are hard drive space (the more the better — i have 390 gig total in my server) and a network adapter.

edit (as root) the file [code]/etc/samba/smb.conf[/code] to set your samba server options. for the most part, you can follow the examples in the file to set up shared directories.

create samba users with [code]smbpasswd -a username[/code] (omit the -a to change password of existing user). allow smb connections from the lan by adding the following lines to [code]/etc/sysconfig/iptables[/code], just before the first line with -j REJECT:

[code]-A RH-Firewall-1-INPUT -p udp -m udp -s 192.168.1.0/24 --dport 137 -j ACCEPT -A RH-Firewall-1-INPUT -p udp -m udp -s 192.168.1.0/24 --dport 138 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -s 192.168.1.0/24 --dport 139 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -s 192.168.1.0/24 --dport 445 -j ACCEPT[/code]

most routers default to 192.168.1.* for lan ip addresses — change the 192.168.1.0/24 accordingly if yours is different. after the file has been changed, restart the firewall to apply the changes, start the samba service, then make it autostart:

[code]# service iptables restart

  1. service smb start
  2. chkconfig --level 345 smb on[/code]

for nfs, edit [code]/etc/exports[/code] and add one line per directory to share, in the following format:

[code] /path/to/share 192.168.1.0/24(rw,insecure,sync)[/code]

again, the 192.168.1.0/24 may need to change. run [code]exportfs -ra[/code] to apply the changes made in [code]/etc/exports[/code]. parts of nfs use ports that change when restarted, so the following changes can make force them to use a static port. edit [code]/etc/sysconfig/nfs[/code] and add the following lines (note some of these may only need to be uncommented):

[code]RQUOTAD_PORT=875 LOCKD_TCPPORT=32803 LOCKD_UDPPORT]32769 MOUNTD_PORT=892 STATD_PORT=662[/code]

now allow those ports through the firewall with the following in [code]/etc/sysconfig/iptables[/code]:

[code]-A RH-Firewall-1-INPUT -m state --state NEW -p tcp -s 192.168.1.0/24 -m multiport --dports 111,662,875,892,2049,32803 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -p udp -s 192.168.1.0/24 -m multiport --dports 111,662,875,892,2049,32769 -j ACCEPT[/code]

portmap runs on port 111, and nfsd uses 2049 by default, so that's where those ports come from (the others are from the port settings). apply the new firewall rules, start nfs, and make it autostart:

[code]# service iptables restart

  1. service nfs start
  2. chkconfig --level 345 nfs on[/code]

ftp server (pure-ftpd)

i like to use pure-ftpd as my ftp server, and i compile and install it myself (not sure if there are rpm packages available). download the source from [url=http://download.pureftpd.org/pub/pure-ftpd/releases/]pureftpd.org[/url] — get the latest version with .tar.bz2 as it's a bit smaller than .tar.gz.

i put things i build and install under [code]/opt/[/code], so the next step is to create [code]/opt/src/[/code] and then cd into it. extract the pure-ftpd source:

[code]

  1. tar xjvf /path/to/pure-ftpd-1.0.21.tar.bz2[/code]

the source will extract into a directory named pure-ftpd-1.0.21, so cd into that and run these two commands to configure and install pure-ftpd:

[code]$ ./configure --without-banner --with-paranoidmsg --with-virtualchroot --with-ftpwho

  1. make install-strip
  2. cp contrib/redhat.init /etc/rc.d/init.d/pure-ftpd[/code]

edit [code]/etc/rc.d/init.d/pure-ftpd[/code] and change “prog=pure-config.pl” to “prog=pure-ftpd” and “$fullpath /etc/pure-ftpd.conf --daemonize” to “$fullpath -A -Z -S ## -P #.#.#.# -p 50000:50100 -u ### &”. the numbers to fill in are ## = the port you want to serve ftp on (default is 21, but i change mine so have to put that here), #.#.#.# = the public (internet) ip of the server, ### = lowest user id that can log in via ftp. now start and set for automatic start:

[code]# chmod 755 /etc/rc.d/init.d/pure-ftpd

  1. service pure-ftpd start
  2. chkconfig --add pure-ftpd[/code]

now ftp should be running, but it's not accessible yet. open port ## (set above) and ports 50000:50100 (also set above) by adding these lines to [code]/etc/sysconfig/iptables[/code]:

[code]-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport ## -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 50000:50100 -j ACCEPT[/code]

restart the firewall with [code]service iptables restart[/code]. i run my ftp accessible from the internet (so i can get my stuff when i’m not at home), so since my server is behind a router i also need to forward ports ## and 50000:50100 in my router configuration to my server. this is probably different for different routers, but for many the first step is to load up http://192.168.1.1/ in a browser.

this ftp configuration will only allow passive mode connections, and users will only see the contents of their home directory. for ftp-only users, i create a directory [code]/ftphome/[/code] with subdirectory [code]std/[/code] and other subdirectories for users that should see other directories. i then create ftp-only users with a command like the following:

[code]

  1. useradd -g ftpgroupname -u ### -d /ftphome/std -s /sbin/nologin username[/code]

after creating ftp users, give them passwords with [code]passwd username[/code]. the -d specifies the user’s home directory. i create symlinks in /ftphome/std/ to whatever directories i want to make accessible. the -s is the shell, and /sbin/nologin means that these users cannot login over ssh. i also created an ftp group with [code]groupadd -g ### ftpgroupname[/code] and put all my ftp-only users with that as the default group.

web server (apache, mysql, php)

i do web development as a hobby, using apache httpd, php, and mysql. hecubus is my test web server, so it needs to be set up to be able to run php / mysql through apache.

requirements for running a web server are a moderate amount of disk space (a few hundred megabytes should do it) and a network card.

if you are also going to be installing mythtv, that’s going to require apache httpd, php, and mysql from yum and not from source. either way you can install all three from yum, start them, and set them to startup automatically with the following commands:

[code]# yum -y install httpd php mysql mysql-server php-mysql php-mbstring

  1. service httpd start
  2. service mysqld start
  3. chkconfig httpd on
  4. chkconfig mysqld on[/code]

if you go that route, ignore everything else here besides editing config files.

download the latest apache httpd server from [url=http://httpd.apache.org/download.cgi]apache.org[/url]. you want the unix source bz2 file. change directory to [code]/opt/src/[/code] (create it if it doesn’t exist) and extract the source with the following command:

[code]

  1. tar xjvf /path/to/httpd-2.2.6.tar.bz2[/code]

change directory into the newly-created [code]httpd-2.2.6[/code] and run these commands to compile and install apache httpd server:

[code]$ ./configure --prefix=/etc/httpd --enable-module=rewrite --enable-shared=rewrite --enable-module=so $ make

  1. make install[/code]

create an apache user:

[code]

  1. useradd -g groupname -u 1## -s /dev/null -d /etc/httpd apache[/code]

now create the file [code]/etc/rc.d/init.d/httpd[/code] with the following text:

[code]#!/bin/sh

  1. Startup script for the Apache Web Server
  2. chkconfig: 345 85 15
  3. description: Apache is a World Wide Web server. It is used to serve \
  4. HTML files and CGI.
  5. processname: httpd
  6. pidfile: /var/run/httpd.pid
  7. config: /etc/httpd/conf/access.conf
  8. config: /etc/httpd/conf/httpd.conf
  9. config: /etc/httpd/conf/srm.conf


  1. Source function library.

. /etc/rc.d/init.d/functions

  1. See how we were called.

case "$1" in

 start)

echo -n "Starting httpd: " daemon /etc/httpd/bin/httpd echo touch /var/lock/subsys/httpd ;;

 stop)

echo -n "Shutting down http: " killproc httpd echo rm -f /var/lock/subsys/httpd rm -f /var/run/httpd.pid ;;

 status)

status httpd ;;

 restart)

$0 stop $0 start ;;

 reload)

echo -n "Reloading httpd: " killproc httpd -HUP echo ;;

 *)

echo "Usage: $0 {start|stop|restart|reload|status}" exit 1 esac

exit 0[/code]

make it executable, start the server, and make it start automatically:

[code]# chmod 755 /etc/rc.d/init.d/httpd

  1. service httpd start
  2. chkconfig --add httpd[/code]

if you need any special configuration, edit the config file at [code]/etc/httpd/conf/httpd.conf[/code]. i run multiple test sites under multiple ports so i need to do this, but it’s not always necessary. the default path for a yum install is [code]/var/www/html/[/code].

next open port(s) through the firewall. i limit port 80 to my lan but serve my other ports to the internet:

[code]-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -s 192.168.1.0/24 --dport 80 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80##:80## -j ACCEPT[/code]

[code]

  1. service iptables restart[/code]


for mysql, create a user named mysql and allow it to use the default group mysql:

[code]

  1. useradd -r mysql[/code]

the mysql website seems to be trying to get you to pay for mysql with professional support, but i’m not a business and just want to download the source. right now, source downloads can be found at [url=http://dev.mysql.com/downloads/mysql/5.0.html#source]this well-buried location[/url] — go with the compressed gnu tar archive. it will want you to register, but there’s a small “no thanks” link below that will let you choose a mirror to download from. once downloaded, change directory to [code]/opt/src/[/code] (create it if it doesn’t exist) and extract the archive:

[code]

  1. tar xzvf /path/to/mysql-5.0.51.tar.gz[/code]

change to the [code]mysql-5.0.51[/code] directory it extracted to, then run the following to configure and install it (make sure to set your own password instead of rootuserpassword):

[code]$ ./configure --prefix=/etc/mysql $ make

  1. make install[/code]
  2. cp support-files/my-small.cnf /etc/my.cnf
  3. cp support-files/mysql.server /etc/rc.d/init.d/mysqld
  4. chmod 755 /etc/rc.d/init.d/mysqld
  5. cd /etc/mysql/
  6. bin/mysql_install_db --user=mysql
  7. chgrp -R mysql .
  8. service mysqld start
  9. chkconfig --add mysqld
  10. cp bin/mysql /usr/bin/
  11. chmod 755 /usr/bin/mysql

$ mysql -u root > update mysql.user set password=password('rootuserpassword') where user='root'; > delete from mysql.user where user=; > flush privileges; > exit[/code]

to enter mysql again (to create accounts for web sites, create databases) use [code]mysql -u root -p[/code] and exit with [code]exit[/code].

php’s gd library needs libjpeg, so download the jpegsrc package from [url=http://www.ijg.org/files/]ijg.org[/url]. run the following to install:

[code]# cd /opt/src/

  1. tar xzvf /path/to/jpegsrc.v6b.tar.gz
  2. cd jpeg-6b/
  3. ./configure --enable-shared
  4. make
  5. make install[/code]

gd also needs libpng, so download it from [url=http://sourceforge.net/project/showfiles.php?group_id=5624&package_id=5683]sourceforge[/url] — get the latest version source .bz2 file (not the one that says no-config). run the following to install:

[code]# cd /opt/src/

  1. tar xjvf /path/to/libpng-1.2.24.tar.bz2
  2. cd libpng-1.2.24/
  3. ./configure
  4. make
  5. make install[/code]

install the freetype headers (for gd) with the following command:

[code]

  1. yum install freetype-devel[/code]

download the php source from [url=http://www.php.net/downloads.php]php.net[/url] — get the bz2 source code package. run the following to install:

[code]$ cd /opt/src/ $ tar xjvf /path/to/php-5.2.5.tar.bz2 $ cd php-5.2.5/ $ ./configure --with-apxs2=/etc/httpd/bin/apxs --with-mysql=/etc/mysql --with-mysqli=/etc/mysql/bin/mysql_config --with-gd --with-freetype-dir=/usr --with-jpeg-dir=/usr/local/lib --with-zlib-dir=/usr/local --enable-mbstring $ make

  1. make install
  2. cp php.ini-dist /usr/local/lib/php.ini
  3. echo AddType application/x-httpd-php .php >> /etc/httpd/conf/httpd.conf
  4. service httpd restart[/code]

personal video recorder (mythtv)

recording tv to files on a hard drive is in many ways better than recording to vhs tape. mythtv has commercial detection that can automatically skip commercials for you, and you don’t have to worry about changing or rewinding your tape.

i have mythtv record the shows i want to watch to mpeg2 format using the hardware encoder on my hauppage pvr 150 card, then detect commercials and convert to xvid without the commercials.

requirements for mythtv as a personal video recorder are some sort of linux gui (kde works well — hopefully you already installed it!), a tv tuner card (this guide is for ivtv cards, which encompasses most hauppage cards), and a good deal of hard drive space to hold the shows and / or movies you want to record. for reference, a half-hour show is 1.1 gigabytes in mpeg2 format, and around 150 megabytes in xvid format with the commercials stripped and the other settings i use.

to start, add atrpms and freshrpms repositories to yum:

[code]# cd /etc/yum.repos.d/

  1. wget http://wilsonet.com/mythtv/atrpms.repo
  2. rpm --import http://atrpms.net/RPM-GPG-KEY.atrpms
  3. wget http://wilsonet.com/mythtv/freshrpms.repo[/code]

edit atrpms.repo and change 2 places to fedora 7 version (which also works for fedora 8 — see comments), then install mythtv from yum:

[code]

  1. yum -y install mythtv-suite[/code]

install ivtv drivers (provided your tv card is supported). make sure to have run [code]yum -y update[/code] recently and rebooted before this step:

[code]# yum -y install ivtv-firmware

  1. yum -y install ivtv-kmdl-`uname -r`[/code]

you may also want to install the ivtv package for utilities like ivtv-tune. this is not required but may be helpful for troubleshooting:

[code]

  1. yum -y install ivtv[/code]

if your tv card not installed, shut down, install the card, and start up. otherwise just reboot. verify that [code]/dev/video[/code] exists, symlinked to [code]/dev/video#[/code] (# is probably 0, but remember it in case it’s not). test with the command [code]cat /dev/video > /tmp/test_capture.mpg[/code]. let that run for a while, then stop it with ctrl-c. make sure you can play the file and it looks okay.

mysql should already be set up with a password set for the root user and also running as a service. the following lines are likely to improve mythtv database performance if you add them to /etc/my.cnf, but as i don’t keep recordings in mythtv for longer than it takes to export them i don’t bother:

[code]key_buffer = 16M table_cache = 128 sort_buffer_size = 2M myisam_sort_buffer_size = 8M query_cache_size = 16M[/code]

restart the mysql service if you added those lines to make sure the changes take effect:

[code]

  1. service mysqld restart[/code]

set up the default mysql databases using the provided sql file:

[code] $ mysql -u root -p < /usr/share/doc/mythtv-docs-0.20.2/database/mc.sql[/code]

log into the server in a kde session, and run [i]mythtv setup[/i] from [i]multimedia[/i] in the k menu. choose your language, then go through the options in order.

under [i]general[/i], the [i]host address backend setup[/i] defaults are fine except for the [i]directory to hold recordings[/i] (on the second screen), which i change to one of my secondary drives. on the global backend setup, make sure tv format (ntsc) and channel frequency table (us-cable) are correct. the default settings are fine again until you reach [i]job queue (host-specific)[/i]. i am going to set up user jobs to run nuvexport and convert my recordings to xvid, so i need to check the boxes to allow all 4 user jobs (technically i only need user job 1, but it’s easier to enable all 4 in case i need another one later). you can also change the job queue start and end times if you don’t want your server detecting commercials or encoding video whenever it feels like it. this hasn’t caused any significant slowness for me, so i leave it at the default. on the [i]job queue (job commands)[/i] screen, change user job #1 description to convert to xvid, and user job #1 command to nuvexport-xvid --input="%FILE%". you can also enter other user jobs if you want to convert to different formats or with different settings, but i do everything the same way.

under [i]capture cards[/i], choose [i]new capture card[/i] to set up your tuner card. for my card, i change card type to "mpeg-2 encoder card (pvr-x50, pvr-500)" and everything else defaults correctly. if your video device is not /dev/video0 though, make sure to change it.

under [i]video sources[/i], choose [i]new video source[/i]. give it whatever name you like (for example, “xyz cable”). in the us or canada, schedulesdirect can hook you up with tv listings for $20/year after a free 7-day trial. unfortunately i don’t know of any free services. sign up for an account at [url=http://www.schedulesdirect.org/]schedulesdirect.org[/url] if you don’t already have one, and set up your channels on their site. back in mythtv, enter your user id and password, then click [i]retrieve lineups[/i]. your lineup should come into [i]data direct lineup[/i].

under [i]input[/i], you connect your tv card to the listings. find your tuner in the list. enter a display name if you like (i use “tv”). choose the video source you chose earlier, then click [i]fetch channels from listings source[/i].

under [i]channel editor[i], i edit each channel and change its name to the network it shows (i’d rather see nbc than wxxx).

from a shell, get your tv listings into the database, then start the mythtv server:

[code]$ mythfilldatabase

  1. service mythbackend start[/code]

run mythtv frontend from [i]multimedia[/i] under the k menu for some additional configuration. go to [i]utilities / setup[/i], [i]setup[/i], then [i]general[/i]. hit next until you reach [i]mythfilldatabase[/i], and check the box for [i]automatically run mythfilldatabase[/i]. i set mine to run every day, and choose times when i know i’m not going to record anything (5 - 15). it’s also nice to leave it checked to run at the suggested time.

under [i]tv settings[/i], [i]recording profiles[/i], choose your encoder, go to [i]high quality[/i] and set the width (720) and height (480) on the second page.

under [i]tv settings[/i], [i]recording priorities[/i], select [i]recording priorities[/i]. i set start early to 1 and end late to 3 to help catch the entire show if the channel is running a little early or late.

now make sure the mythtv server starts automatically:

[code]

  1. chkconfig mythbackend on[/code]

finally, make sure the convert to xvid job can actually run (install nuvexport):

[code]# yum -y install id3lib

  1. rpm -Uvh http://forevermore.net/files/nuvexport/nuvexport-0.4-0.20071226.svn.noarch.rpm[/code]

edit [code]/etc/nuvexportrc[/code] as root, and make it look like this (make sure to fill in a useful path):

[code]#

  1. nuvexportrc:
  2. This file contains the configuration for nuvexport, and should be installed
  3. as /etc/nuvexportrc. You can also copy this file to ~/.nuvexportrc, where
  4. nuvexport will look first, if you wish to create settings local to a
  5. specific user.
  6. I try to use this file to document all of the commandline options supported
  7. by nuvexport, but it is quite likely that a few slip through here and there
  8. unnoticed. Feel free to poke around in the code for add_arg() calls to see
  9. all of the available options.
  1. Anything placed within the <nuvexport> section will be interpreted
  2. as a global option. Use this section for options that don't relate
  3. specifically to any particular exporter.

<nuvexport>

  1. Set export_prog to ffmpeg, transcode or mencoder, depending on your
  2. preference of program for exports. This is equivalent to --ffmpeg,
  3. --transcode or --mencoder
   export_prog=mencoder
  1. Any other parameters set in this file are equivalent to using the equivalent
  2. setting as a commandline option. For boolean options like --deinterlace
  3. (--nodeinterlace), use deinterlace=yes (or no, true or false) instead.
  4. Actual commandline options will override anything in this file.
  1. Preferred mode -- if you don't set this, nuvexport will ask you what you
  2. would like to do. Use --mode or any of the mode symlinks (like
  3. nuvexport-xvid) to override.
  4. mode=xvid
  1. Setting underscores to yes will convert whitespace in filenames to an
  2. underscore character (which some people seem to prefer)
   underscores=no
  1. Setting require_cutlist to yes will tell nuvexport to show only those
  2. recordings that have a cutlist
  3. require_cutlist=no
  1. By default, nuvexport picks what it thinks is a good name for your file
  2. (doing its best to avoid printing "Untitled" into the filename). Setting
  3. name will let you change the output format of the filename generated by
  4. nuvexport. Even after this formatting, nuvexport will still do some basic
  5. replacements to make sure that illegal filename characters (eg. /\:*?<>|)
  6. are replaced with a dash (or " with a '). The following format variables
  7. are supported:
  8. %f -> full path to the filename
  9. %c -> the chanid of the show
  10. %a -> start time in YYYYMMDDHHMMSS format
  11. %b -> end time in YYYYMMDDHHMMSS format
  12. %t -> title (show name)
  13. %s -> subtitle (episode name)
  14. %h -> hostname where the file resides
  15. %m -> showtime in human-readable format (see --date below)
  16. %d -> description
  17. %% -> a % character
   filename=%t - %a - %s
  1. By default, nuvexport uses an American-style date to represent showtimes in
  2. lists and filenames. Use --date to override that with the format of your
  3. choosing. See the UnixDate section `perldoc Date::Manip` for formatting
  4. options.
  5. date=%m/%d, %i:%M %p
  1. Nuvexport has the option to crop a percentage of the border of each recording
  2. in order to get rid of the unsightly edges of the tv signal. The default 2%
  3. approximates the overscan of an average TV, but you can alter this from 0 to
  4. 5% to fit your preferences. Please keep in mind that this amount is removed
  5. prior to making any aspect conversions like removing black bars from 4:3
  6. recordings to make a 16:9 export.
   crop_pct = 0
  1. Alternatively, you can override the general crop_pct to crop a different
  2. amount from specific sides of the recording.
  3. crop_top = 2
  4. crop_right = 2
  5. crop_bottom = 2
  6. crop_left = 2
  1. You can also override the output aspect ratio. This is useful in combination
  2. with crop_top=12.5 and crop_bottom=12.5 to remove the black bars from the
  3. top/bottom of recordings broadcast in fake widescreen.
  4. out_aspect = 16:9

</nuvexport>

  1. The sections below work as above, with each more specific section overriding
  2. the more generic.

<generic>

  1. Default to export to the current directory
   path = /path/to/xvidtv/
  1. Use the cutlist (not to be confused with the commercial flag list) when
  2. exporting.
   use_cutlist = yes
  1. Tell mythcommflag to generate a cutlist from the commercial flags before
  2. exporting. Don't forget to enable use_cutlist above, too.
  gencutlist = yes
  1. Contrary to popular belief, enabling multipass will not make your recordings
  2. look better. What it will do, however is guarantee that the bitrate you
  3. choose will be the average bitrate of your entire encode (meaning that your
  4. exports will end up being about the same size per-minute), and that you
  5. will receive the best overall quality for a files of the same size.
   multipass = no
  1. Disabling noise reduction can speed up your exports dramatically, but at the
  2. expense of some quality. For your convenience, this is also aliased on
  3. the commandline as --denoise (or --nodenoise), as well as
  4. --noise_reduction.
   noise_reduction = no
  1. Deinterlace the video so that it looks better on software players.
   deinterlace     = yes
  1. Crop about 2% from the border of the recording before encoding. This is done
  2. to get rid of part of the broadcast signal that is usually obscured by the
  3. tv's overscan.
   crop = no
  1. You can create settings for each export module type. These are the
  2. second-most generic sections, and will only be reached if there are no
  3. matches in the full or generic module names.
  4. If you have a particularly dirty signal, you might want to try to disable
  5. fast_denoise (it's actually part of yuvdenoise, which both the ffmpeg
  6. and transcode exporters call). It can be almost twice as slow as the
  7. default "fast" normal noise reduction, but it considerably more effective.
  8. The latest version of yuvdenoise (which is called directly by the ffmpeg
  9. exporters) does not support this option, so it is ignored in that case.
   fast_denoise = yes
  1. If nuvexport is having trouble detecting the *input* aspect ratio of your
  2. recordings (MythTV used to hard-code all software-encoded files as 1:1
  3. regardless of the true aspect), set this option to one of the following:
  4. force_aspect = [ 1:1 4:3 16:9 2.21:1 ]

</generic>

<ffmpeg>

  1. ffmpeg is almost twice as fast if you disable noise reduction
  2. noise_reduction = no
  3. By default, nuvexport's ffmpeg module lets ffmpeg handle deinterlacing.
  4. I've found that this provides the best results, but if you wish to let
  5. yuvdenoise do it instead, set deint_in_yuvdenoise to a true value.
  6. deint_in_yuvdenoise = no

</ffmpeg>

<transcode>

  1. Mythtranscode will always be used for nupplevideo recordings because
  2. transcode can't read them, but setting force_mythtranscode to yes will
  3. force nuvexport to call mythtranscode when using the transcode exporter for
  4. mpeg recordings, too. This may help problems that some people have been
  5. having with transcode not recognizing certain dvb recordings, as well as
  6. transcode not working properly on certain ivtv recordings.
   force_mythtranscode = yes
  1. Setting both force_mythtranscode and mythtranscode_cutlist to yes will tell
  2. nuvexport to use mythtranscode's built-in cutlist functions, rather than
  3. having transcode use its own. I've found that the cutlists for a handful
  4. of ivtv recordings that do not work properly with transcode's internal
  5. cutlist handler.
   mythtranscode_cutlist = yes

</transcode>

<mencoder> </mencoder>

  1. You can also create settings for generic export module names. These will
  2. only be overridden by full module names.

<XviD>

   vbr          = yes   # Enable vbr to get the multipass/quantisation options
                        # (enabling multipass or quantisation automatically enables vbr)
   multipass    = no   # You get either multipass or quantisation; multipass will override
   quantisation = 5     # 4 through 6 is probably right...  1..31 are allowed (lower is better quality)
   a_bitrate    = 96   # Audio bitrate of 128 kbps
   v_bitrate    = 750   # Remember, quantisation overrides video bitrate
   width        = 720   # Height adjusts automatically to width, according to aspect ratio
   height       = 480

</XviD>

  1. The mp3 bitrate used by MythTV's software encoder is 128, so there is no
  2. real need to go any higher in exports. You can, of course, turn this up if
  3. you get your recordings from other sources.

<MP3>

   bitrate = 96

</MP3>

  1. If you want to provide settings for a very specific export module, you can
  2. use its full name, and it will override any more generic settings.
  1. The MP4 encoder for ffmpeg has a few options unique to itself

<ffmpeg::MP4>

  1. Codec to use (mpeg4 or h264). Please note that h264 support requires the
  2. SVN version of ffmpeg (not CVS!). In fact, even the mpeg4 codec works
  3. better with the SVN version.
  4. Note: The h.264 files exported by nuvexport seem to play fine on ipods,
  5. but lack the atom necessary to be recognized by iTunes, so you will have to
  6. find other means to get the exports onto your ipod (gtkpod works great).
   mp4_codec = h264
  1. Framerate to use: auto, 25, 23.97, 29.97. PAL will always be 25 fps, and
  2. auto will set 29.97 for everything over 320x288 and 23.97 for the rest.
   mp4_fps = auto
  1. Enable ipod compatibility mode. Aside from forcing a max resolution of
  2. 640x480, this basically just sets motion detection reference frames (-refs)
  3. to 2 instead of 7 (the ipod can only handle 2), and thus a small drop in
  4. motion detection quality.
   ipod = yes

</ffmpeg::MP4>

  1. As does the PSP exporter

<ffmpeg::PSP>

  1. PSP framerate (high=29.97, low=14.985)
   psp_fps = low
  1. PSP resolution (320x240, 368x208 or 400x192)
   psp_resolution = 320x240
  1. PSP video bitrate (high=768, low=384)
   psp_bitrate = high
  1. Create a thumbnail to go with the PSP video export?
   psp_thumbnail = yes

</ffmpeg::PSP>

  1. You can also add flags to the one and only mencoder option

<mencoder::XviD>

   multipass = no

</mencoder::XviD>

  1. You can also make specific profiles called with the --profile parameter that
  2. will override other config options (but not commandline arguments).
  3. For example, you could make a profile that would encode your favorite show
  4. with your favorite settings.

<profile::sample>

   title       = test
   export_prog = transcode
   mode        = xvid
   confirm     = true

</profile::sample>

  1. Or crop the black bars off of the top/bottom of fake widescreen shows.

<profile::samplewide>

   title       = test
   export_prog = ffmpeg
   mode        = mp4
   out_aspect  = 16:9
   crop_pct    = 0
   crop_top    = 12.5
   crop_bottom = 12.5
   width        = 528
   height       = 360

</profile::samplewide>[/code]

since i don't plan on logging into my server for x sessions, i use mythweb (installed to [code]/var/www/html/mythweb/[/code] in case you need to point apache to it) to schedule recordings. access it from http://yourserver/mythweb/. to record something and have it automatically convert to xvid, first find the show either through browsing the listings from the link in the upper left, or using the search box in the upper right. click on the link for the show and choose whichever schedule option works best for you. under advanced options change recording profile to high quality, uncheck auto-transcode, and check convert to xvid. click update recording settings and your show will be scheduled to record.