Linux Tutorials

Setup Per User Domain In Cent Os 7/RHEL 7

per_user_based_domain_new

In this tutorial we are going to setup Per User Based Domain like WHM/cPanel

  1. Install httpd/apache server and configuration
  2. virtual host setup
  3. installing PHP
  4. installing FTP server i.e pure-ftpd or etc
  5. Test the server

Install httpd/apache server

update all packages yum update

guess_linux_per_user_domain_setup_guide1

 

install httpd yum install httpd

 

guess_linux_per_user_domain_setup_guide2

 

we have to install  mod_ruid2 for run apache under privileged user group.

for that we have to enable EPEL repo

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 

guess_linux_per_user_domain_setup_guide3

 

then yum update

 

guess_linux_per_user_domain_setup_guide4

 

install mod_ruid2 yum install mod_ruid2

 

guess_linux_per_user_domain_setup_guide5

 

Virtual Host setup

create a file under /etc/httpd/conf.d/domainname.com.conf

vim /etc/httpd/conf.d/domainname.com.conf

 

guess_linux_per_user_domain_setup_guide6

 

 

append the following code

here 139.59.27.160 is my ip you can add your ip or “*”

<VirtualHost 139.59.27.160:80>
ServerName domainname.com
ServerAlias www.domainname.com
DocumentRoot /home/satya/public_html
ServerAdmin webmaster@satyabrata.com
UseCanonicalName Off

<Directory "/home/satya/public_html">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<IfModule ruid2_module>
RMode config
RUidGid satya satya
</IfModule>

</VirtualHost>

 

guess_linux_per_user_domain_setup_guide7

 

enable httpd server in startup

systemctl enable httpd

 

restart httpd server

systemctl restart httpd

open domainname.com

here i am added domainname.com to my Mac you can add at vi /etc/hosts and point to your server.

mine is 139.59.27.160 domainname.com

 

guess_linux_per_user_domain_setup_guide8 guess_linux_per_user_domain_setup_guide9 guess_linux_per_user_domain_setup_guide10

 

when you open domainname.com it will show you default httpd page, you have to add a index.html in /home/satya/public_html

mkdir /home/satya/public_html

guess_linux_per_user_domain_setup_guide12 guess_linux_per_user_domain_setup_guide13 guess_linux_per_user_domain_setup_guide14 guess_linux_per_user_domain_setup_guide15 guess_linux_per_user_domain_setup_guide16

vim /home/satya/public_html/index.html

add some text like Ok Tested

and save. and open domainname.com you will see the result.

 

guess_linux_per_user_domain_setup_guide17

 

Installing PHP

its very simple just type yum install php

 

guess_linux_per_user_domain_setup_guide18

 

create index.php in /home/satya/public_html and remove index.html

vim /home/satya/public_html/index.php and add the following code

guess_linux_per_user_domain_setup_guide22

<?php

echo phpinfo();

?>

then restart httpd server

systemctl restart httpd

guess_linux_per_user_domain_setup_guide21

and open domainname.com in your browser and you will get the result.

guess_linux_per_user_domain_setup_guide23

Setup FTP server for users to manage their file

yum install pure-ftpd

guess_linux_per_user_domain_setup_guide24

modify some configuration file of pure-ftpd

vim /etc/pure-ftpd/pure-ftpd.conf

guess_linux_per_user_domain_setup_guide25

comment 137 line

#PAMAuthentication             yes

uncomment 143 line

 UnixAuthentication            yes

 

guess_linux_per_user_domain_setup_guide27

 

systemctl restart pure-ftpd

guess_linux_per_user_domain_setup_guide28 guess_linux_per_user_domain_setup_guide29

You are done.

Testing Server

open domainname.com you will see php details

connect to ftp server through your hostname i.e your ip address and username, password

you can upload delete modify your file system.

guess_linux_per_user_domain_setup_guide30 guess_linux_per_user_domain_setup_guide31 guess_linux_per_user_domain_setup_guide32 guess_linux_per_user_domain_setup_guide33 guess_linux_per_user_domain_setup_guide34 guess_linux_per_user_domain_setup_guide35 guess_linux_per_user_domain_setup_guide36 guess_linux_per_user_domain_setup_guide37 guess_linux_per_user_domain_setup_guide38 guess_linux_per_user_domain_setup_guide39

THANK YOU

Leave a Comment