How to automatically lock my computer after logged in via auto login

i have setup my ubuntu 12.04 LTS (unity) to auto login after the computer is turned on after a power outage. so that the web server installed keeps running. but also i have to lock the computer right after logging in so that no one can use it other than me. How would i do that.

gnome-screensaver-command -l does lock the computer. but manaully. i want it automated after login.

I dont want anyone to be using the computer other than me.


When you install a web server, you don't need to "login" to run that web server.

Web servers such as apache or nginx start up at boot time with their parent process run by root (to bind to ports). Subsequent child processes are generally started with the user or group specified in the configs. Therefore, your computer can be on but not logged in, and your system will still run the web server. Remote administration can be done by SSH whether you're logged in via the GUI or not.

Therefore, there is no need for autologin to make the webserver work (unless its a weird Node.js or some other backend that needs to be manually started by a user).