How to Install and configure Solaris Web Server
Set up a multipurpose Solaris web server
Contents
Introduction
This HOWTO explains how to set up a multipurpose Solaris web server.
Purpose
The purpose of this howto is to provide instructions on how to install a multipurpose Web server on a Solaris box.
Scope
- "OS:" Solaris 10, using zones.
- "HW:" Via Epia 800 ITX board
- "Utilities:"
- Orca
- Sendmail
- tripwire replacement
- "Applications:"
- Apache
- Twiki
- Bugzilla
- MySQL
References
- Ref1: http://solaris-x86.org
- Ref2: Free NIC drivers for Solaris
- Ref3: HOWTO setup a home-server
- Ref4: Sendmail Configuration for Solaris 10
- Ref5: cf/README for sendmai
- Ref6: Setting up sendmail to use an SMTP server on Red Hat 9
- http://www.boran.com/security/sp/Solaris_hardening2.html
Overview
ToDo
- Create FLAR
- Create install DVD
- Test Install DVD
- Install SE tool.
- Install ORCA.
- Install MySQL
- Install BugZilla
- Create FLAR
- Install
- Install Moodle
- Have Apache support SSL
- Have Apache support LDAP
- install LDAP server
- AIDE: handle dead symlinks
- AIDE: handle mnttab
Steps
Installing Solaris 10 on x86
- Download the media from
- Insert V1
- boot
- Select 1 Solaris Interactive
- Select a language: 0
- The X is openlook, so the cursor must be moved over the window to enable data entry in the window.
(true only if use of graphical environment, for this puspose normal text based instalation is OK)
- enter hostname
- Select geographical region
- Make sure the date and time are correct
- Enter root password, twice
- Confirm, Hostname, and region.
- Installer options
- Reboot automatically: Yes
- Eject CDs: Yes
- Notice; Ok
- Specify Media: CD/DVD
- Read and accept the license.
- Type of install: Custom
- Select software localizations: just select next, unless you want to start installing any other language than the default English.
- Select system locale: POSIX C
- Select products: Solaris Software Companion CD
- Additional Products: None
- Select Solaris software group: Entire Group
- Disk Selection: c0d0
- unless you have more disks and want to install onto secondary disk.
- "PLEASE NOTE;" This will destroy your disk by default.
- Select Disks for fdsik partition customization: c0d0
- Customize fdisk partition: Solaris everything
- Select the rest as unused.
- You will be asked about slices in the next step.
- Lay out file system: select the default
- You can slice this a lot of ways, and most will be dependent on what you want to use the system for.
- Install: this takes about 9 minutes.
- When primary installation is done, you need to manually eject the V1 boot CD. Go figure...
- When booting from the HD, it will be loading smf(5) descriptions x/87
- NFS version 4: default no
- Specify media: CD/DVD
- It will take three minutes to read the CD before you are prompted for install Now
- Installing V2 takes about 12-15 minutes.
- V3 takes about 5 minutes.
- V4 takes about 7? minutes.
- CCD takes about 20 minutes.
Getting the network running
- Identify the Driver see BigAdmin HCL
- Transfer the driver to the Solaris box if not there
- e.g. through Mounting USB Key under solaris
Rhine driver
- Get the driver from http://homepage2.nifty.com/mrym3/taiyodo/eng/
- Unpack it
- cp rh-1.0.24.tar.gz /tmp
- cd /tmp
- gzip -dc rh-1.0.24.tar.gz | tar -xvf -
- cd rh-1.0.24
- Follow the README.txt
- vi /etc/hosts
- Add the host name and ip address.
- Add: 172.16.0.1 defaultrouter # or whatever it is you have.
- vi /etc/hostname.rh0
- Add the hostname
- vi /etc/nsswitch.conf
- hosts: files dns
- vi /etc/resolv.conf
- Add you router, primary DNS and secondary DNS
- 'nameserver 172.16.0.1'
Sadly I do not know Unix well enough to do anything but reboot at this point: shutdown -g0 -i6 -y
Enabling sending mails through ISP
So when you are not prepared to RTFM and try it the easy way, you sometimes have to take the long route.
I thought it would take me two minutes to reconfigure sendmail.cf so that I could send mails to the internet, through my ISP.
Three days later, I'm wiser.
My original intention was to use my gmail account, but just getting mailx to send e-mails through my local ISP was challenge enough for now.
Please note, I don't know didly about sendmail, so I might have broken the first fifty rules....
But here are the short version of the steps I took:
- cd /etc/mail/cf/cf
- cp sendmail.mc sendmail.mc.org
- Re-write sendmail.mc
- /usr/ccs/bin/make sendmail.cf
- cp sendmail.cf ../../sendmail.cf
- svcadm -v refresh sendmail
- mailx -s "testing" My.Internet@account.net < sendmail.mc
- look at /etc/log/syslog if the mail doesn't arrive.
sendmail.mc
divert(-1) # # Copyright (c) 1983 Eric P. Allman # Copyright (c) 1988, 1993 # The Regents of the University of California. All rights reserved. # # Copyright 2004 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)sendmail.mc 1.11 04/06/21 SMI" # # This is a configuration file for SunOS 5.8 (a.k.a. Solaris 8) and later # subsidiary machines. It has support for local and SMTP mail. The # confFALLBACK_SMARTHOST macro is enabled, which means that messages will # be sent to that host (which is set to mailhost.$m [$m is the local domain]) # if MX records are unavailable. A short-cut rule is also defined, which # says if the recipient host is in the local domain, send to it directly # instead of the smart host. # # If you want to customize this further, copy it to a name appropriate # for your environment and do the modifications there. # divert(0)dnl VERSIONID(`@(#)sendmail.mc 1.11 (Sun) 06/21/04') OSTYPE(`solaris8')dnl DOMAIN(`solaris-generic')dnl define(`confFALLBACK_SMARTHOST', `smtp.mail.net')dnl Dred.dwarf define(`confDOMAIN_NAME', `$w.$m')dnl dnl This is the domain that it will look like the e-mail comes from that domain. dnl If this isn't valid then the you get a 550 error from your isp. MASQUERADE_AS(`my-registered-domain.org') FEATURE(masquerade_envelope) dnl dnl The mail gateway of our ISP has to be used as a relay. dnl define(`SMART_HOST', `smtp.mail.net') # This according to http://www.sendmail.org/m4/intro.html should always be at the end. MAILER(`local')dnl MAILER(`smtp')dnl
AIDE
- http://sourceforge.net/projects/aide
- http://gentoo-wiki.com/HOWTO_setup_a_home-server#AIDE
- http://linsec.ca/filesystems/aide.php
- Get the source code
- gzip -dc aide-0.11-rc2.tar.gz | tar -xf -
- ./configure
- Hmm this wasn't so simple
- getting the aide module from Sol9 x86 from sunfreeware.com
- mkdir -p /etc/aide/RCS
Template:Box File
LDAP server
http://www.bolthole.com/solaris/LDAP.html
[edit]
Orca
- http://www.sun.com/bigadmin/features/articles/orca.html Monitoring System Performance With Orca, RRDtool, and the SE Toolkit
- Solaris™ Operating System and ORACLE Relational Database Management System Performance Tuning
- http://www.setoolkit.com
- http://www.orcaware.com/orca/pub
- setenv PATH /opt/sfw/bin:/opt/sfw/gcc-3/bin:${PATH}:/usr/perl5/5.6.1/bin
- setenv PATH /usr/local/bin:/usr/sfw/bin:/opt/sfw/bin:/opt/sfw/lib/bin:${PATH}
- For x86
- edit /usr/local/lib/perl5/5.8.5/i86pc-solaris/Config.pm
- remove '-B/usr/css/bin'
- setenv CC gcc
- ln -s /opt/sfw/bin/gmake /opt/sfw/bin/make
- tar zxf orca-0.27.tar.gz
- cd orca-0.27
- ./configure --with-html-dir=/var/apache/htdocs/orca --with-ncsa-log=/var/apache/logs/access_log
- find . -name Makefile | xargs grep -w cc
- change CC = cc to CC = gcc in:
- ./packages/TimeDate-1.14/Makefile
- ./packages/Digest-MD5-2.20/Makefile
- make
- make install
- make orcallator_run_at_boot
- vi /usr/local/lib/orcallator.cfg
- edit /opt/RICHPse/bin/se
- for epia add i386*) MACH=i386;;
- /etc/init.d/orcallator start
Disabling services
See JASS toolkit for securing the Solaris box.
Doing an nmap scan of the box you get:
21/tcp open ftp 22/tcp open ssh 23/tcp open telnet 25/tcp open smtp 79/tcp open finger 80/tcp open http 111/tcp open rpcbind 513/tcp open login 514/tcp open shell 587/tcp open submission 898/tcp open sun-manageconsole 4045/tcp open lockd 7100/tcp open font-service
- svcadm -v disable ftp
- svcadm -v disable telnet
- svcadm -v disable bind
- this is rpcbin
- svcadm -v disable smtp
- svcadm -v disable
- svcadm -v disable
- svcadm -v disable
- svcadm -v disable
- svcadm -v disable
- svcadm -v disable
- svcadm -v disable
Disabling graphical/dtlogin
http://supportforum.sun.com/sunos/index.php?t=msg&th=2681&start=0&rid=0
- /usr/dt/bin/dtlogin -d
- after disabling of dtlogin will be very wise to kill the current opened login screen with command: /usr/dt/bin/dtlogin -kill
- mv /etc/rc2.d/S99dtlogin /etc/rc2.d/s99dtlogin
- above recommendation is suitable only for "home" servers and not for production
Fire wall
[ pass | block ] [ log ] [ in | out ] [ quick ]
- ipfstat -i
(This will show the active filter list.)
- ipmon
(This will do a kind of trail -f on the filter log, provided log i active.)
- svc name ipfilter (You need restart to read the updated.)
Solaris Zones
- zonecfg -z kochanski -f twiki.cfg
- zoneadm list -vc
- ID NAME STATUS PATH
- 0 global running /
- - kochanski configured /export/home/kochanski
- zoneadm -z kochanski install
- cp sysidcfg.twiki /export/home/kochanski/root/etc/sysidcfg
- zoneadm -z kochanski boot
- zlogin -C kochanski
- The '-C' give you the system console
- svcs -xv
- See if there are any services that arent running.
Configuring sendmail
From global zone
- cd /etc/mail
- find . | cpio -pumvd /export/home/kochanski/root/etc/mail
- p - pass through
- u - Copies unconditionally.
- m - Retains previous file modification time.
- v - verbose
- d - target directory.
- cp resolv.conf /export/home/kochanski/root/etc
- cp nsswitch..conf /export/home/kochanski/root/etc
In kochanski zone
- cd /etc
- echo "dwarf" > domainname
- domainname dwarf
- echo "192.168.0.1 defaultrouter" >> hosts
- add to /etc/hosts <hostname>.<domainname>
Services
- svcs -xv
- svcadm -v disable svc:/application/print/server:default
Configuration files
zone.cfg
set zonepath=/export/home/kochanski set autoboot=true add inherit-pkg-dir set dir=/lib end add inherit-pkg-dir set dir=/platform end add inherit-pkg-dir set dir=/sbin end add inherit-pkg-dir set dir=/usr end add net set address=192.168.0.221 set physical=rh0 end commit
sysidcfg
name_service=NONE network_interface=PRIMARY {primary hostname=kochanski ip_address=192.168.0.221 netmask=255.255.255.0 protocol_ipv6=no default_route=192.168.0.1 } root_password=Secret timeserver=localhost timezone=CET terminal=vt100 system_locale=C security_policy=none
Apache
- http://httpd.apache.org/docs/2.0/misc/perf-tuning.html
- http://www.onlamp.com/pub/a/apache/2004/08/19/apacheckbk.html
- http://www.onlamp.com/pub/a/apache/2000/03/02/configuring_apache.html
- http://www.linuxplanet.com/linuxplanet/tutorials/1527/2
AuthName "Foo for Thought" AuthType Basic AuthUserFile /home/johnson/foo.htpasswd Require valid-user
Is very good idea to redirect logs of Apache to different directory like /var/adm/httpd or /var/log/httpd
<example>
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /var/adm/httpd/access_log common
ErrorLog /var/adm/httpd/error_log common
</example>
- make - SUNWgmake
- wget - SUNWwgetu
- lynx - SFWlynx
- ncftpget
- ncftp
- gpg
In the global zone
- setenv PATH /opt/sfw/bin:${PATH}:/usr/sfw/bin
- perl -MCPAN -e 'install Net::SMTP;'
In the local zone http://develop.twiki.org/~develop/cgi-bin/view/TWiki/#Installation_and_configuration
- rm /var/apache/cgi-bin/test-cgi
- rm /var/apache/cgi-bin/printenv
- These are removed for security reasons, I seem to have come accross a mention that they should be removed.
- cd /var/apache
- mkdir twiki
- cd twiki
- gzip -dc /TWiki2005x11x06x7338beta.tgz | tar -xf -
- edit /ec/apache/httpd.conf
- /usr/apache/bin/apachectl configtest
- edit /var/apache/twiki/bin/setlib.cfg
- cp LocalSite.cfg.txt LocalSite.cfg
- chown twiki:twiki LocalSite.cfg
- chmod o+w,g+w LocalSite.cfg
- edit LocalSite.cfg
- /var/apache/twiki/lib/TWiki.cfg
- chmod +x /var/apache/twiki/bin/rdiffauth
- chmod +x /var/apache/twiki/bin/viewauth
- cp subdir-htaccess.txt data/.htaccess
- cp subdir-htaccess.txt lib/.htaccess
- cp subdir-htaccess.txt templates/.htaccess
- chown -R nobody *
- chmod -R 755 data
- chown twiki:twiki /var/apache/twiki/data/.htpasswd
- chown -x twiki/bin/configure
- remove '-H' from egrep and fgrep
- Remove \< and \> in the Param.pm
From within Twiki
- Update Main/TWikiAdminGroup
ISSUES
- cd /var/apache/twiki/data/ShadowRunGm/
- /usr/local/bin/ci -q -l WebPreferences.txt
- ci: WebPreferences.txt,v: no lock set by nobody
MySQL
Create the Zone
- zonecfg -z kryten /mysql.cfg
- zoneadm -z kryten install
- cp sysidcfg /export/home/kryten/root/etc/sysidcfg
- zoneadm -z kryten boot
Configure MySQL
You need to install the Sun package SUNWmysqlu as root.
- pkgadd -d . SUNWmysqlu
follow the instructions in /etc/sfw/mysql/README.solaris.mysql
- /usr/sfw/bin/mysql_install_db
- groupadd mysql
- useradd -g mysql mysql
- chgrp -R mysql /var/mysql
- chmod -R 770 /var/mysql
- installf SUNWmysqlr /var/mysql d 770 root mysql
- copy the correct cnf file from /usr/sfw/share/mysql to /etc/my.cnf
- E.g. cp /usr/sfw/share/mysql/my-huge.cnf /etc/my.cnf
- /usr/sfw/sbin/mysqld_safe --user=mysql &
- mysqladmin -u root password 'PASSWORD'
- cd /usr/sfw/mysql/mysql-test; ./mysql-test-run
Bugzilla
Get the source source
Version 2.20 is being used here.
In the Global Zone
- cd /tmp
- gzip -dc bugzille.tar.gz | tar -xvf
- setenv PATH /usr/local/bin:${PATH}
- rehash
- which perl
- vi checksetup.pl
- set perl path to /usr/local/bin/perl
- ./checksetup.pl --check-modules
- perl -MCPAN -e 'install Bundle::Bugzilla'
- cd /export/home/kochanski/root/var/apache/htdocs
- gzip -dc bugzille.tar.gz | tar -xvf
On the MySQL server kryten:
- /usr/sfw/bin/mysql -u root -p
- create database bugzilla;
- use bugzilla
- grant all on bugzilla to bugzilla@kochanski identified by "PASSWORD"
Apacher with mod_perl
- See instructions: http://perl.apache.org/docs/1.0/guide/getwet.html
Mason
Mason installation
In the global zone.
- setenv PATH /usr/perl5/5.8.4/bin:${PATH}
- setenv PATH /opt/SUNWspro/bin:${PATH}
- setenv PERL5LIB /usr/apache/perl5/5.8.4/i86pc-solaris
- perl -MCPAN -e 'install HTML::Entities'
- perl -MCPAN -e 'install HTML::Mason'
- perl -MCPAN -e 'install Apache::Request'
- zlogin kochanski
- /usr/apache/bin/httpd -f /var/apachem/conf/httpd.conf
FLAR
Creating a FLAR
- flar create -c -n epia
Creating the DVD
- http://www.sun.com/blueprints/0404/817-6991.pdf Building a Bootable DVD(s) to Deploy a Solaris Flash Archive (PDF Version)
- http://www.sun.com/bigadmin/scripts/submittedScripts/make-bootable-dvd.sh.txt Recovering at bare metal level - DVD only
- http://www.informit.com/articles/article.asp?p=174310&rl=1 Building a Bootable DVD to Deploy a Solaris Flash Archive
- mkdir /export/home/mydvd10
- cd /cdrom/sol_9_1203_sparc
- find s0 -print |cpio -pudm /export/home/mydvd10/s0
- cd /export/home/mydvd10
- /etc/init.d/volmgt stop
- for i in 1 2 3 4 5
- > do
- > dd if=/dev/dsk/c0t6d0s${i} of=s9u5.s${i} bs=512
- > done
- dd if=/dev/dsk/c0t6d0s0 of=s9u5.dvd.vtoc bs=512 count=1
- copy vtoc
- /etc/init.d/volmgt start
- restart volumen mgmt
- cd /export/home/mydvd10/s0/Solaris_10/Product
- rm -rf *
- cd /export/home/mydvd10/s0
- rm -rf 1of2_Doc_CD 1of2_Doc_CD SW_Supp_CD
- cp /epia.flar /export/home/mydvd10/s0/Solaris_10/Product
- rm /export/home/mydvd10/s0/.install_config/*
- cp /mydvd10.profile /export/home/mydvd10/s0/.install_config
- cd /
- ./check
- Validating rules...
- Validating profile bidvd9.profile...
- The custom JumpStart configuration is ok.
- cp rules.ok /export/home/mydvd10/s0/.install_config
- edit /export/home/mydvd10/s0/Solaris_10/Tools/Boot/usr/sbin/install.d/profind
- cd /export/home/mydvd10
- mkisofs -R -D -d -L -l -o s9u5.S0 s0
- dd if=/export/home/mydvd10/s9u5.S0 of=/export/home/mydvd10/s9u5.s0 bs=512 skip=1
- It is important to note that mkisofs creates a VTOC at offset 0 within this image. Use the dd command to remove this invalid VTOC from the HSFS image by skipping the first 512 byte block.
- 5636159+0 records in
- 5636159+0 records out
- rm /export/home/mydvd10/s9u5.S0
- it was only the count that was needed.
- bc
- 6026240-(5636159+1)
- 390080
- dd if=/dev/zero of=pad.s0 bs=512 count=390080
- 390080+0 records in
- 390080+0 records out
- lofiadm -a /bidvd9/s9u5.s1 /dev/lofi/1
- mount /dev/lofi/1 /mnt
- ls -al /mnt/etc/sysidcfg
- lrwxrwxrwx 1 root other 24 Nov 28 16:38 /mnt/etc/sysidcfg -> ../tmp/root/etc/sysidcfg
- rm /mnt/etc/sysidcfg
- cp /export/home/mydvd10/sysidcfg /mnt/etc/sysidcfg
- umount /mnt
- lofiadm -d /dev/lofi/1
- cat s9u5.dvd.vtoc s9u5.s0 pad.s0 s9u5.s1 s9u5.s2 s9u5.s3 s9u5.s4 s9u5.s5 >bidvd9.image
mydvd10.profile
install_type flash_install archive_location local_file /cdrom/Solaris_10/Product/epia.flar partitioning explicit # # 2.0GB swap on a 36GB disk # 4 cylinders on slice 7 for SVM's MetaData # filesys rootdisk.s0 free / filesys rootdisk.s1 1:1450 swap filesys rootdisk.s7 1451:4 unnamed
rules
any - - mydvd10.profile -
profind
cdrom() { # Factory JumpStart is only allowed with factory # stub images, indicated by the file /tmp/.preinstall # if [ -f /tmp/.preinstall ]; then mount -o ro -F lofs ${CD_CONFIG_DIR} ${SI_CONFIG_DIR} >/dev/null 2>&1 if [ $? -eq 0 ]; then verify_config "defaults" "CDROM" fi fi gettext " <<< using DVD install_config >>>"; echo # bidvd9 rmdir ${SI_CONFIG_DIR} # bidvd9 ln -s /cdrom/.install_config ${SI_CONFIG_DIR} # bidvd9 }
[edit]
sysidcfg
system_locale=en_US timezone=US/Pacific network_interface=primary {hostname=barossa ip_address=192.168.0.2 netmask=255.255.255.0 default_route=none protocol_ipv6=no} terminal=vt100 security_policy=NONE root_password=Q7jsh1m6IztTU name_service=NONE timeserver=localhost
HW tested
Box 1
Motherboard: Via Epia 800 ITX board
Box 2
- NIC: D-Link, DFE-530TX, DL10030B
Trouble shooting
Sendmail
Mail not going out
Users report
Mail not going out of local zone, even thought the configuration is the same as the global zone.
/var/log/syslog
Nov 15 23:21:37 kochanski sendmail[8431]: [ID 801593 mail.info] jAFMLbUS008431: from=<root@kochanski.dwarf>, size=357, class=0, nrcpts=1, msgid=<200511152221.jAFMLbDt008430@kochanski.dwarf>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1] Nov 15 23:21:37 kochanski sendmail[8430]: [ID 801593 mail.info] jAFMLbDt008430: to=valid@inter.net, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30073, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (jAFMLbUS008431 Message accepted for delivery) Nov 15 23:21:37 kochanski sendmail[8433]: [ID 801593 mail.info] jAFMLbUS008431: to=<hclaville@gmail.com>, ctladdr=<root@kochanski.dwarf> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120357, relay=smtp.net [nnn.nnn.nnn.nnn], dsn=5.1.1, stat=User unknown Nov 15 23:21:37 kochanski sendmail[8433]: [ID 801593 mail.info] jAFMLbUS008431: jAFMLbUS008433: DSN: User unknown
Solution
So, it turns out, root don't get spoofed, after creating the twiki user and su twiki, sending e-mails worked as expected.
Connection refused by [127.0.0.1]Connection refused by [127.0.0.1]
Feb 15 22:11:06 myhost sendmail[3047]: [ID 801593 mail.info] m1FLB6Je003047: to=nospam@spamcity.org, ctladdr=mailadmin (100/1), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30065, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
Solution
remove /etc/mail/submit.cf see: http://www.sunmanagers.org/pipermail/sunmanagers/2006-February/039507.html
Building Digest::SHA1
- download the Digest::SHA1
- perl Makefile.PL cc=gcc ld=gcc
- edit Makefile
- Replace FPIC with fPIC
- Remove -xO3 -xspace -xildoff from OPTIMIZE =
- Leaving 'OPTIMIZE ='
Thank you for reading
No comments:
Post a Comment