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
Laravel

Homestead PostgreSQL

PostgreSQL is running in Homestead by default, but you cannot access it from the host machine (though the docs do mention the 54320 forwarded port?)

Instead SSH into the Vagrant box and run migrations locally.

Putty on Windows. I had to convert the default private_key file to ppk. Use PuttyGen to generate a private key, use it as Auth option from putty and vagrant username.

Categories
Uncategorized

Unable to Start Apache on Windows

If you get service specific error code 1 this relates to an IP/port conflict.

In my case Apache was listening to an IP address no longer attached to the system.

In httpd.conf there was Listen 192.168.0.20:80, which was an out of date IP. This line is usually unnecessary, but for me to get Apache to respond to the computer name I needed it.

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
Laravel

Render Laravel view in Controller

You may want to grab the output of a Laravel view; for example to store in cache. You can do so with the render method;

[code]
$result = View::make( ‘index’, $data );
Cache::put(‘mykey’, $result->render(), 10);
[/code]

 

Categories
Laravel

Redis Alias Unavailable in Laravel

Short Answer, even with Redis installed the ‘Redis’ Facade alias can conflict.

Try renaming the alias in app/config/app.php and reloading the autoloader.

Via StackOverflow.

Categories
Laravel PHP

Mandrill mail from Laravel

The Laravel docs mention adding guzzlehttp/guzzle ~4.0 to composer.json for use with Mandrill’s API.

At the time of writing GuzzleHTTP 5.2 was current. Unclear why 5.2 is not suitable, but it gave the SSL Error 60  locally.

[code]
"require": {
"laravel/framework": "4.2.*",
"guzzlehttp/guzzle": "~4.0"
}[/code]

Seemed to fix it on Windows 8. PHP 5.6

Categories
Laravel

Laravel Mail Callback Scope

Sending email with Laravel uses a callback closure to set the recipient, subject & other headers. You may need that callback to access variables from the scope of the calling code.
Like this:

[code language=”php”]
$to = ‘CaptainMorgan@example.com’;

Mail::send(‘myEmailView’, [‘data’=>value], function($message) use ($to) {
$message->to($to)->subject(‘Hey, do stuff’);
});
[/code]

Ensure a space after use statement.
Via StackOverflow.

Categories
Uncategorized

Learn Frontend

  • CSS3 — what’s new
  • HTML5 — ditto
  • Macaw
  • SVG — animation, sprites
  • JavaScript
    • Ember, Angular
  • BrowserSync
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.