Apache2 on Solaris 10

The apache web server is included with Solaris 10. Follow these steps to enable it.
Step 1: Create a working default apache config file

The apache server config files are in /etc/apache2. To quickly get up and running, you can just use the sample config file by doing the following:

cd /etc/apache2 cp httpd.conf-example httpd.conf

 

Step 2: Enable the apache/httpd service

Check to see if apache is already running:

svcs -a | grep -i http

You will probably see the following, indicating that apache is NOT running: disabled Apr_20 svc:/network/http:apache2
Use the svcadm command to start the webserver. This will also make it automatically start if your machine reboots. svcadm -v enable /network/http:apache2

Use the following svcs command to make sure it worked: svcs -p /network/http:apache2 STATE STIME FMRI online 15:32:44 svc:/network/http:apache2

              15:32:44    28711 httpd
              15:32:45    28712 httpd
              15:32:45    28713 httpd
              15:32:45    28714 httpd
              15:32:45    28715 httpd
              15:32:45    28716 httpd

This is showing that the webserver is online and working.

 

Step 3: Add your web content

Put your html (IE: index.html) in the /var/apache2/htdocs directory. If everything went OK, you should have a functioning apache webserver.
Debugging / Troubleshooting

If the svcs -p command from the above step doesn’t show a STATE of online, do the followig: svcs -a | grep -i http

You’ll probably see that it’s in maintenance mode: maintenance 15:16:12 svc:/network/http:apache2

For more detailed info run: svcs -l http

OR svcs -x http svc:/network/http:apache2 (Apache 2 HTTP server)

State: maintenance since May  8, 2007  3:16:12 PM EDT

Reason: Start method failed repeatedly, last exited with status 1.

  See: http://sun.com/msg/SMF-8000-KS
  See: httpd(8)
  See: /var/svc/log/network-http:apache2.log

Impact: This service is not running.

Note that the second to last line tells you where the log file is, so take a look at that. Once you’ve fixed the problem, you can restart apache with: svcadm restart /network/http:apache2

If for some reason you want to shut off apache, use this: svcadm disable /network/http:apache2

svcs -p /network/http:apache2 STATE STIME FMRI disabled 15:36:33 svc:/network/http:apache2

 

svcs -l http fmri svc:/network/http:apache2 name Apache 2 HTTP server enabled false state disabled next_state none state_time May 8, 2007 3:36:33 PM EDT logfile /var/svc/log/network-http:apache2.log restarter svc:/system/svc/restarter:default contract_id dependency require_all/error svc:/milestone/network:default (online) dependency require_all/none svc:/system/filesystem/local:default (online) dependency optional_all/error svc:/system/filesystem/autofs:default (online)

Rsync Between Servers Automatically

Part 1 – Setting up SSH key authentication

First, we need to make sure the DESTSERVER has the ability to use key authentication enabled. Find your sshd configuration file (usually ‘/etc/ssh/sshd_config’) and enable the following options if they are not already set.

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

If you edit the file be sure to restart sshd afterwards.

# /etc/init.d/sshd restart

Next, on the SOURCESERVER we will create the public / private key pair to be used for authentication with the following command.

# ssh-keygen -t rsa
  • Note: Do not enter a passphrase for this, just hit enter when prompted.

This should create 2 files, a public key file and a private key file. The public key file (usually [homedir]/.ssh/id_rsa.pub) we will upload to the DESTSERVER. The private key file (usually [homedir]/.ssh/id_rsa) we will keep on the SOURCESERVER.

  • Be sure to keep this private key safe. With it anyone will be able to connect to the DESTSERVER that contains the public key.

Now we will plant the public key we created on to the DESTSERVER. Choose the user account which you will use to connect to on DESTSERVER, we’ll call this user ‘destuser’ for now.

In that account’s home directory, create a ‘.ssh’ subdirectory, and in that directory create a new text file called ‘authorized_keys’. If it already exists, great, use the existing file. Open the ‘authorized_keys’ file and paste in the contents of the public key you created in the previous step (id_rsa.pub). It should look something like the following

ssh-rsa <lots and lots of characters…> sourceuser@SOURCESERVER

Save the file and change the permissions to 600 for the file and 700 for the ‘.ssh’ directory.

Now to test that the keys are working. From the SOURCESERVER try logging in as normal using ssh to the DESTSERVER.

# ssh destuser@DESTSERVER

If all is working you should not be prompted for a password but instead connected directly to a shell on the DESTSERVER.

Part 2 – Creating the rsync script

 

Now for the rsync script.

#!/bin/sh

SOURCEPATH=’/var/svn/workingcopies/beta.app.jp/’
DESTPATH=’/var/www/lamp_root/wwwapps/app.jp’
DESTUSER=’updater’
LOGFILE=’/var/log/rsync_beta.log’

echo $’\n\n’ >> $LOGFILE
for SERVER in web01 web02
do
        rsync -av –rsh=ssh $SOURCEPATH $DESTUSER@$SERVER:$DESTPATH 2>&1 >> $LOGFILE
        echo “Completed at: `/bin/date`” >> $LOGFILE
done
Part 3 – Setting up the cron job

This is optional. I assume web updates will be done manually.

Assuming everything has worked so far all that’s left is to setup a cron job to run the script automatically at a predefined interval.

Use the ‘crontab’ command to create a new cron job.

>sudo crontab -e -u updater

This will open an editor where you can schedule the job.

Enter the following to have the script run once every hour

0 * * * * /var/scripts/rsync_betajp.sh

A small Magento maintenance script.

This script will rebuild some of the indexes and tables within Magento. I find it useful if the GUI times out when performing cache management.

rebuild();
/*
rebuild catalog index
*/
Mage::getSingleton('catalog/index')->rebuild();
/*
rebuild search
*/
Mage::getSingleton( 'catalogsearch/fulltext' )->rebuildIndex();
/*
rebuild flat category
*/
Mage::getResourceModel('catalog/category_flat')->rebuild();
/*
rebuild flat catalog product
*/
Mage::getResourceModel('catalog/product_flat_indexer')->rebuild();
/*
apply catalog rules
*/
Mage::getResourceSingleton('catalogrule/rule')->applyAllRulesForDateRange();

$t_end = microtime(true);
$diff = $t_end - $t_start;

echo "Refresh Complete in $diff seconds";
?>

OAuth Flaws

Here is an interesting article on the flaws of OAuth:

http://insanecoding.blogspot.com/2013/03/oauth-great-way-to-cripple-your-api.html

Zenoss

I think I might try Zenoss again. It has been a year or two since I last visited this product. I am looking for a product that is all encompassing. I will probably use CentoOS as the OS.

http://wiki.zenoss.org/Install_Zenoss