Can I apply for student visa from US?.
As I am currently in US on tourist visa.
Is it necessaire to apply from your home country?
No, you cant get visa from being inside US.
One needs to travel outside the US to get the visa stamp. But you can try to request change of status from B1 to F1 but surely 99.99% uscis would deny(due to many candidates earlier like this try to stay in the country for longer period after gaining one entry). So you can still try your luck as its allowed per law to request change of status. Later if they deny then you can decide what needs to be done.
Its easier and safe(when application gets delayed) to apply from home country than applying from third country.