Among the buttons in your iPhone's Control Center -- an overlay that appears when you swipe up from the bottom edge -- is one to lock the screen in portrait orientation. Locking the screen in landscape orientation is harder, and requires using one of the iPhone's accessibility features as a workaround.
Portrait Orientation Lock
Swipe upwards from the bottom of the screen to display the control center.
Video of the Day
Tap the Portrait Orientation Lock button.
Tap outside of the control center to hide it.
Landscape Orientation Lock
Locking the screen in landscape orientation requires the screen to be already locked in portrait orientation, and relies on the iPhone's Assistive Touch function. The process works only when the screen can display its contents in landscape orientation -- for example, you can do it within the iPhone's Safari browser, but not on the Home screen. If you switch from an app that supports landscape orientation to one that doesn't, or return to the Home screen, the "lock" is lost and must be reapplied.
Enabling Assistive Touch
Ensure the iPhone's screen is locked in portrait orientation. Open the Settings app and tap General.
Tap AssistiveTouch. You may have to scroll down for this option to be visible.
Tap the AssistiveTouch switch to enable it.
Rotating the Screen
Open the app you want to use and tap the Assistive Touch overlay.
Tap Rotate Screen.
Tap either Left or Right, depending on how you want to hold the iPhone in landscape orientation. If you want the Home button under your right thumb, tap Left; otherwise, tap Right.
Tap anywhere outside the overlay to minimize it and return to the app.