If you want to sell one by one course use Moodle and a Paypal plugin + a Pro Theme (all FREE you have to pay for theme)
If you want to have an eshop to sell courses and may be mor you can use
WordPress a good one is LearnDash plugin an econoly is LeranPress (see web)
Joomla an economy one with quickstart to bulid the site fast is SP LMS
Drupal see sites like Themeforest for ready solutions
Otherwise you must write the code. In Udemy there is one in CodeIgniter 3 and more tutorials.
For WordPress there are also FREE solutions see Youtube for free tutorials.