Adding a new domain website
> useradd -d /home/mydomain.com -m mydomain.com
[note that adduser is different. it requires more details]
[rm -r to remove the directory from /home/mydomain]
[userdel to delete the user if wrongly created]
> passwd mydomain.com
> usermod -a -G www-data mydomain.com
[this adds your user to the www-data group]
> chgrp -R www-data /home/mydomain.com/public
> chmod -R 2750 /home/mydomain.com/public
> chmod -R 2770 /home/mydomain.com/public/uploads
[if you copy stuff from another directory using root remember to use following]
> chown -R mydomain:www-data /home/mydomain.com/public
> chgrp -R www-data /home/mydomain.com/public
> chmod -R 2750 /home/mydomain.com/public
[otherwise you may get ftp errors]
[lightly configuation and logs]
> nano /etc/lighttpd/lighttpd.conf
[find a nice place: scroll all the way down till: #### handle Debian Policy Manual, Section 11.5. urls]
[add in the following]
$HTTP["host"] =~ “(^|\.)mydomain\.com$” {
server.document-root = “/home/mydomain.com/public”
server.errorlog = “/var/log/lighttpd/mydomain.com/error.log”
accesslog.filename = “/var/log/lighttpd/mydomain.com/access.log”
server.error-handler-404 = “/e404.php”
}
> mkdir /var/log/lighttpd/mydomain.com
> chown -R www-data:www-data /var/log/lighttpd
[now lighttpd own this logs directory]
[you have to run this everytime you add a new domain]
> /etc/init.d/lighttpd restart
[this should restart the server nicely. if you have installed vsftp you should be able to put in a test.html file in the public folder and test it.]
[at this time you can configure your dns for mydomain.com to point to this ip address. This would be the A record]
FAQ:
Q: Why asd.html file is not found but sdf.html file is found when i type in 123.45.67.89 when both files are in the directory?
A: File permission settings might be wrong. check that www-data is the group and its chmod -R 2750 to the public folder
Setting up Wordpress
[Another big topic. please read other installation guide]
[ftp into your main domain]
[download the latest version of wordpress]
[upzip and upload to public folder]
[the following copies the wordpress setup from mydomain.com to mydomain2.com]
> cd /home/mydomain2.com/public
> cp -R /home/mydomain.com/wp wp
> chown -R mydomain2.com wp
[remember to regenerate API keys.]
[remember to create new db and update config file]
[recommended plugins: zero conf mail, configure smtp, google anilicator]
[make sure ownership is correct.]
[this might come in handy: > chown -R mydomain.com:www-data /home/mydomain.com/public]
[Adding lighttpd supported permalinks]
[Ref: http://www.cyberciti.biz/tips/lighttpd-and-wordpress-setup-clean-seo-friendly-urls.html]
