George Mason University Antonin Scalia Law School

Apache Rewrites

Redirect non-www to www with .htaccess


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Example: law.gmu.edu to www.law.gmu.edu


Add trailing slash (/) to URL:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.sample.com/$1/ [QSA,L,R=301]

Example: law.gmu.edu to law.gmu.edu/

Upgrade Notes

WordPress: Just hit the upgrade button

MODX: 1.06

  • Follow Upgrading Guide (Alternate Method).
  • Back up config.inc.php and document.parser.class.inc.php
  • Once upgraded, change default sort order in resource tree:if (!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) {
    // This is the first startup, set default sort order
    $_SESSION['tree_sortby'] = 'menuindex'; // Change menuindex to a value of your choice.
    $_SESSION['tree_sortdir'] = 'ASC';
    }
  • PHx Bug & pageTOC issue: The fix is to increase the pcre.backtrack_limit setting in php.inifrom 100000 to 800000

    [Pcre]
    ;PCRE library backtracking limit.
    pcre.backtrack_limit=800000

Modifying the document.parser.class.inc.php

Add the following codes when upgrade:

// START CODE BY PAUL BOHMAN/DONNY TRUONG
// Ability to get all documents, whether deleted or unpublished, added by Paul Bohman
if ($published == '*') $sqlPublished = '';
else $sqlPublished = "AND sc.published=$published";
if ($deleted == '*') $sqlDeleted = '';
else $sqlDeleted = "AND sc.deleted=$deleted";
// END CODE BY PAUL BOHMAN/DONNY TRUONG

And here:

$result= $this->getTemplateVars($vars, "*", $docid, $published, "", "", $sep, $deleted=0);
// The deleted option above was added by Paul Bohman/Donny Truong

Remember to add the codes for CASifying MODX as well.

Frequently Used Linux Command Lines

Install WordPress
wget https://wordpress.org/latest.tar.gz
tar xfz latest.tar.gz
cp -r * ~/public_html/your/website/folder/

Change Permissions (rwx => 4 + 2 + 1 = 7)
For Directories: find /path/to/your/directory/ -type d -exec chmod 755 {} \;
For Files: find /path/to/your/file/ -type f -exec chmod 644 {} \;

Permissions
chmod -R 755 directory
chmod -R 644 files

Remove files and directory (use carefully)
rm -rf YourDirectory

Change Owner
chown -R apache new_name (change entire directory)

Remane Directory
mv {old} {new}

Database
To access database: mysql -u root -p
mysql> create database [database name];
mysql> show databases;
mysql> drop database [database name];
More

VI editor
Reference: Using the VI editor

Red Hat Training

Notes from Red Hat System Administration I (RH124) from April 2-6, 2012

Day 1

Covered:
Installing Red Hat 6, which took almost half a day.
Using GNOME graphical desktop.
Editing files with gedit.
Managing files with Nautilus.
Getting help with manuals (F1 for help)
Managing system clock.
Configuring printers.

Command Lines:
uname -r (find out what version of Red Hat)
$ su – (log in as substitute user)
# useradd visitor (add username “visitor”)
# passwd visitor (add password to “visitor”)
# ip addr show eth0 (show ip address)
# ls /usr/share/doc (documentations)
# man man (access manual)
# man -k print (-k is for keyword)

Day 2

Introduced to Bash

Commands entered at the shell prompt have three basic parts:
# chmod +x gedit demo.txt
[command] [options] [arguments]

Command lines:
# pwd (path you’re currently in)
# history
Using the tab key (“tab” “tab”) for completion
# scp filename user@ip-address:/ (copy file from local folder to virtual server)

Introduced to managing physical storage using the graphical interface
Learned to manage logical volumes
Introduced to monitoring system resources

Day 3

Yum
# yum list (get the list of .rpm, which stands for RPM Package Manager)
# yum search kernel (kernel is the name of the package)
# yum install kernel
# yum update kernel
# yum remove kernel

Network
# ip addr show eth0 (eth0 is the name of the network)
# more /etc/sysconfig/network-scripts/ifcfg-eth0
# service network restart
# system-config-network
# ip route
# host visualgui.com
# dig visualgui.com

Users and Groups
# useradd donny
# passwd donny
# vipw (let’s one user edit at the same time)

Manage Files
# echo $PATH
# pwd (current path)
# ls /home/{dir1,dir2} (show more two directories)
# ln file1 file2 (link file 1 to file 2)
# ln -s file1 file2 (symbolic link)
# su – username (change user)
# cp -av /dir/to/copy /dir/destination

Permission
r (view content)
w (change the content)
x (requires r to execute the content)

rw-rw-rw-
rw-r–r–
umask 002

u+s (suid=4: file executes as the user that owns the file, not the user that ran the file
g+s (sgid=2: file executes as the group that owns the file
o+t (sticky=1: no effect)

Day 4

Administer remote system including remote shell access, remote file transfer, using SSH keys

Managing physical storage including filesystem, partition and swap space

Install Linux with Anaconda.

SSH
# scp original-file new-file
# rsync -a /home/student demo:/tmp
-a=all

Archive
# tar -cvf target/to/archive source/to/archive
-c=create
-x=extract
-t=test (tell)
-v=verbose
-f=filename

Using SSH
# ssh-keygen
# ssh-copy-id example.com

# service crond status
# chkconfig –list crond

# vi /etc/ssh/sshd_config
PermissionRootLogin no
PassordAuthentication no
# service sshd restart

Day 5

FTP
# service vsftpd status
# service vsftpd start
# chkconfig vsftpd on
# chkconfig vsftpd –list

httpd
# ll /var/www/
# ln -s /var/ftp/pub /var/www/html/pub
# cat > /var/ftp/pub/index.html
Hello World!