PHPNews

Connecting Containers

We run a Laravel application! docker run --it --rm -v $(pwd):/var/www/html \ -w /var/www/html \ shippingdocker/app:latest \ composer create-project laravel/laravel application This shares our current directory into the /var/www/html directory in the container, and then runs composer create …

Continue reading »

Written by Servers for Hackers - - Aggregated on Sunday November 4, 2018


PHP, FPM, and Nginx

PHP We can see we have php 7.0 available out of the box: sudo apt-cache show php-cli Instead of using that, we'll start by installing the latest PHP 7.1, via the populate PHP repository. # Add repository and update local cache of available packages sudo add-apt-repository -y ppa:ondrej/php sudo apt-get …

Continue reading »

Written by Servers for Hackers - - Aggregated on Sunday October 21, 2018


PHP App Setup & Permissions

Composer First we installed Composer so we can get PHP dependencies: # Become user root sudo su # Pipe the composer installer to php, and pass the installer some flags curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer GitHub Next, we want to get a …

Continue reading »

Written by Servers for Hackers - - Aggregated on Sunday October 21, 2018


SSL Termination

We'll set up SSL-termination on the load balancer. In this setup, the load balancer decrypts the SSL connection and sends an http request on port 80 over the local private network to the application servers. SSL Termination is a common setup, however there are setups that keep the connection encrypted all the way …

Continue reading »

Written by Servers for Hackers - - Aggregated on Tuesday July 31, 2018


The Working Directory

We cover some more about working directories, the exec vs run command, and update our docker-compose.yml file. If our exec command doesn't work with a working directory setting, we can run a command that cd's into a directory and runs the command we want all in one shot: docker exec -it app bash -c "cd …

Continue reading »

Written by Servers for Hackers - - Aggregated on Tuesday June 12, 2018


Variables in Docker Compose

We can use variables in our docker-compose.yml files! The syntax is: ${SOME_VAR_NAME} . These specifically are environment variables. First, let's set our docker-compose.yml file to read two variables: version: '3' services: app: build: context: ./docker/app dockerfile: Dockerfile …

Continue reading »

Written by Servers for Hackers - - Aggregated on Tuesday June 12, 2018


Adding a NodeJS Service

We add a node service that we can use to build our static assets: version: '3' services: app: build: context: ./docker/app dockerfile: Dockerfile image: shippingdocker/app:latest networks: - appnet volumes: - .:/var/www/html ports: - ${APP_PORT}:80 working_dir: …

Continue reading »

Written by Servers for Hackers - - Aggregated on Tuesday June 12, 2018


Dev Workflow Intro

We can build up a nice development workflow using a helper bash script. This makes running command witin our Docker container super easy. Running all of those docker-compose commands are a real pain! We also move our application files up a level so the Docker files are all within the same directory. I …

Continue reading »

Written by Servers for Hackers - - Aggregated on Tuesday June 12, 2018


The Workflow

Here we build up our helper script to accomplish the following: Pass-thru any undefined commands to docker-compose Run docker-compose ps if we don't pass any arguments to the develop script Create a series of commands such as artisan , composer , yarn , and so on, setting the script up to allow us to …

Continue reading »

Written by Servers for Hackers - - Aggregated on Tuesday June 12, 2018


Redirect www to non-www subdomain

Nginx's server_name can handle multiple hostnames. But we often want to redirect "www" to non-"www" subdomains (or visa-versa!). (Don't forget to handle SSL connections to the domain you are redirecting). More info: https://t.co/WaBdUmDVwU pic.twitter.com/WcM2tEDqD7 — Chris Fidao (@fideloper) May 17, 2018 …

Continue reading »

Written by Servers for Hackers - - Aggregated on Thursday May 17, 2018


Using SSL Certificates with HAProxy

Overview If your application makes use of SSL certificates, then some decisions need to be made about how to use them with a load balancer. A simple setup of one server usually sees a client's SSL connection being decrypted by the server receiving the request. Because a load balancer sits between a client and …

Continue reading »

Written by Servers for Hackers - - Aggregated on Monday January 22, 2018


PHP Apps in a Subdirectory in Nginx

In this video, we work through how to put your PHP application in a subdirectory of another site. For example, we may have an application running at example.org but need a second application running at example.org/blog . This feels like it should be simple, but it turns out to be more complex and fraught with …

Continue reading »

Written by Servers for Hackers - - Aggregated on Sunday January 21, 2018