The Blog

Ubuntu 22.04 LTS + Plesk 18 + PHP 8.1 + Symfony 6.1 and so on

Posted on

First issue after installing all of that was symfony-cli could not find Plesk’s PHP, this fixed it.

sudo ln -s /opt/plesk/php/8.0/bin/php /usr/local/bin/php

Next issue was “KnpMenuBundle” in 6.1 it needs to be used as a service, see here. Also if you want custom template the path needs to be set this way; if your template is in “templates/Menu/knp_menu.html.twig”

#config/packages/knp_menu.yaml

knp_menu:
    # use 'twig: false' to disable the Twig extension and the TwigRenderer
    twig:
        template: Menu/knp_menu.html.twig
    #  if true, enables the helper for PHP templates
    templating: false
    # the renderer to use, list is also available by default
    default_renderer: twig

Another issue was, how to use raw SQL in symfony 6, very simple thanks to auto-wiring.

https://symfonycasts.com/screencast/doctrine-queries/raw-sql-queries


Posted in Symfony 6, Uncategorized Leave a comment

Symfony 3 adding “swiftmailer-mailgun-bundle” on PLESK

Posted on

Just 4 bundles to make this work

/opt/plesk/php/7.3/bin/php -d memory_limit=-1 /usr/lib/plesk-9.0/composer.phar require nyholm/psr7
/opt/plesk/php/7.3/bin/php -d memory_limit=-1 /usr/lib/plesk-9.0/composer.phar require kriswallsmith/buzz
/opt/plesk/php/7.3/bin/php -d memory_limit=-1 /usr/lib/plesk-9.0/composer.phar require cspoo/swiftmailer-mailgun-bundle
/opt/plesk/php/7.3/bin/php -d memory_limit=-1 /usr/lib/plesk-9.0/composer.phar require mailgun/mailgun-php

Configuration

Symfony 3.4

Also add to your AppKernel:

new cspoo\Swiftmailer\MailgunBundle\cspooSwiftmailerMailgunBundle(),

Configure your application with the credentials you find on the domain overview on the Mailgun.com dashboard.

// app/config/config.yml:
cspoo_swiftmailer_mailgun:
    key: "key-xxxxxxxxxx"
    domain: "mydomain.com"
    endpoint: "https://api.eu.mailgun.net" # Optional. Use this config for EU region. Defaults to "https://api.mailgun.net"
    http_client: "httplug.client" # Optional. Defaults to null and uses discovery to find client. 

# Swiftmailer Configuration
swiftmailer:
    transport: "mailgun"
    spool:     { type: memory } # This will start sending emails on kernel.terminate event

Note that the swiftmailer configuration is the same as the standard one – you just change the mailer_transport parameter.

Posted in Symfony3 Leave a comment

GCP How to assign a static IP address to a new VM instance

Posted on

When you create a VM instance, it is automatically assigned an ephemeral external IP address. If you don’t want an ephemeral external IP address, you can explicitly assign a static external IP address to the instance instead.

  1. In the GCP Console, go to the VM Instances page.

  2. Click Create instance.

  3. On the Create a new instance page, fill in the properties for your instance.

  4. Expand the Management, security, disks, networking, sole tenancy section.

  5. Click Networking.

  6. Under Network interfaces, click on the default network interface to edit it.

  7. Under the External IP section, select the static external IP address that you reserved from the drop-down menu.

  8. Click Done to finish modifying the default network interface.

  9. Click Create to create the instance.

Posted in Google Cloud Platform Leave a comment

XenServer 7.3 Restore VM with CLI

Posted on

Import/Restore a Xen VM from a backed-up image file, likely a backup taken of a VM prior to the destruction of said VM for any reason.

  1. Ensure you have mounted the location with the .xva file. For instance, if it is a remote NFS store, you may want to check the current mount points, or execute:

    mount -t nfs 10.1.1.250:/mnt/backups/xenbackups /mnt/backup
    
  2. Take note of the filename & path that you will use for restoration/import, such as:

    /mnt/backup/Test-VM-2016-02-17_12-23-01.xva
    
  3. If you don’t have shared storage in your Xen Pool, or if you wish to place the VM on a specific server or Storage Repository (SR), execute the command:

    xe sr-list
    

    which will produce output such as this:

                uuid ( RO): 73a394e5-2a60-a13d-9c42-4987d81c1a77
          name-label ( RW): DVD drives
    name-description ( RW): Physical DVD drives
                host ( RO): XEN-SRV-4
                type ( RO): udev
        content-type ( RO): iso
    
                uuid ( RO): 3b3346b2-d08a-90a8-bc13-321e0fe988d9
          name-label ( RW): Removable storage
    name-description ( RW): 
                host ( RO): XEN-SRV-4
                type ( RO): udev
        content-type ( RO): disk
    
                uuid ( RO): 69659292-ca18-3875-8c3b-1c9873db1dc0
          name-label ( RW): Local storage
    name-description ( RW): 
                host ( RO): XEN-SRV-4
                type ( RO): lvm
        content-type ( RO): user
    

    Take note of the uuid of the “Local Storage” of the host on which you wish to place the VM. In this case, if we want to place the VM on “XEN-SRV-4,” then we will need the uuid “69659292-ca18-3875-8c3b-1c9873db1dc0

  4. Using the uuid & filename from above, you can then execute the vm-import command thus, preferably on the physical host where you are importing the VM, to minimize network traffic and potential slowdowns caused by passing packets from one server to another unnecessarily:

    xe vm-import filename=/mnt/backup/Test-VM-2016-02-17_12-23-01.xva sr-uuid=69659292-ca18-3875-8c3b-1c9873db1dc0
    

    If you want or need to retain the VIF MAC addresses (such as for a VM that gets its IP Address via DHCP), ensure that you specify the preserve=true option such as:

    xe vm-import filename=/mnt/backup/Test-VM-2016-02-17_12-23-01.xva sr-uuid=69659292-ca18-3875-8c3b-1c9873db1dc0 preserve=true
    
  5. If you wish to have the VM start automatically when the Hypervisor/Host boots, ensure you re-enable the autostart option, as it does not get restored when importing a VM from a file. For that, you’ll need the uuid of the VM (xe vm-list can help you there) and then you need to execute:

    xe vm-param-set uuid= other-config:auto_poweron=true
    
Posted in XenServer Leave a comment
Next Page »