Apache Not Reloading Configuration File / Rewrites Not Updating July 15, 2009
Posted by scoopseven in Apache, Linux.add a comment
This week I experienced a problem where my apache rewrite rules wouldn’t update or reload. I would change a 301 redirect or an alias, restart Apache and the changes wouldn’t process. Humph. I got to the point where I started to believe, like DNS, that these redirects where propagated somewhere out on the Internet and they were just happening. Of course, this doesn’t happen.
Our Apache setup contains conf files for several sites, and our main httpd.conf file has a section that includes these conf files:
# Load config files from the config directory "/etc/httpd/conf.d".
Include conf.d/*.conf
What I had done was left a backup config file in the /etc/httpd/conf.d directory, so I had mysite.conf and mysite-20090710.conf being included when Apache loaded. Weather Apache tried to load both config files or my backup was simply overwriting my real config, I’m not sure, but as soon as I removed the backup config everything started working as normal. From now on, my backup Apache config files will be named mysite.bak!
Virtual Hosts with Jboss / Apache / ColdFusion March 25, 2009
Posted by scoopseven in ColdFusion, Linux, MediaPost.add a comment
ServerName www.mysite.comServerAlias sitetwo #added this line to Apache .conf file.
<jboss-web><context-root> /</context-root><virtual-host>www.mysite.com</virtual-host><virtual-host>sitetwo.mysite.com</virtual-host></jboss-web>
Spidering and Saving Images with CFHTTP and CFFILE March 11, 2009
Posted by scoopseven in ColdFusion, Linux, MediaPost.add a comment
Goal: To spider a site (our own site) and save all image files from the pages on that site to a hard disk on another server.
Thanks to Ben Nadel for showing me the way on this one. For some reason the path/file attributes on cfhttp were not allowing me to save a image file to the hard disk on our linux (CentOS) server. I thought I could save the file using cfcontent somehow, which led me to Ben’s post. Never thought to just save the binary stream using cffile. Not sure if there was a permissions problem or what, but here’s the work-around.
<!— Grab the image file. —>
<cfhttp
method=”get”
url=”http://www.myurl.com/someimage.jpg”
useragent=”#CGI.http_user_agent#”
getasbinary=”yes”
result=”objGet” /><!— Save the image file. —>
<cffile action=”write”
output=”#objGet.FileContent#”
mode=”777″
file=”/mypath/myimage.jpg”>
This worked like a charm. Again, not sure if this was cfhttp doesn’t support the “mode” attribute or what, but it helped immensely. Thanks, Ben.
How to Dump and Import a Database or Table using the CLI on Linux July 8, 2008
Posted by scoopseven in Linux, MySQL.1 comment so far
Log onto your server from the console or with a ssh client. I use Putty. Use the following command to dump a table.
myserver# mysqldump -u yourUserName -p yourDatabaseName yourTableName > yourDestinationFileName.sql
Use this command to dump a whole database (this may take a while). I’m using putting the dump file into a directory below too. Just to add to the example.
myserver# mysqldump -u yourUserName -p yourDatabaseName > /yourDestinationDirectory/yourDestinationFileName.sql
Because I’m moving this to another Linux DB server, I’m going to use scp to copy the file over
myserver# scp theFileIDumpedAbove.sql yourUserName@yourDestinationServer:/yourDestinationDir/yourDestinationFile.sql
Finally, on my destination server, where I just scp’ed the file to, I import my dump file into my database. If you’re replacing tables, make sure you drop those tables from the DB before you try to import them.
myserver# mysql -p yourDestinationDatabase < /yourSourceDirectory/yourSourceSqlFile.sql
FTP from server to server using ColdFusion June 30, 2008
Posted by scoopseven in ColdFusion, Linux, Windows.add a comment
Here’s a brief set of instructions on how to ftp a file (or many files) from one server/computer to another using ColdFusion.
On Windows:
Download and install NcFtp Client from Microsoft Windows at: http://www.ncftp.com/download/
Make sure you’re NcFtp directory is in your PATH statement so you can run it from anywhere.
Test it by running something like this from a DOS prompt (where myHost is the IP address or host for your ftp server:
ncftpput -P -u myUser -p myPass myHost myDestinationFile.txt C:\myLocalFile.txt
Once you get NcFTP working, you want to create a .bat file and put your successful FTP command in it, let’s call it autoFtp.bat. Now we’re going to call autoFtp.bay from CF:
<cfset argumentsArray = arrayNew(1)>
<cfexecute name = “c:\autoFtp.bat”
arguments = “#argumentsArray#”
timeout = “6000″>
</cfexecute>
Don’t worry about the argumentsArray, we’ll get to that in a bit. Put the above code in a .cfm file and run it. Your file should successfully ftp to the remote server. When you can do that, you can start passing in arguments to your autoFtp.bat file. Edit autoFtp.bat to look like this:
ncftpput -P -u myUser -p myPass myHost %1 %2
Edit your .cfm page so it looks like this:
<cfset argumentsArray = arrayNew(1)
<cfset argumentsArray[1] = “myDestinationFile.txt”>
<cfset argumentsArray[2] = “C:\myLocalFile.txt”>
<cfexecute name = “c:\autoFtp.bat”
arguments = “#argumentsArray#”
timeout = “6000″>
</cfexecute>
When you pass argumentsArray to autoFtp.bat, you can reference them by their array index, so argumentsArray[1] will be referenced as %1 in autoFtp.bat.
On Linux:
A little bit easier, no need fro NcFTP. Instead, create a shell script, .sh file called autoFtp.sh. The contents are below:
#! /bin/sh
DESTINATION_FILE=$1
LOCAL_FILE=$2
HOST=’ftp.myhost.com’
USER=’myUserName’
PASSWD=’myPassword’
ftp -nv <<EOF
open $HOST
user $USER $PASSWD
binary
put $LOCAL_FILE $DESTINATION_FILE
EOF
Make sure you have execute permissions on the autoFtp.sh. I’m using this to transfer images, so the “binary” command is totally necessary for me. The arguments are passed into autoFtp.sh on the command line, the first argument is referenced by $1, the second, $2, etc. Good Luck!