Introduction
If there's enough roof space and sun, solar can be installed on any roof. Installation cost and complexity vary with the roof's design and composition. According to a study conducted by the National Renewable Energy Laboratory (NREL), the average cost of building a home rooftop solar array is $19,000, and the bulk of construction cost goes into the installation of solar panels on the roofs
1-Slate Tile, 2- Asphalt Shingles, 3 - Spanish Tile, 4 - Tile, 5 - Membrane Tile
Types of Roofs
Asphalt Shingles
Most roofs use composition shingles and solar panels attached to rails affixed to the roof through bolting mounts into the roof rafters. Thankfully, asphalt shingle sometimes referred to as mere shingles, is the most common roofing material and is the most accessible type for solar installers.
Flat Roof
Flat roofs are also easy for solar panel installation. However, there are additional costs for mounting and racking equipment so that the panels can be angled towards the sun.
Tile Roof
Tile roofs and shake shingle roofs cost more. Tile and shake roofs cost more for solar because there's no way to walk on them without causing some minor damage, such as breaking a clay tile. The shingles are fragile and difficult to walk on, and drilling into them for mounting the racking is delicate work and time-consuming. Installers will make it right, but it can raise installation costs.
Roof Shape
Aside from material, shape also matters. Common home roof types include gable roofs, cross-gabled roofs, hipped roofs, and cross-hipped roofs. These have moderate pitches and can be ideal for solar installations, provided that they have sufficiently large south-facing surfaces. These roof types are also amenable to installations where photovoltaic shingles are desired rather than separate panels.

2-Roof Shapes
Flat roofs are typically covered with either tar and gravel or polyurethane foam. On flat roofs, you may need a few more racks to position the panels at the correct angle. However, very steep roofs and tall homes (more than two floors) may take more time to install and require special cranes or equipment.
Attachment
In general, composite shingle roofs are attached through bolting mounts into the strongest roof rafters and then attaching rails to those mounts. The metal frames for most modules are made of anodized aluminum of varying heights and gauges.

3 - Solar Roofing Attachments
Most racking systems can accommodate hundreds of different makes and models of modules, with only a change of clip height, color, or style. Racking generally accounts for 5% to 10% of an installed system's materials cost and between 20% and 40% of labor cost.
Installers also add sealants into and around the mounts that fill in any gaps. Often the mounts are surrounded by metal or rubber flashing – coverings that serve as an extra rainproof barrier.
The International Building Code requires flashing every roof penetration, shifting away from relying solely on sealants like the old L-feet method. Parallel rails are then attached to the mounts, and the solar panels are attached to the rails.
Live in a townhouse or have some other flat roof? The racks that hold the panels generally don't require drilling into the roof structure. Often some ballast such as concrete blocks is used to keep the racking stable.
Considerations for You, the Homeowner
Before installing anything on your roof, it's best to call a roof inspector to inspect for any preexisting damage. Go through your roof warranty and find out how many years you've got left on your roof's warranty.
Before installing panels, you want a roof in good condition, so if you notice any mold, rot, or leak beforehand, you need to get it fixed.
In any case, if you want to install solar panels and do not want to wait any longer, it's best to replace the roof if it has less than five years of life. And solar panel system simultaneously.
Summary
Finally, suppose you're serious about installing solar and have considered proceeding with solar; in that case, homeowners should check if their roof is suitable for solar panels and any obstacles to putting solar panels on their roofs. It's imperative that homeowners understand what kind of roofs they have and if it will increase the cost of going solar and which may affect the ROI.