For a website, sometime we used more than a script that separated, yes separated and dont have connection at all each other

for example is a forum, using vbulletin is a blog, using wordpress is ecommerce, using oscommerce is article cms, using joomla

so for security best practice, like if one of the script get hacked or get something wrong,
another script files in another folder,
and another mysql database,
is still secure

can we do that? if so how to do that actually? its looks like simple and basic, but i am still not sure how to do it

if there is tutorial link please let me know too, still cant found it