Archive for Linux

How to setup a Linux web server using the command line, Part 1 : Securing Your Server

So you’ve got a fresh new install of a Linux distribution such as Ubuntu Gutsy or Fedora 8 that you plan to use as a web application hosting server - sweet.  The only thing is - you only have root access via SSH, no point-and-click GUI.  That sounds perfect.  Using only the command line will take us about 20 minutes to setup a complete, secure Web 2.0 Linux Apache MySQL PHP (LAMP) Ruby on Rails Django TurboGears stack on a slice (once you get the hang of things, of course).  Take deep breaths.

This multi-part tutorial will show you step-by-step instructions for securing your new dedicated server or virtual private server (a.k.a. Slice or VPS), loading the programs you need to run it, and setting the Linux server up to host multiple Ruby on Rails and other web 2.0 framework applications, all using your local workstation’s bash shell command line, uh, your (Mac) terminal.

This tutorial has been thoroughly tested to work with the following Linux distros:

Read the rest of this entry »

What are the Unix shell commands for handling user administration?

Here’s a quick cheat-sheet for Unix user administration from the command line terminal. Make sure you are logged in as “root” user for these, or enter “sudo -i” for root user access.

Read the rest of this entry »

How to create multiple websites for Apache server using Vhosts

# This one is pretty simple - we’re just using common Unix commands.
# I find this one helpful when I don’t want to generate a rails site skeleton on the server.

# create web application skeletal structures

cd ~/public_html

# domain 1
mkdir -p mydomain1.com/{backup,cgi-bin,log,private,public}
mkdir -p mydomain1.com/{config,releases,shared,tmp}
mkdir -p mydomain1.com/tmp/pids
# create symlinks for a capistrano site here
ln -s /home/super/public_html/mydomain1.com  /home/super/public_html/mydomain1.com/current
ln -s /home/super/public_html/mydomain1.com/log  /home/super/public_html/mydomain1.com/shared/log

# domain 2 (optional)
mkdir -p mydomain2.net/{backup,cgi-bin,log,private,public}
mkdir -p mydomain2.net/{config,releases,shared,tmp}
mkdir -p mydomain2.net/tmp/pids
# create symlink for capistrano site here
ln -s /home/super/public_html/mydomain2.net  /home/super/public_html/mydomain2.net/current
ln -s /home/super/public_html/mydomain2.net/log  /home/super/public_html/mydomain2.net/shared/log

# domain 3 (optional)
mkdir -p mydomain3.ws/{backup,cgi-bin,log,private,public}
mkdir -p mydomain3.ws/{config,releases,shared,tmp}
mkdir -p mydomain3.ws/tmp/pids
# create symlink for capistrano site here
ln -s /home/super/public_html/mydomain3.ws  /home/super/public_html/mydomain3.ws/current
ln -s /home/super/public_html/mydomain3.ws/log  /home/super/public_html/mydomain3.ws/shared/log

# to see what was created in the above code, use “ls -la” command (optional)

ls -la ~/public_html/
ls -la ~/public_html/mydomain1.com
ls -la ~/public_html/mydomain2.net
ls -la ~/public_html/mydomain3.ws

# enable (turn on) website applications in apache

sudo a2ensite mydomain1.com
sudo a2ensite mydomain2.net
sudo a2ensite mydomain3.ws

# disable (turn off) website applications in apache
#sudo a2dissite mydomain1.com
#sudo a2dissite mydomain2.net
#sudo a2dissite mydomain3.ws

# (re)start apache server

sudo /etc/init.d/apache2 start
# or
sudo /etc/init.d/apache2 reload

# visit your sites in a web browser

http://mydomain1.com
http://mydomain2.net
http://mydomain3.ws
# secure versions (self-signed)
https://mydomain1.com
https://mydomain2.net
https://mydomain3.ws

Done!