The generalized van der Waals equation of state for anisotropic liquids in porous media consists of two terms. One of them is based on the equation of state for hard spherocylinders in random porous media obtained from the scaled particle theory. The second term is expressed in terms of the mean value of attractive intermolecular interactions. The obtained equation is used for the investigation of the gas-liquid-nematic phase behavior of a molecular system depending on the anisotropy of molecule shapes, anisotropy of attractive intermolecular interactions, and porosity of a porous medium. It is shown that the anisotropic phase is formed by the anisotropy of attractive intermolecular interactions and by the anisotropy of molecular shapes. The anisotropy of molecular shapes shifts the phase diagram to lower densities and higher temperatures. The anisotropy of attractive interactions widens significantly the coexistence region between the isotropic and anisotropic phases and shifts it to the region of lower densities and higher temperatures. It is shown that, for sufficiently long spherocylinders, the liquid-gas transition is localized completely within the nematic region. For all the considered cases, the decrease of the porosity shifts the phase diagram to the region of lower densities and lower temperatures. K e y w o r d s: fluids in random porous media, gas-liquid-nematic phase transitions, van der Waals equation, scaled particle theory, hard spherocylinders.