@Sanvidha Herath
They both can reside on the same server .. me thinks it's a matter of 'proximity' to one another.
Typically, WP would be the default site. While you could have your WP interactive or even linked to the Moodle for certain purposes, WP's are 'informational' in nature - who we are, about us, staff, our services, our goals ... even descriptions of courses offered in the moodle with a link to sign up or the course itself. etc..
Moodle on the other hand is interactive.
Proximity .... used to be the standard location for the software that rules the roost for a web site was in /home/useraccount/public_html/ but could be in /var/www/html/. If moodle were installed inside WP code it is seen by WP as part of WP and under control of WP's .htaccess. Not good.
Below tld.x is a
domain (tld = top level domain - like, for example, google.com. A subdomain of that would be like maps.google.com
Depending upon how and where you
host, your moodle could be called elearning.tld.x - a subdomain of the WP at tld.x. And because it is a subdomain, elearning.tld.x has to be located else where on that server. So elearning.tld.x could be in /home/useraccount/elearning.tld.x or /var/www/elearning.tld.x.
DNS points to same server and the config of your web service determines where traffic is directed when someone goes to elarning.tld.x.
elearning.tld.x now being away from the WP, it can have it's own restrictions when it comes to access and version of php it runs under (a possible use of .htaccess). Moodle is more sensitive about versions of software that make it go ... ie, PHP + php extensions.
That clear as mud? :|
'SoS', Ken