Testing habitat-sh/core-plans#1146
(Manual steps are based on https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04)
$ mkdir php-test
$ cd php-test
$ vim index.php
index.php
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
$ php -S localhost:8000
- Push to Github repo
- Create release on Github
- Create cloud VM (port 22 and 80 open)
- SSH into Cloud VM
- git clone github repo
$ git clone https://github.com/nellshamrell/sample-php-habitat.git
$ sudo apt-get update
$ sudo apt-get install nginx
- Head to http://<vm_public_ip>
- And you should see the "Welcome to nginx!" page
$ sudo apt-get install php-fpm
- NOTE - nginx does not run php natively, that is why we need php-fpm
$ sudo vim /etc/nginx/sites-available/default
/etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php$is_args$args;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
- Test config file
$ sudo nginx -t
- Reload nginx
$ sudo service nginx restart
$ sudo cp ~/sample-php-habitat/index.php /var/www/html/
Check out the site in your browser and you should see your hello world
$ hab plan init
$ vim habitat/plan.sh
plan.sh