Daanra / laravel-lets-encrypt

Let's Encrypt wrapper for Laravel
MIT License
200 stars 28 forks source link

Pb with jobs #21

Closed alexandre30290 closed 2 years ago

alexandre30290 commented 2 years ago

Hello,

I don't understand how create jobs after successfully generate certificate. For example, I would like to create an apache virtualhost and add a row in database. I found this on website but I don't understand where is this job ?

[$certificate, $pendingDispatch] = \Daanra\LaravelLetsEncrypt\Facades\LetsEncrypt::create('mydomain.com', [ new CreateNewApacheVirtualHost('mydomain.com'), new ReloadApache(), new NotifyUserOfNewCertificate(request()->user()), ]);

Where is job CreateNewApacheVirtualHost ? How create this please ?

Daanra commented 2 years ago

Where is job CreateNewApacheVirtualHost ? How create this please ?

The CreateNewApacheVirtualHost is an example Job that you will have to implement yourself. See also https://github.com/Daanra/laravel-lets-encrypt/issues/7

You could for example create a job that does something along the lines of:

public function handle()
{
        // Configure the apache disk yourself
        Storage::disk('apache')->put($myDomainName.'.conf', $configForVirtualHost);
        $process = new Process(['a2ensite', $myDomainName]);
        if ($process->run() !== 0) {
            throw new \Exception('Failed to run a2ensite for '.$myDomainName);
        }
}
Muffinman commented 2 years ago

Note that this most likely requires PHP command to be executed as root.