Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Advertise on LowEndTalk.com
Cofigure VirtualHost in VPS !
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

Cofigure VirtualHost in VPS !

shyaminayeshshyaminayesh Member
edited April 2013 in General

hi frnds,

i'm trying to host 2 sites in my VPS using VirtualHost. but i can't configure it correctly. can any one explain how to do this. i add A records with www point to my VPS IP in both domains. and then i create 2 folders in www folder like this.

/var/www/site1/public_html

/var/www/site2/public.html

after that i place different index.html files in both locations. and i set permission using this command.

chown -R root:root /var/www/site1/public_html

chown -R root:root /var/www/site2/public_html

and after of that i edit the httpd.conf file and add this lines to the VirtualHost section.

<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/site1/public_html ServerName www.site1.com </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/site2/public_html ServerName www.site2.com </VirtualHost>

but the problem is both domains are get the apache 2 test page. please anyone can help me to resolve this problem. thanks ... :/

Comments

  • Did you restart your Apache after the changes are made? If that still does not work, try issue a reboot.

    http://BornIn.Asia - FREE shared hosting and subdomain service for LET members! Click here to see how to get one yourself!
    96Forum: Low End VPS Discussions. Selling domains with GApp with various user counts (10 year reg incl. for some)

  • mikhomikho Member, Provider

    Wouldn't a config reload be enough?

    Get a LES NAT VPS! (or 10) in United States (3), Germany, Bulgaria, France, Norway, Australia (2), Singapore. | -> 500gb NAT Storage
  • chown -R www-data:www-data /var/www/site1/public_html ?????

    Hi!

  • @zhuanyi said: Did you restart your Apache after the changes are made? If that still does not work, try issue a reboot.

    yeah ... i try restart httpd and restart my server ... but the issue is still have ....

  • texteditortexteditor Member
    edited April 2013

    Make sure to get rid of any default config too

    edit for clarity: Apache should have a default vhost file created depending on your distribution that can cause other VirtualHosts that you create yourself to not load properly; check and make sure that isn't the case.

    Contractually bound by a verbal non-disclosure agreement

  • @texteditor said: Make sure to get rid of any default config too

    mmm ... i installed httpd server and php engine only ... :/

  • is there any tutorial for this ... ?? :'(

  • Here's the Linode Library information on basic installation and vhosts I use as a reference https://library.linode.com/web-servers/apache/installation/debian-6-squeeze

    Contractually bound by a verbal non-disclosure agreement

  • If this server is bare currently, I would suggest trying out ZPanel. Super user friendly install, and everything (for me) worked right out of the box on CentOS 6.4. And it is free. I believe you need to install this on a fresh server, though, so you would likely have to reinstall.

    www.zpanel.com

  • also you shouldn't give root ownership of those files, and/or check and see if the directories are set to rwxr-xr-x (755)

    Contractually bound by a verbal non-disclosure agreement

  • NoermanNoerman Member
    edited April 2013

    What tutorial do you use before?

    Try install webmin, it will detect what you already installed so we can know what to do.

    Get Storage VPS (40% Off Discount: 40PERCENT) | BuyShared & Reseller (Free Dedicated IP) (aff links)

  • Edit apache2.conf?

    Also, it's better to create individual conf files for each site in /etc/apache2/sites-available and use a2ensite

  • pretty sure all a2ensite does is symbolically link them to sites-enabled

    Contractually bound by a verbal non-disclosure agreement

  • The point is that apache on some distros is ignoring httpd.conf and using apache2.conf (and individual configs in sites-enabled). Sure, you can just ln -s blah blah but it's easier to a2ensite?

  • shyaminayeshshyaminayesh Member
    edited April 2013

    @vedran said: The point is that apache on some distros is ignoring httpd.conf and using apache2.conf (and individual configs in sites-enabled). Sure, you can just ln -s blah blah but it's easier to a2ensite?

    i'm working on cent os 6.3 minimal ... is there any issue ...

    yum install apache2 say's

    No package apache2 available.

  • BlazeMuisBlazeMuis Member
    edited April 2013

    @shyaminayesh said: yum install apache2 say's

    No package apache2 available.

    It's HTTPD on CentOS...

  • @joodle said: It's HTTPD on CentOS

    yes i'm currently working with httpd ...

  • @shyaminayesh said: yes i'm currently working with httpd ...

    You're trying to do "yum install apache2" on CentOS, that won't work as you've seen
    Then i said that it's yum install httpd, and you're just saying that you're "currently working with httpd"

    Did i mis something?

  • @joodle said: Did i mis something?

    nope ... i'm just try to install apache2 in this ... :D but it doesn't work & my previous httpd is working now ...

  • 198.23.249.33

    this is the IP of my server ... now i rebuild it with cent os 6.3 minimal & i installed httpd in it ... then i need to host two domains in this server ... can anyone please help me to do it ... i execute this commands set only ...

    yum install httpd

    yum install nano
    yum install php
    service httpd start

    what i do next ...

  • From fresh vps,
    I suggest you install webmin, after that login, and you don't have anything installed yet, so use webmin to install it.

    For better process use virtualmin, it just few click shorter compared to webmin.

    https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-centos-6 tutorial is not complete.

    Get Storage VPS (40% Off Discount: 40PERCENT) | BuyShared & Reseller (Free Dedicated IP) (aff links)

  • twaintwain Member

    @shyaminayesh - Great site for Linux server config/setup, multiple distros.
    http://www.server-world.info/en

  • @shyaminayesh said: but the problem is both domains are get the apache 2 test page. please anyone can help me to resolve this problem. thanks ... :/

    ServerName site1.com
    ServerAlias www.site1.com

    Try this for both? With your current setup it will only server the site to www.site1.com and www.site2.com but not if you go to site1/2.com

    Also don't have Root as the owner of the web files.

  • @Noerman said: I suggest you install webmin, after that login, and you don't have anything installed yet, so use webmin to install it.

    i install webmin ... and i create 2 sites using it ... now the problem is both sites give me the same index.html file

    http://www.sithruu.info/

    http://www.freethemebucket.info/

  • @shyaminayesh your virtual host containers are not correct. If you want me to do this for you send me a PM.
    If not first don't put your containers in httpd.conf. Also you are trying to make use of name based virtual hosts and your ServerNames are not right. Set your www. with ServerAlias.
    Would be a lot easier just to do it for you so you can see all of this in action. You are doing too much wrong.

  • vladincvladinc Member
    edited April 2013

    Try this:
    <VirtualHost your_IP:80> ServerAdmin [email protected] ServerName site1.com ServerAlias site1.com DocumentRoot /var/www/site1.com/public_html ErrorLog logs/site1_com-error_log CustomLog logs/site1_com-access_log common </VirtualHost>

    http://vladinc.co.uk - freelance web and graphic design

  • @vladinc That's the right one.

    Happy to be alive and kicking!

  • @natestamm said: @shyaminayesh your virtual host containers are not correct. If you want me to do this for you send me a PM.

    I agree, something in the setup is causing your virtualhosts to not work. i have webmin on a few systems and i also have just a CLI on the rest. PM @natestamm or me if you want us to look at it in the mean time.

    Gauged Hosting | [email protected] | Latest LEB specials - HERE
  • @NickGH said: I agree, something in the setup is causing your virtualhosts to not work. i have webmin on a few systems and i also have just a CLI on the rest. PM @natestamm or me if you want us to look at it in the mean time.

    mmmm ... thank you very much for help, greatly appreciate ... i'll inform you quickly ...

  • hdpixelhdpixel Member
    edited April 2013

    My last lamp install notes. Centos 6.4/6.3

    1. yum install wget nano

    yum update

    Download repos for newer and extra packages

    EPEL i386
    wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

    or

    EPEL x86_64
    wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

    and

    rpmforge 32bit
    wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm

    or

    rpmforge 64bit
    wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

    and

    Remi 6 i386
    http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

    install repos
    rpm -Uvh remi-release-6.rpm epel-release-6.rpm rpmforge-release-*.rpm

    set priority to 10. Edit the repos config files below.
    ls -1 /etc/yum.repos.d/epel* /etc/yum.repos.d/remi.repo
    priority=10

    nano /etc/yum.repos.d/epel*
    nano /etc/yum.repos.d/remi.repo
    priority=10

    yum install yum-priorities

    yum groupinstall 'Development'

    yum --enablerepo=remi install httpd php php-common openssl-devel openssl mod_ssl rpm-build rpm-devel autoconf automake lynx gcc

    yum --enablerepo=remi install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

    Start apache.
    /etc/init.d/httpd start

    Start apache after reboot
    chkconfig --levels 235 httpd on

    NOTE: On Centos, add the user apache to the group who owns the directory. For example, I created a user in /home/jeff/ user and group is: jeff:jeff
    You will add the user apache to the group jeff.

    Set the right permissions on the web folder.

    -chmod 770 /home/jeff
    -ownership folder jeff is
    drwxr-x---. jeff:jeff

    Create a web folder public_html. See permissions below.

    chmod 755 /home/jeff/public_html
    drwxr-xr-x 23 jeff jeff 4096 Mar 21 13:07 public_html

    Edit Apache configuration file
    nano /etc/httpd/conf/httpd.conf

    < VirtualHost xx.xx.xx.xx:80>
    ServerAdmin [email protected]
    DirectoryIndex index.html index.php
    DocumentRoot /home/user/public_html
    Options - Indexes FollowSymLinks MultiViews AllowOverride All Order allow , deny allow from all
    # CGI Directory
    ScriptAlias /cgi-bin/ /home/user/public_html/cgi-bin/
    <Location /cgi-bin>
    Options+ExecCGI
    </Location>
    ServerName website.com
    ServerAlias www.website..com

    # Logfiles
    ErrorLog "logs/user_error_log"
    CustomLog "logs/user_access_log" common
    </VirtualHost>

    # website.com ssl
    <VirtualHost xx.xx.xx.xx:443>
    SSLEngine On
    SSLCertificateFile /etc/ssl/localcerts/www_website._com.crt
    SSLCertificateKeyFile /etc/ssl/localcerts/www.website.com.key
    SSLCACertificateFile /etc/ssl/localcerts/AddTrustExternalCARoot.crt
    SSLCertificateChainFile /etc/ssl/localcerts/PositiveSSLCA2.crt

    ServerAdmin [email protected]
    DirectoryIndex index.html index.php
    DocumentRoot /home/user/public_html

    <Directory /home/user/public_html>
    Options-Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>

    # CGI Directory
    ScriptAlias /cgi-bin/ /home/user/public_html/cgi-bin/
    <Location /cgi-bin>
    Options+ExecCGI
    </Location>

    ServerName www.website.com
    # ServerAlias www.website..com

    # Logfiles
    ErrorLog "logs/user_error_log"
    CustomLog "logs/user_access_log" common
    </VirtualHost>

    /etc/init.d/httpd restart

    Mysql db installation
    yum --enablerepo=remi install mysql mod_auth_mysql mysql-devel mysql-server

    yum --enablerepo=remi install mod_python python python-devel

    yum --enablerepo=remi install perl mod_perl mod_perl-devel openssl-perl perl-Convert-ASN1 perl-Date-Calc perl-DateManip perl-HTML-Parser perl-libwww-perl perl-CPAN perl-DBD-MySQL perl-XML-Parser

    yum install openssh-clients
    chkconfig --levels 235 mysql on

    more stuff...
    logwatch
    mod_sec
    apf firewall
    bfd
    etc.,

  • mikhomikho Member, Provider

    I cant find this # Listen for virtual host requests on all IP addresses NameVirtualHost *:80 in your apache config.

    according to this : http://httpd.apache.org/docs/2.2/vhosts/examples.html you must have it and your DNS should be pointing those domain names to your server.

    Get a LES NAT VPS! (or 10) in United States (3), Germany, Bulgaria, France, Norway, Australia (2), Singapore. | -> 500gb NAT Storage
  • yeah ... @Noerman thank you very much for your help ... also thanks to all of you for helping me ... finally @Noerman give me a big help to do this with webmin panel ... yeah now it's working perfect ... :D

  • @shyaminayesh good luck with your new websites

    Happy to be alive and kicking!

  • @vRozenSch00n : hey hey thank you very much ... :D

  • @shyaminayesh Love to help you, don't forget to learn for more.

    Get Storage VPS (40% Off Discount: 40PERCENT) | BuyShared & Reseller (Free Dedicated IP) (aff links)

  • budingyunbudingyun Member
    edited April 2013

    Learn how to configure manually. :)
    Real man doesn't need control panel. :p

  • @budingyun : yep ... i'm trying to do it without control panel ...

    @Noerman said: @shyaminayesh Love to help you, don't forget to learn for more.

    yep ... still learning ... :D

  • @shyaminayesh said: yep ... still learning ... :D

    I recommend you learn how setup nginx + php-fpm. :D

Sign In or Register to comment.