Setup a Domain without cpanel or plesk

Its a very length process. For the 1st though I would suggest to go with Plesk or Cpanel. Use there demo setups for creating 1 domain and then explore how others can be created without these panels. But if you want to use SSH only then most probably you need to do following things

  1. Create a user with useradd <user_name>
  2. Create a password for the new user with passwd <user_name>
    It will prompt you for new password and confirm password
  3. Create a group with groupadd <group_name>
    If you have already worked with cpanel then better keep username and group name same. With this username you can login to ftp
  4. Add the user to the new group with
    gpasswd -a <user_name> <group_name>
  5. Create a directory with user_name in /home with
    mkdir /home/user_name
    mkdir /home/user_name/public_html   (Your website files will reside here)
  6. Create a symbolic link www pointing to public_html folder with
    ln -s /home/user_name/public_html www/
  7. Change the ownership of this directory to the usergroup with
    chgrp -R group_name /home/user_name
  8. Enable proper permissions to the above created directory with
    chmod -R g+rw /home/user_name
  9. Create a database
    Login to mysql with user name and password instead of root login
    mysql -u user_name -p user_name
  10. Create database user with
    mysql> CREATE USER ‘user_name’@’localhost’ IDENTIFIED BY ‘password’;
  11. Grant this use all privileges
    mysql> GRANT ALL PRIVILEGES ON * . * TO ‘user_name’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
  12. Create a database with name as username_databasename
    mysql> CREATE DATABASE IF NOT EXISTS `username_db1` ;
  13. Grant all rights for this database to the user.
    mysql> GRANT ALL PRIVILEGES ON `username_db1` . * TO ‘user_name’@’%’;
  14. Create a zone file.
    Create a text file with name as domain.com.zone at /var/named and then edit /var/named/domain.com.db
  15. Add the following in that file:domain.com.
    86400   IN      SOA     ns1.yournameserver.com.  webmast@domain.com (
    2008062802 ;Serial Number
    86400 ;refresh
  16. 7200 ;retry
    2419200 ;expire
    86400 ;minimum )
    domain.com.       86400   IN      NS      ns1.yournameserver.com.
    domain.com.       86400   IN      NS      ns2.yournameserver.com.
    domain.com.       14400   IN      A       YOUR IP
    localhost       14400   IN      A       127.0.0.1
    domain.com.       14400   IN      MX      0       domain.com.
    www     14400   IN      CNAME  domain.com.
    ftp     14400   IN      A       YOUR IP
    mail    14400   IN      A       YOUR IPplease note the ” . ” at the end of domain name.
  17. DNS Server: COnfiguring BIND
    Edit /etc/named.conf and add the below at appropriate location
    zone “domain.com” {
    type master;
    file “/var/named/domain.com.db”;
    };
  18. Edit your httpd.conf to add the domain routing and other domain details.
    The httpd.conf is generally located at /etc/httpd/conf/
    Edit this file and add the below details at appropriate location
    <VirtualHost YOUR_IP:80>
    ServerName domainname.com
    ServerAlias www.domainname.com
    DocumentRoot /home/user_name/public_html
    ServerAdmin webmaster@domainname.com
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/domainname.com combined
    CustomLog /usr/local/apache/domlogs/domainname.com-bytes_log “%{%s}t %I .\n%{$
    UserDir disabled
    UserDir enabled user_name
    </VirtualHost>
  19. Restart apache with
    service httpd restart
  20. Restart other service with
    service chkservd restart

Your are done now. If you found anything missing then please comment.