To write a book is a long process - think of a story and write it down. Well. To get it published, send it in manuscript form (gaps between each line) to a literary agent - they will do the work of getting it published, if it's good enough. If it's not they will send it back and let you try again. Have fun.
That's two separate and difficulty processes! Writing the book will take a lot of self-discipline, time and effort. Publishing will take.. a lot of self-discipline, time and effort! The best of both worlds is if you can convince an agent/publisher that your book should be published long before you finish it. That will ensure they help you to finish it - with encouragement, advice and hopefully money.