Being Portugal a member of the European Union (EU), if you’re an EU-national or a permanent resident with a residence card, it will be a lot easier for you to work as a self-employed person in Portugal.
For non-EU nationals, there’s a process you must follow to obtain a residence permit to be self-employed in Portugal. For more information on visa requests, check this link.
It is very important to do a proper homework when it comes to this topic, such as consulting with a professional.
All self-employed persons must register in the local tax office for income tax, social security and VAT (IVA, in Portuguese), and anyone with income in Portugal requires a tax number (called “número de contribuinte”, in Portuguese), which you can get on your local tax office.
Here you can find an overview of the Portuguese tax system.