How to modify search.php to not show pages only show posts

The search template is way too late to change anything: The pages are searched already here, and your page numbers would be wrong. Do not alter the output, alter the query.

Filter posts_search instead, and if there is a search term, filter posts_where_paged and remove the post type you don’t want to be searched.

Sample code:

is_admin() || add_filter( 'posts_search', function( $search )
{
    empty ( $search ) || add_filter( 'posts_where_paged', function( $where ) {
        return preg_replace(
            '~post_type IN \((.*)\'page\',?~',
            'post_type IN (\1',
            $where
        );
    });

    return $search;
});