sudo apt-get update && sudo apt-get install imagemagick gs
mkdir -p pdf_conversion/{merged,split}
cd pdf_conversion
curl -o LargeSample.pdf "http://cl.ly/0o1T453E153m/download/LargeSample.pdf"
convert LargeSample.pdf split/page-%0d.jpg
convert split/*.jpg merged/full.pdf
convert LargeSample.pdf split/page-%0d.jpg
rm split/page-2.jpg
convert split/*.jpg merged/full.pdf
With PHP: You can use PHP exec function to run these commands, ie:
<?php
exec('convert LargeSample.pdf split/page-%0d.jpg');
http://linuxcommando.blogspot.com/2015/03/how-to-merge-or-split-pdf-files-using.html http://linuxcommando.blogspot.com/2013/02/splitting-up-is-easy-for-pdf-file.html http://stackoverflow.com/questions/17025515/converting-a-multi-page-pdf-to-multiple-pages-using-a-single-command http://codetheory.in/convert-split-pdf-files-into-images-with-imagemagick-and-ghostscript/
This method to remove pages from a PDF isn't exactly ideal since text loses significant clarify due to that it all becomes one big image instead of separately rendered elements. It's probably useful in some cases, but if you need clear text this won't cut it.