Categories
PHP Servers

Restart PHP7.3 FPM

Restarting PHP FPM on Ubuntu 16.04

Probably
service php7.3-fpm restart

Maybe
systemctl restart php-fpm.service

Homebrew Locally

sudo brew services restart php74

Categories
Servers

MariaDB Password Change Not Working

New Ubuntu 16 server with MariaDB.

Tried using

“`SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘myGreatPassword’);

Password is changed but could not connect to DB from PHP.

Needed to update mysql.user table and set the Plugin field to an empty value (rather than unix_socket)!

Categories
Servers

LetsEncrypt SSL Failures

SSLs are failing to renew

  • MySquash / UltraVulture due for renewal in <1 month
  • Failing because Nginx is not allowing access to .well-known dir
  • Need to debug syntax and rerun certbot-auto renew

Maybe related to SSL redirection. I think LetsEncrypts requests that file over http

Could HSTS interfere?


Update: One domain was failing due to out of date LetsEncrypt config (pointing to an old install folder).

Got it going by disabling force HTTPS redirect, creating .well-known/acme-challenge and rerunning.

Should be able to delete .well-known and leave it to LetsEncrypt to create those.


Update2:

/etc/letsencrypt/renewal/www.mysquash.pro.conf referred to old install directory (I bump directory when upgrading Laravel).

So .well-known would have been created in wrong path. Pointed to mysquash54, but cannot test yet as now there have been too many recent fails of the domain 🙁

I may have passed through the correct nginx config along the way and not known it.

Categories
Servers

Add Lets Encrypt Domain

cd /opt/certbot

./certbot-auto certonly --webroot -w /var/www/html \
-d tutorial.serverops.io \
--non-interactive --agree-tos --email me@example.com
Categories
Servers

Uploading to AWS S3

101 Demo

[code]
<?php
// Instantiate an Amazon S3 client.
$s3 = new S3Client([
‘version’ => ‘latest’,
‘region’ => ‘ap-southeast-2’,  //Sydney
‘scheme’ => ‘http’, //omit, or https on servers that support it
‘credentials’ => [
‘key’ => ‘ YOUR KEY ‘,
‘secret’ => ‘ YOUR SECRET ‘
]
]);

// Upload a publicly accessible file. The file size and type are determined by the SDK.
try {
$s3->putObject([
‘Bucket’ => ‘yourbucket’,
‘Key’ => ‘path/to/key.png’,
‘Body’ => fopen(‘my-picture.png’, ‘r’),
‘ACL’ => ‘public-read’,
]);

echo "<p>Picture uploaded [tick]</p>";

} catch (Aws\Exception\S3Exception $e) {
echo "There was an error uploading the file.\n";
}
?>

[/code]

Categories
Servers

Ubuntu Memory Usage

[code]
ps aux –sort -rss | head -n10
[/code]

Categories
Servers

Installing SSL on Apache

Generate CSR on your server.  Paste the contents of .csr into Namecheap’s interface.

(The .key file is referenced by Apache later along with the certificate)

[code]
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr[/code]

(use www.mikehealy.com.au as my FQDN)

Create crazy long CNAME in DNS to verify. Seems to replace email validation.

Overwrite certificate files in /root on server with new ones from Comodo. Restart Apache, config can stay the same.

Categories
Servers

PHP Cron Jobs on Ubuntu 14.04

I have PHP scripts to backup MySQL databases and FTP them to another server.

Edit the crontab file and add your tasks

[code]
crontab -e

5 12 * * * php /var/www/mysite/tools/autobackup/run_this_file.php
[/code]

The paths in the PHP script were relative to the user. Needed to add this at the top of PHP scripts to be relative to the script

[code]
chdir(__DIR__);
[/code]

Categories
Servers Workflow

Manually Backup Site & MySQL from Command Line

(e.g. WordPress site)

Tar Gz Directory

  • Go to /var/www
  • tar -zcf ../mysite_today.tar.gz public_html
    • (-z compress; c create file; f archive file name)
    • contains public_html in archive.
  • Download with WinSCP

MySQL

mysqldump -u username -p dbname | gzip > myexport.sql.gz

Type your password. Done.