Stedding is a minimalistic LEMP Stack setup for Laravel in progress. It facilitates the setting up of Laravel apps on a well prepared server using Ansible Playbooks. It provisions your VPS with all the tools necessary to run your Laravel PHP application with ease.
Again, this is still a work in progress. So use it wisely and backup when possible. Better still to test on a barebone server and send in pull requests :)
- Digital Ocean Sudo User Setup
- Digital Ocean Basic PHP App Setup
- Pogorelov-SS' Github Private Repo Clone Gist
You need to have Ansible installed on your local computer. This really differs from box to box See Ansible Documents for instructions.
To run Ansible Playbooks properly on Ubuntu 16.0.4 we need to setup a sudo user and make sure Python and some other packages are available so Ansible can run. The setting up of a sudo user and adding of the SSH keys for it can be done following the instructions below. In the future we will integrate this in a shell script.
Log into your remote server as root using
ssh root@ip
Then add a new sudo user:
adduser laravel
gpasswd -a laravel sudo
Then add your own public key to the authorized keys for your user laravel:
su laravel
cd
mkdir .ssh
chmod 700 .ssh
nano .ssh/authorized_keys
add key from local box cat ~/.ssh/id_rsa.pub and exit twice to log off the box
chmod 600 .ssh/authorized_keys
exit
exit
Now on your local box do the following:
ssh laravel@ip
Then on the remote do:
sudo su
nano /etc/ssh/sshd_config
Make sure you set root access to no to secure the box
PermitRootLogin no
Then you need to restart the SSH server:
service ssh restart
And log off as root and exit box as laravel:
exit
exit
We expect you to have installed Ansible on your own control box already. If not check out Ansible for instructions.
The Ansible config file is in the repository already. It checks for a hosts file the root of the project. It is put on .gitignore as we do not want to share host details. So you need to add it. So create and open hosts file with nano using:
nano hosts
add php details using your non sudo user, laravel here, and the ip address to your server
[server]
xxx.xxx.xx.xxx ansible_ssh_user=laravel
Then make sure SSH agent forwarding is working to forward the SSH key to access the repository. Add the following to ~/.ssh/config
:
Host *
ForwardAgent yes
I am using * as the Host as called "Laravel" + ip address did not work. May be a configuration issue on my part that can be changed later on. Also, to make sure the ssh agent is running and your ssh key is included you can run:
eval `ssh-agent -s`
ssh-add
To do a test from your local computer - a MacBook Pro for example - you should run the following command:
ansible server -m ping
And when all is well you should get this response:
xxx.xxx.xx.xxx | SUCCESS => {
"changed": false,
"ping": "pong"
}
Then to run the script use the following:
ansible-playbook server.yml --ask-sudo-pass
The current yaml playbook will install the following packages:
- git
- mcrypt
- nginx
- php7.1-cli
- php7.1-common
- php7.1-curl
- php7.1-dev
- php7.1-fpm
- php7.1-gd
- php7.1-intl
- php7.1-json
- php7.1-mbstring
- php7.1-mcrypt
- php7.1-mysql
- php7.1-opcache
- php7.1-xml
- php7.1-xmlrpc
- php7.1-zip
- mariadb-server
- mariadb-client
It will also add a github repository of choice to a location of choice.