There are many schools that offer a PhD (or other Doctorate degree) online.
please note I am speaking only of US schools.
While many are considered degree mills, others rise above this and offer quality education. Still further, many traditional universities have online PhD programs.
The question one should be asking is 'will a PhD completed online be of value, or of as much value of a traditional on campus brick and mortar PhD?'
The answer is highly situational. First, the 'quality education' part. This is determined by accreditation.
Degree mills (where you just pay money and get a degree) are not respectable in the slightest. They are generally not accredited or accredited by a dubious agency. It is a vanity purchase and means nothing of value to anyone of discerning character. They should be avoided at all costs.
Second up is Nationally Accredited. These are actual accredited schools and recognized by the US Dept of Education and are held to some standards. You will have to do the work. You will buy textbooks and it will take you several years to get done. These degrees are often sought by working professionals that do not have time or the ability to go to a campus and compete a residency requirement. In many cases, they are just as rigorous (hard) as a traditional PhD, and in others, much easier.
Third is Regionally Accredited. These are usually state schools that are offering a PhD online. Many are very good schools, others are not. It will depend on the program itself. generally, most people regard regional accreditation a bit higher than national.
Accreditation is the first thing you should look at and find out who the accrediting agency is and if they are legitimate.
The other part of this question is residency. Can the degree be completed 100% online. Some schools will have no residency requirement at all. Every course may be completed online and any exams may be taken at a testing center near you (often a library or local school) with a proctor. Others may require a short residency of a few weeks or a single semester. In between them is a 'weekend residency' where you travel to the university for a few days, at one or more times through out the program. These often take the form of workshops or seminars.
There are various combinations of these traits in hundreds of schools.
To provide an example, the University of Missouri offers several Online Only PhD programs, here is one of them:
Many universities recognize that online education is an effective medium for learning and that not everyone can travel or dedicate time to living on campus. With some research, you are likely to find a PhD program available online that suits your needs. Pay careful attention to accreditation and any residency requirements and you may find a path forward that suits your needs in higher education.