A lot of people regard the stock market as a scary, unpredictable thing, but actually, stocks have a long history of delivering solid returns. As such, investing in stocks is a good way to turn yourself into a millionaire, even if you earn a modest living. And if you follow these steps, you'll be even more likely to make millions over time.

1. Start early

Time is the strongest weapon in your arsenal when it comes to building wealth. The sooner you start investing, the more opportunity you'll give your money to grow. In fact, it pays to start investing from the moment you start collecting a steady paycheck -- even if that means funding a retirement plan or brokerage account with as little as $50 a month and then working your way up over time.

Imagine you begin investing $400 a month at the age of 25. The S&P 500 index has, over the past 30 years, delivered an average annual return of around 12%, but let's be a bit more conservative and assume you'll enjoy a 9% average annual return on your money. If that's the case, then if you keep your money in the stock market for 40 years, by the time you turn 65, you'll have a cool $1.6 million to your name. Make it $500 a month, and you'll be looking at just over $2 million, all other things being equal.

Smiling man raising arms while bills float around him

Image source: Getty Images.

2. Diversify

A diverse portfolio could be your ticket to not only growing wealth over time, but also, protecting yourself in the face of stock market crashes. Now you can diversify in a few different way. You could simply buy a bunch of individual stocks from different segments of the market (for example, some tech stocks, some bank stocks, some energy stocks, and some healthcare stocks), or you could load up on index funds.

Index funds are passively managed funds that track different indexes. An S&P 500 index fund, for example, will aim to match the performance of that index, and since, as we discussed earlier, the S&P 500 has done very well over the past three decades, it's a solid bet for growing wealth. Plus, index funds take a lot of the legwork out of investing. Rather than sink time into researching individual companies, you could instead just buy shares of an index fund and get instant diversification.

3. Be consistent

Some investors try to time the market -- and fail miserably in the process. A better system is to invest in stocks consistently, which means putting money into the market when stocks are up and also during periods of volatility.

In fact, a good strategy to employ in this regard is dollar-cost averaging, where you commit to investing a certain amount of money at predetermined intervals (for example, $500 a month) no matter what the stock market looks like at the time. In doing so, you're likely to end up paying a lower average share price than you would trying to time the market. You're also less likely to miss out on lucrative opportunities that enable you to grow wealth.

Making millions in the stock market may seem like a lofty goal -- but with the right approach, it's actually more doable than you might think. If you start investing at a young age, diversify your holdings, and remain consistent, you may be pleasantly surprised at how wealthy you ultimately wind up.