A deep learning (DL) architecture is proposed in this study for the multi-class classification of COVID-19, lung opacity, lung cancer, tuberculosis (TB), and pneumonia. There are two distinct models, namely Classification_1 and Classification_2 in this research. Classification_1 detects the lung diseases and Classification_2 classifies the different lung diseases. The hyperparameters and architecture of the DL models are tuned by grid search optimization (GSO) to get accurate results. To meet the DL criteria, the enormous number of CXR images of COVID-19, lung opacity, pneumonia, lung cancer, TB, and normal images of 3615, 6012, 5856, 20,000, 1400, and 100,192, respectively, were reduced, normalized, and randomly divided. According to the experimental findings, our proposed model beat previous research with 99.82% accuracy in Classifcation_1 and 98.75% accuracy in Classification_2. The suggested paradigm offered greater performance, enabling medical professionals to identify and treat patients more rapidly and effectively.