No, it is not possible to apply for a visa (of pretty much any kind) for the UK, from within the UK. In fact, they must (under normal circumstances) apply from their country of residence - note that the UK frequently refers to visas as "entry clearance". According the UK Immigration Rules, part 1:
- An applicant for an entry clearance must be outside the United Kingdom and Islands at the time of the application. An applicant for an entry clearance who is seeking entry as a short-term student must apply to a post designated by the Secretary of State to accept applications for entry clearance for that purpose and from that category of applicant. Subject to paragraph 28A, any other application must be made to the post in the country or territory where the applicant is living which has been designated by the Secretary of State to accept applications for entry clearance for that purpose and from that category of applicant. Where there is no such post the applicant must apply to the appropriate designated post outside the country or territory where he is living.
However, your central premise is somewhat flawed. It isn't possible to extend visitor stays by getting a visa. Equally, the UK doesn't really differentiate between those who have a visa and those who don't need one - they are all, normally admitted for 6 months. So your girlfriend can remain for up to 6 months without a visa. However, the length of admitted stay is at the discretion of the Immigration Officer that admits her. See again, Immigration Rules part 1:
23A. A person who is not a visa national and who is seeking leave to enter on arrival in the United Kingdom for a period not exceeding 6 months for a purpose for which prior entry clearance is not required under these Rules may be granted such leave, for a period not exceeding 6 months.
It seems as if you and your girlfriend are not really familiar with the rules. You should probably become (at least passingly) so, especially with
Appendix V which describes the rules for visitors. The sections of interest to you are probably V1 and V4 (which describes who is eligible, and what you can and can't do). Note that V4.10 forbids you getting married unless you have a visa that is marked for this purpose.
Note that your girlfriend may be asked what she is doing, how long she intends to do it for, and how she intends to support herself in this time. She may be asked to provide evidence to support this. They may call you, to confirm that her story is correct and that you will house her. You should agree in advance how long she is staying. If she is not so wealthy that plane ticket costs are trivial, she should have a return flight ticket (can be refundable/changeable) so that they know she can still leave even if she overspends. Alternatively, she may get waved through after minimal questioning - but you need to be prepared for the more thorough approach.
Note that the phrasing of your question would ring alarm bells for immigration. You say (emphasis mine):
But I need her to stay longer
There is nothing permitted under visitor rules, other than perhaps medical treatment that would count as need rather than want. Saying things to the IO like "But I need to stay for 4 months" will immediately set off alarm bells and further questioning.
Note: Your girlfriend shouldn't attempt to follow any "strategies" when talking to the IO, except telling truthful answers to their questions. If you search the tags uk us-citizens together, you will find numerous examples of US citizens who were refused entry when trying to be clever, who would have been allowed in if they just both:
- Were honest/truthful
- Didn't volunteer extra information/ask for things that don't exist (eg a 3 month "visa" for a 2 week visa-free stay)