//

2009/07/09

Setup a website in Linux

1. Create the website user (usually the domain name is the user)
# /usr/sbin/useradd yourdomain.com

Give a password to the user. This password will be used as the ftp password.
# passwd yourdomain.com
Changing password for user yourdomain.com.
New UNIX password:
*****
Retype new UNIX password:
*****
passwd: all authentication tokens updated successfully.

2. Create the website directory.
# mkdir /home/yourdomain.com/www

3. Create log directory.
# mkdir /home/yourdomain.com/logs

4. Configure the vhost for virtual hosting:
# nano /usr/local/apache2/conf/extra/httpd-vhosts.conf

For each domain, need a directive as below:

<'virtualhost *:80'>
ServerAdmin admin@yourdomain.com.my
ServerName yourdomain.com
ServerAlias www.yourdomain.com
<'directory'>
Options FollowSymLinks
AllowOverride All
Order deny,allow
allow from all
<'/directory'>
DocumentRoot "/home/yourdomain.com/www"
ErrorLog "/home/yourdomain.com/logs/yourdomain.com-error_log"
CustomLog "/home/yourdomain.com/logs/yourdomain.com-access_log" common
<'/virtualhost'>

5. Check apache configuration:
# /usr/local/apache2/bin/apachectl configtest

6. Stop and start the apache:
# /usr/local/apache2/bin/apachectl stop
# /usr/local/apache2/bin/apachectl start

7. Check the ownership of /home/domain_name if getting 403 forbidden error:
Set the permission of /home/domain_name
# chmod -R 755 /home/yourdomain.com/
# chown -R yourdomain.com:yourdomain.com /home/yourdomain.com/

No comments:

IP address