Follow this tutorial
http://unixetc.co.uk/2016/11/20/simple-nextcloud-installation-on-raspberry-pi/
Also, I commented on another post before this which tells you exactly all you need that is not mentioned everywhere else. I suggest you look back
Link to the other post: