DISCLAIMER
This is the walk-through scripts in an offline seminar about *nix, which gives a basic understanding / real-world practices of the steps to deploy a typical web application to a blank server machine. The tasks includes creating system user account, setting up proper proper permissions, uploading crafted sourcecode, preparing server and database, setting up cronjob and scheduling crawling tasks, gateway, cache and load ballance ...
The sample application was a pretty naughty app for artists only, who likes nudity arts on 500px but just don't have enough patient to click "uncover" all the time. It was working well at the time of this seminar, but might not for future versions :-) (and probably the covered black tile has been removed?)
So this is an art website of photographers, called the 501px. Note that it's not a 500px parody.
Setup your user account with the following details
- username: your email (drop the @offspringdigital.com)
- password: freely pick it
- home directory: /home/{user-name} Then use it to ssh.
Upload sourcecode to /home/{user-name}/www
. There are several ways to make it
- scp
- rsync
- ftp (need to setup first,
vsftpd
is recommended)
Setup apache site (via virtual host)
- Port 80
- DocumentRoot
home/{user-name}/www
- Run as user
apache
- Run as group
www
(should createwww
group)
Import SQL database
- database name:
501px
- sql file at
home/{user-name}/www/res/db/init.sql
- note that we haven't got any GUI tool
- actually, it's just a dummy task
Symlink to make res
available as /home/{user-name}/public/res
.
Using ln
.
Change all the files/folders ownerships to {user-name}/www (user {user-name} and group www). Make the mod so that owner-user can fully read+write, the owner-group can read, and others can do nothing (no read, no write)>
Make all the files to-be-created res/photos/
has the same ownership
({user-name}/www). Hint: that's sticky bit, chmod +s
. Also, the res/photos/
folder has to be writable by the www
group, so that we'll implement the
upload feature later.
Exec the spider, and wait
cd /home/{user-name}/www
sudo npm link
501px-crawl
Let's make the 501px-crawl
runs every 2 minutes.
Please see http://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800
As we don't have a nice domain name point to the playgrounds, let's make it
ngrok
ed. Just type
ngrok http 80 -subdomain=of-{user-name}
Or use the already installed psi
cli tool