First setup the structure of module by creating folders.

Create configuration file module.xml.

Code:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Cloudways_Mymodule" setup_version="1.0.0"></module>
</config>
Create the file registration.php in the module root directory

Code:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Cloudways_Mymodule',
__DIR__
);
That's it.

Full tutorial: Magento 2 module

View more threads in the same category: