Monthly Archives: December 2012

Install Apache web server on Windows 7 with php

Here’s the steps I followed to install Apache web server on Windows 7 with php.

I have been running an application on a Windows XP PC for years.  The application was web enabled on top of Apache for Windows.  This note captures the steps to move my application over to my Win7 PC; since I’ve done this before, this should be easy.  Well no, I had some bumps and these notes are to help me for next time.

For starters, I decided to follow the nice how-to found at Badprog.

1. Install Apache httpd.

  • Download from here
  • For Network Domain, I entered my domain name.
  • For Server Name, I entered my private IP address, 192.168.x.x
  • I verified my setup, by trying http://192.168.x.x.  Look for “It Works!”

.2. Install PHP

  • Download from here. I used VC9 x86 Thread Safe (2012-Nov-21 21:22:38), v5.4.9
  • unzip and copy to C:\Program Files (x86)\PHP
  • rename folder to php-5.4.9

3. Configure

  • C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf
 LoadModule php5_module "C:/Program files (x86)/\
 LoadModule ssl_module modules/
 LoadModule rewrite_module modules/
 AddType application/x-httpd-php .php
 # for .htaccess
 AllowOverride All
 # for dir_module
 DirectoryIndex index.php index.html
 <Directory "C:/public_html">
 Include conf/extra/httpd-ssl.conf
 # at end of file:
 PHPIniDir "C:/Program Files (x86)/PHP/php-5.4.9"
  • In same directory create a .htpasswd file
  • In c:\public_html, create file phptest.php
  • create file .htaccess
AuthUserFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/.htpasswd"
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic require user j****k
  • verify
  • C:\Program Files (x86)\PHP\php-5.4.9:
    • rename php.ini-development -> php.ini
 date.timezone = "America/Chicago"
 ForceType application/x-httpd-php

Key stuck point for me when setting up my Apache Web Server on Windows 7:

Remember: restart httpd with “Run as Administrator” !!

Restart - must run as Administrator

Whenever the httpd.conf file is changed you need to restart the Apache web server.  Just selecting and running Restart doesn’t work, except if you run it as an Administrator. From the Start menu, find Restart, the right-mouse click it, and select “Run as Administrator.” It took me two hours to figure this out.  Since my old installation was on Windows XP, I never had this issue.

4. Configure SSL

  • edit file: “C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/extra/httpd-ssl.con”
 DocumentRoot "c:/public_html"
 SSLCertificateFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/cisco163_kozikfamily_net.crt"
 SSLCertificateKeyFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/"
 SSLCertificateChainFile "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/"

#Because of syntax error on Windows:
SSLSessionCache "shmcb:C:/Progra\~2/Zend/Apache2/logs/ssl_scache(512000)"
Mississippi Capitol

Walk Jackson Capitol area – State House, Governor’s Mansion, War Memorial

Mississippi CapitolI was in Jackson on business.  This was my first visit to the state of Mississippi, and I was looking forward to walk Jackson Capitol area.

I parked at the State Capitol, I walked around the grounds, I then made my way over to the Old  State Capitol, now a museum, then walked a little further to the Governor’s Mansion, then headed back.  The Jackson Capitol Area is a nice compact area in the historic downtown section of Jackson.

Jackson Capitol Area Sites

Vetrans MonumentOn my walk, I saw the following:  USS Mississippi. Figurehead of Battleship, Sillers Building, Carroll Gartin Justice Building (Supreme Court), Mississippi Veterans Monument, State of Mississippi Medal of Honor Recipients, Veterans Monument, Secretary of State Office, …

And, the Liberty Bell replica, Memorial to the Women of the Confederacy, Lamar Life Building, War Memorial Building, Old Capitol Museum, Confederate Monument, St. Andrews Episcopal Cathedral, Mississippi Governor’s Mansion, Cathedral of St. Peter the Apostle, and more.

At this time of day, the downtown area appeared to be pretty empty.  There were cars at the capitol area and near some law offices, but for the most part, restaurants, shopping, and other tourist type activities were found in other parts of town.  This area is historic and architecturally interesting and I recommend a short visit.

Buffalo Linkstation

Buffalo Linkstation for linux backup.

Buffalo Linkstation WXL

Buffalo Linkstation WXL

It’s time to expand the usage of my Buffalo Linkstation for linux backup.  I have been using my Linkstation Network Attached Storage box for backup of my home PCs and MACs.  I have a couple of linux servers so I thought I’d see if I could use my Buffalo Linkstation for linux backup.

Summary: create tar files and ftp them to Linkstation

The short version of the story is that I wrote a Buffalo Linkstation for linux backup script that created tar files of my user directories and ftp’d them to the Buffalo Linkstation.  I tried samba mounting the Linkstation and rsyncing to it.  ext4<->ntfs file system incompatibilities won’t let that work.

Buffalo Linkstation for linux backup tar / ftp script approach

I use the following command to backup a user’s directory:

# tar cvzf backupfile.tar.gz --exclude='.*' /home/$USER/

This is a traditional tar command where I exclude the hidden files.

Next, in researching this problem, the Buffalo Linkstation Forum has lots of powerful tips.  The ftp program ncftp is a favorite to use in scripts.  My fedora distribution didn’t have it, so I installed it.

# yum install ncftp

This lets me very easily copy my tar file to my Linkstation; on it, I make a separate share for each home computer:

# ncftpput /array1/share/fedora backupfile.tar.gz

For personal reasons, I want to do backups per user login. That way, I have control over frequency of backup; some content changes frequently, some changes rarely. From this, here’s a per-user Fedora Linux to Buffalo Linkstation backup script:

## usage username
##    /home/$username much exist, else exit
echo "Test for /home/$USER"
if [ -d "/home/$USER" ] ; then
   echo "/home/$USER is valid user directory";
   echo "/home/$USER is not a valid user directory... Exiting";
   exit 1

DATE=`/bin/date +%Y%m%d`
TIME=`/bin/date +%H`
tar cvzf $BCKUPFILE  --exclude='.*' /home/$USER/
ncftpput /array1/share/fedora $BCKUPFILE

I run user backups once per week, except one backup I run monthly. The backup tar files are on the order of 10M each. I also have a script to backup mysql (borrowing from link):

DATE=`/bin/date +%Y%m%d`
TIME=`/bin/date +%H`
mysqldump --user root --all-databases > $BCKUPFILE
ncftpput /array1/share/fedora $BCKUPFILE

In my crontab, you can see the general workflow:

0 3 * * * /home/jkozik/bin/ # rsync to the other 
                                         # hard drive in the PC
0 17 * * * /home/jkozik/bin/
0 16 * * 0 /home/jkozik/bin/ nf
0 16 * * 1 /home/jkozik/bin/ jkozik
0 16 * * 2 /home/jkozik/bin/ lizkozik
0 16 * * 3 /home/jkozik/bin/ weather
0 16 * * 4 /home/jkozik/bin/ wjr
0 4 1 * * /home/jkozik/bin/ family

I tried rsync between by linux server and Linkstation… no luck.

For starters, my home network PCs are all backing up to my Linkstation now using its windows (samba/cifs) sharing service. The Linkstation, named LS-WXL9E3, is sitting on my home LAN and looks like any other host on my home LAN WORKGROUP.  Here’s what my home PCs see;

Buffalo Linkstation as a Windows 7 Share

click for larger image

Setting up the Buffalo Linkstation console:  be sure to check the Windows box on the shared folders settings page:

Share Folders Setting

And on the Network->Workgroup/Domain settings page, be sure to put in the right settings for your home workgroup.  My home workgroup is called WORKGROUP.  This is explicitly set on my PCs.

Network Workgroup/Domain Settings

So from my linux server, I mounted the Linkstation.  My fedora installation, included setting up CIFS/SAMBA, so all I had to do was mount:

# mount -tcifs // /mnt/ls-wxl93e \
                -o guest,user=guest

 So from here, I ran a simple test rsync script.

# rsync -av -L --modify-window=2 /home/jkozik   \

This worked.  Great (I thought)!   So I started setting up  some cronjobs.  I noticed that every time I ran my rsync, more than half of the files were re-backedup each run.  Rsync only backs up that have changed; but none of these files had changed.  Even after I added the “–modify-window=2″ parameter to the rsync command, I was still backing up way too many files.   Similar to the issue found at link.  Backing up an ext4 filesystem on my fedora linux server to the samba interface on the Linkstation wasn’t going to work for me.

Next step for me:  enable sshd on my Linkstation

So, I learned that the Linkstation community follows a different approach to this issue.  There’s robust set of contributions on how to turn-on ssh access to let rsync run directly through the sshd on the Linkstation, sans samba/cifs. I found the wiki that covers this case, and I’ll someday move to this approach; tar files are ok, but I want to eventually land into a rsync approach.