SubDirectories Versus Subdomains Which Is Better? How to Create them by ISPConfig?

Discussion in 'HOWTO-Related Questions' started by tejas28, Jul 7, 2015.

  1. tejas28

    tejas28 New Member

    Earlier i had my home server set up on opensuse 13.2. I was managing it without any control panel by modifying files manually. Later on i started using 'monit' and liked it. Now I want to try ISPConfig control panel to create my website from scratch. I have few questions:
    (1)On opensuse 13.2 (without using ISPConfig) my directory structure was as below:
    Web root: /srv/www/htdocs: The index.html page inside htdocs was accessed by http://magicbits.net
    Moodle: /srv/www/htdocs/moodle Accessed in browser by http://magicbits.net/moodle
    Wordpress:srv/www/htdocs/wordpress Accessed in browser by http://magicbits.net/wordpress
    ..........and so on for other PHP-MYSQL solutions put inside "htdocs"
    Here i faced one problem: My SSL certificate was for "magicbits.net" and browser was showing warning when a person typed URL -say- magicbits.net/moodle. WOULD A WILD CARD SSL CERTIFICATE HAVE SOLVED THIS PROBLEM OR DO I HAVE TO BY DIFFERENT CERTIFICATES FOR "magicbits.net" , "magicbits.net/moodle", "magicbits.net/wordpress" .......... and so on?

    (2) Now that i have successfully installed ISPConfig-after replacing OPENSUSE 13.2 by UBUNTU 14.02 LTS server- i want to try the sub domain approach i.e. I want my sites to be accessed by "moodle.magicbits.net" , "wordpress.magicbits.net", "webmail.magicbits.net"... and so on. CAN SOMEONE GIVE STEP BY STEP METHOD TO DO THIS BY USING ISPConfig CONTROL PANEL? I think it is done by creating virtual hosts but i am not clear in that area. I also want to know if i have to purchase different SSL certificates for "magicbits.net" , "moodle.magicbits.net" , "wordpress.magicbits.net"......etc or there is a way to use a single certificate for all?

    (3)Can someone suggest which out of (1) and (2) above is better for a single site on a home server? Any third better alternative is also welcome.
    Sorry for rather long post but i tried to give maximum details. Thanks in advance to all.
     
    Alex Bryan likes this.
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    There must have been something else wrong with your old setup as sl certs are lways for a domain / ubdomain and never for a path. So when you have a ssl cert for magicbits.net then this cert is valid for all directories of that domain.

    Klick on new website, enter "moodle.magicbits.net" in the domain field and press save. Repeat this for as many subdomains you want to have. As mentioned above, ssl certs are domain specific, so when you want to have ssl for these subdomains, then you need a wildcard ssl cert that you set in ecah of these websites.

    This has several aspects like security and seo. security wise the subdomain approach is better as the sites are isolated, so when your wordpress website would get hacked, then the hacker will not get access to moodle. From a seo standpoint, subdomains are separating the content more then directories. This can be good or bad for your specific site and depends on your website strategy.
     
    Alex Bryan likes this.
  3. tejas28

    tejas28 New Member

    Thanks Till. Here i have two more questions:
    (1) I run my website behind a router. I can handle port forwarding etc and my ISP puts no restriction whatsoever.I also have static IP address. I installed squirrelmail as per tutorial Perfect server: Ubuntu Plus LAMP on sourforge website. Squirrelmail was successfully installed and i could access it through magicbits.net/webmail. However when i tried to create virtual host as per last step in the tutorial i could not access by browser. DO I NEED TO TWEAK ROUTER SETTINGS FOR USING VIRTUAL HOSTS?
    (2) Once my server is setup, i want to clone it exactly to another identical os with almost similar hardware. I am planning to go as below:
    (A) Using live cd of clonezilla or fsarchiver i will clone entire file system on external hard drive.
    (B) Set up system on second PC by image created in step (A); DO I NEED TO MODIFY /etc/fstab ON THAT PC AND INSTALL ISPCOFIG ON IT MANUALLY?
    (C) USE feature "is clone of" OF ISPCONFIG on clone (mirror server) . How exactly should i use that feature?.I want to put two servers at two different locations and use two different IPaddresses from two different ISPs and want to ensure that visitots to magicbits.net are automatically re directed to clone (mirror) server in case the master server is not accessible.
    CAN I PUT THIS SETUP IN PLACE TOTALLY BY ISPCONFIG CONTROL PANELS ON MASTER AND MIRROR SERVER BY ABOVE STEPS (a) (b) (c)? IF YES THEN HOW? IF NO THEN
    WHAT IS MISSING IN ABOVE STEPS?
    It is my humble suggesstion to incororate a module in ISPCONFIG by which one can easily create clone of existing server on other PC connected to existing server by internet or local network.
     
    Alex Bryan likes this.
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    1) No. you just have to ensure that the domain / subdomain of the website you created exists in dns an points to the external ip of the ruter. To access the website, just enter the domain / subdomain name in the browser.
    2) Please see mirror tutorial on how to install a ISPConfig mirror setup. A mirror is not just a clone of a single server.

    https://www.howtoforge.com/installi...tabase-cluster-on-debian-6.0-with-ispconfig-3
     
    Alex Bryan likes this.
  5. tejas28

    tejas28 New Member

    subdomains.png websites.png
    Ok! Initially I forget about mirror and cloning. I guess I need to first set up my server.
    As per your guidance in point (1), I created sub domains (see above image subdomains.png) at my GoDaddy account. I also created two websites using ISPConfig (see above image websites.png). Now when I type (From another computer on internet) http://moodle.magicbits.net [ or smimer.magicbits.net for the other site], I get message "The site is temporarily unavailable. Please try again later". Same message is obtained for webmail.magicbits.net [ though it was not created by ISPConfig but by manually editing file as per this tutorial on howtoforge ]. Please see msg.png file below.
    msg.png
    If I type 192.168.0.101 (My router's internal IP) I am led to squirrel-mail login page (IS THIS EXPECTED BEHAVIOUR?). If I type http://magicbits.net then I am lead to the default Apache "It works! page (see image apache2.png)".
    apache2.png

    If I type a random subdomain (say xyz.magicbits.net) then I get "Server not found" message - as expected because there is no DNS record for xyz.magicbits.net in my GoDaddy account- so it seems I am on right track.

    IN PLACE OF message "The site is temporarily unavailable. Please try again later" I was expecting to see the welcome page of ISPConfig as below. (Or at least standard ISPConfig error messages). welcome.png
    I HAVE CHECKED THAT SITE IS ACTIVE (see img1.png below). I also checked that 'Redirect' is set.(See img2.png below).

    img1.png img2.png
    ONE VERY IMPORTANT INFORMATION I WANT TO GIVE IS THAT I FOLLOWED THE TUTORIAL "Perfect Server: Ubuntu+LAMP" WITH A DIFFERENCE. THE TUTORIAL ASKS TO JUST SET UP SSH SERVER WHILE INSTALLING UBUNTU BUT I SELECTED TO INSTALL ALL SERVERS AT THE TIME OF INSTALLING UBUNTU.
    What should I do so that sites created by ISPConfig are accessible through moodle.magicbits.net or smimer.magicbits.net etc?


    Please forgive me if I am asking basic questions. I have decided to go for sub domain approach where I am new (all my earlier sites were set by subdirectory approach). I am also new to ISPConfig. Thanks in advance.
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    The setup at your ISP is wrong, you have to add a dns a-record that points to your external IP address and not a forward. a forward means that the subdomain points to your domain registrar and not your server, he then forwards the request but the information which vhost shall be shown gets lost during forward, thats why apache cant show you the correct page. therefr a a-record is required instaed of a forward.

    This might be ok but dont has to be ok, depends on the reason why it is shown :) Please open the squirrelmail.conf file and remove the optional vhost that you might have added there. Then restart apache.

    Finally remove all details that you entered on the redirect tab of the website in ispconfig, there is no redirect required.
     
  7. tejas28

    tejas28 New Member

    Thanks Till. I did all changes as per your instructions above and now "moodle.magicbits.net" , or "smimer.magicbits.net" do give me the expected "Welcome" page as shown below.
    welcome.png

    So I think your guidance has put me on right track. Now i will put my 'moodle', 'wordpress', 'prestashop' ....etc. in their corresponding websites and install. THANKS FOR PUTTING ME ON RIGHT TRACK.
     
    till likes this.
  8. tejas28

    tejas28 New Member

    Hi!
    This post is with respect to above posts. I tried to install moodle after creating subdomain moodle.magicbits.net . I checked that moodle.magicbits.net can be accessed from web browser and gives the default ISPConfig welcom page as in previous post. My steps were as follows:
    (1)Extract latest moodle tar archieve into directory var/www/moodle.magicbits.net/web/
    (2)Created a mysql database for moodle using PhpMyAdmin
    (3)Created moodle_data directory in var/www/
    (4)Changed ownership of both moodle and moodle_data directories by:
    root@magicbits # chown -R www-data /var/www/moodle_data
    root@magicbits # chown -R www-data /var/www/moodle.magicbits.net/web/moodle
    CHECKED THAT OWNERSHIPS HAVE INDEED BEEN CHANGED
    (5)Changed file permissions of both moodle and moodle_data directories by:
    chmod -R 777 /var/www/moodle_data
    chmod -R 0755 /var/www/moodle.magicbits.net/web/moodle
    (6)Changed default storage engine to innodb for moodle in /etc/mysql/my.cnf
    (7)Restarted apache2 and mysql servers successfully
    (8)In web browser typed http://moodle.magicbits.net/web/moodle
    THIS SHOULD START THE WEB INSTALLER OF MOODLE AND FURTHER INSTALLATION IS DONE BY FOLLOWING ITS PROMPTS. INSTEAD I GOT 404 ERROR OF ISPCONFIG PAGE.
    "The requested URL was not found on this server."
    WHAT SHOULD I DO? i HAVE SUCCESSFULLY INSTALLED AND ADMINISTERED MOODLE BY EXTRACTING "moodle" TO
    /var/www/html/ , CHANGING PERMISSIONS AND OWNERSHIPS AS ABOVE AND THEN USING WEB BASED INSTALLATION. BUT NOW I WANT TO DO IT BY "subdomain approach" USING ISPCONFIG.
    PLEASE GUIDE ME. SEEMS SOME KIND OF PERMISSION ISSUE TO ME BUT NOT SURE.
     
  9. If you created a new website for this subdomain like till explained you can just access your main website with http://moodle.magicbits.net . You don't have to use the /web directory since thats the default directory apache will show.
     
    Alex Bryan likes this.
  10. btw. Be aware that you are posting website links to your actual website. I was just able to install your moodle setup with http://moodle.magicbits.net/moodle . Now we don't have a bad reputation here in the community, but everybody could access and install your website right now ;)
     
    Alex Bryan likes this.
  11. You also need to change a few things I see now. You extracted the moodle installation in /var/www/clients/client2/web4/web/moodle . Instead you should extract the moodle files in the /web directory. If you dont change this, people will have to access the website with http://moodle.magicbits.net/moodle. I also recommend you install the moodledata in the webdirectory of the website instead of the main /var/www
     
    Alex Bryan likes this.
  12. inantuigiay

    inantuigiay New Member

    I also recommend you install the moodledata in the webdirectory of the website instead of the main /var/www
     
    Alex Bryan likes this.
  13. tejas28

    tejas28 New Member

    screenshot1.png screenshot2.png Thanks for pointing out the security aspect. Currently there is nothing on website as I am still playing with ISPConfig (and liking it). Your suggestion to extract the moodle files in the /web directory was implemented. Thanks for that. However about location of moodle data directory i was not clear. Actually moodle developers prescribe that "moodle code" and "moodle data" should be (NOT MUST BE) in different directories.
    Actually the web installer can automatically create webdata directory but here i am getting the error (See screenshot1 below) "Parent directory (/var/www/clients/client2/web4) is not writeable. Data directory (/var/www/clients/client2/web4/moodledata) cannot be created by the installer."
    The reason is also seen at the top of screnshot2 below. Warning: is_writable(): open_basedir restriction in effect. File(/var/www/clients/client2/web4) is not within the allowed path(s):
    Now in opensuse i could easily set path by yast control panel but with ubuntu i will have to find out. Even if I use system root privileges, i can not create a directory in /var/www/moodle.magicbits.net/. DOES THIS MEAN ISPCONFIG 'admin' IS HAVING MORE PRIVILEGES THAN EVEN THE "sytemroot"?
     
    Alex Bryan likes this.
  14. tejas28

    tejas28 New Member

  15. till

    till Super Moderator Staff Member ISPConfig Developer

    First add ":/var/www/clients/client2/web4/private"at the end of the existing data in the open_basedir field of the website, you find it on the options tab. This allows php to write data into the private directory. The moodle data directory should then be:

    /var/www/clients/client2/web4/private/moodledata

    as all data that shall not be accessible has to be in /var/www/clients/client2/web4/private and all data that you want to access over the web is in /var/www/clients/client2/web4/web
     
  16. nathes2016

    nathes2016 New Member

    Here someone installing wordpress encountered same error. However i can not understand the various solutions (?) suggested:(



    ____________________________

    The 16th China International Lighting Fair (Autumn Fair) will be held from 22-26 October, 2015 at the Guzhen Convention and Exhibition Centre in Zhongshan City, Guangdong Province.
     
    Alex Bryan likes this.
  17. Rakjasaman

    Rakjasaman New Member

    nice place i like this
     
    Alex Bryan likes this.

Share This Page