Basically you have to do the following steps:
First you have to be able to access your Pi from any network.
To do this, go to any Dynamic DNS Host and register. Services like DynDNS or no-ip provide an internet address for your home router.
Than go to your Routers IP-Adress and see if there is already a build in functionallity for Dynamic DNS. You need to configure this, so you router sends his external IP-Adress to you DynDNS Host. This will make your router accessible. If not, than use software on the pi to send the IP-Adress.
Either set your Pi to an static IP or tell the router in his settings to give the pi an static IP and then forward Ports 80 and 443 to this IP-Adress. With this step you tell the router to forward every incomming traffic on the two ports to the raspberry pi.
Set up an webserver like apache on your Pi in order to provide a webserver funtionality.
There are definitely many ways to access the GPIO pins from a website, one way is:
Write a php script for your website. This is the page you will see when you access your pi.
Within it should be buttons and stuff so you can control something end send it via POST method to the script.
Extract the message and call a python script which will do the actual change on the GPIO.
$command = escapeshellcmd(sudo python /home/pi/path/to/script.py led 1);
exec("$command > /dev/null &");
The first line would call the python script located in /home/pi/path/to/ and execute it. The
> /dev/null will tell it to put all output into an non-existing file and the
& will run it in the background. The last 2 are not really necessary but without it your website will load as long as it takes to execute the python script.
At the moment php could not start python because of the sudo command. It is nessesary because we need the privileges to work with the GPIO Pins.
So we need to do:
sudo nano /etc/sudoers and at the end add
www-data ALL=(ALL) NOPASSWD: ALL
The last step is to write your Python script and work with the input variables you put in via php. I assume you already now how to do that based on your question.