I could write a book for this one because it is such a broad question.
All I can say is that when I taught high school I found it was important to let my students know that I had a true interest in them and respected them. I made myself available to those who needed counseling, was fair with grading but strict on discipline. It worked pretty well, but it takes time.
The most important thing I learned was that students don't just automatically respect teachers...that respect has to be earned.