When I setup a development system there are a few steps I follow to get everything working together.
The aim is to get everything installed to provide php and composer, node, nginx, mysql and Laravel as a base to build on.
I take the latest amd64 version using a network installable iso. This way if I use an older 9.1, 9.2, 9.3 version iso, being a netinst version I’ll end up with the latest in that series as it downloads from the net.
Mostly making a 50GB disk is more than enough, as it’s thin provisioned on a virtual, space isn’t really a concern. When it comes to partitioning I’ve learned to take the easy option and create one partition to mount all filesystems into it.
As it’s a development platform I never install a desktop environment. I never need to use any GUI programs on the server. The only options I choose to install are the standard system utilities and the ssh server.
Out of personal preference, once up and running I install sudo, zsh, curl and git.
# apt-get install sudo zsh curl git
Then I add my non-root user to the sudo group so I can stop using root and use my regular user account to ssh onto the dev server..
# usermod -aG sudo [user]
I like using zsh and the OhMyZsh which is why I installed curl and git. So logon as your non-root user.
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Then I edit the
~/.zshrc file and change the theme to “bureau”.
Because we don’t want Apache2 installed you need to install
php-fpm which won’t force an install of Apache.
$ sudo apt-get install php-fpm
It will include a load of other php components you need, but no Apache, so you can then choose to move on to Nginx or some other php service.
Add the Laravel php requirements
$ sudo apt-get install php-mbstring php-zip php-xml libpng-dev make gcc g++
The additional module
libpng-dev is required for Laravel to build using NodeJS npm. Without
g++, under your Laravel project folder the call to
$ npm i fails with errors like:
> email@example.com postinstall /home/user/myproject/node_modules/pngquant-bin > node lib/install.js ⚠ The `/home/user/myproject/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly ⚠ pngquant pre-build test failed ℹ compiling from source ✔ pngquant pre-build test passed successfully ✖ Error: pngquant failed to build, make sure that libpng-dev is installed at Promise.all.then.arr (/home/user/myproject/node_modules/pngquant-bin/node_modules/bin-build/node_modules/execa/index.js:231:11) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)
As you’ll need a database you’ll want to install MySQL. These days MySQL is installed from the MySQL site by downloading a
.deb file which add the Oracle repositories. The version of MySQL in the Debian repositories is MariaDB, a fork of MySQL.
If you go for the Oracle version you’ll probably need to ensure you use legacy authentication for now.
Include the php drivers as we install the server:
$ sudo apt-get install mysql-server php-mysql
To manage MariaDB using
mysql you need to use sudo:
$ sudo mysql -u root ... MariaDB [(none)]>
Go to your home folder and use the command line install from here: https://getcomposer.org/download/
You’ll end up with a file
composer.phar. This is ok if you’re the only one going to use it but I like to put it in
/usr/bin as just
composer so it is available for everyone.
$ sudo cp ~/composer.phar /usr/bin/composer $ sudo chmod 755 /usr/bin/composer
Install it using a package manager following the steps for Debian
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - $ sudo apt-get install -y nodejs
Then the first thing I do is update npm.
$ sudo npm i npm -g
Because not all development takes place on a Linux host this will allow us access to shares for Windows clients.
$ sudo install samba
/etc/samba/smb.conf and make some simple changes.
workgroup=[NETBIOS DOMAIN NAME]
[homes] and in that section change:
read only = no create mask = 640 directory mask = 750
Create a password entry for your non-root user:
$ sudo smbpasswd -a [user]
Then restart Samba
$ sudo systemctl restart smbd
Then when you browse to the server from windows you should see and have access to your home folder eg.
I prefer to install Laravel as a project using the Create Project method:
$ composer create-project --prefer-dist laravel/laravel [myproject]
This downloads all of the PHP composer prerequisites and delivers the project.
Once the project is created you can go into the folder [myproject] and check you can compile the assets using Node.
$ cd myproject $ npm i
This will install all of the NodeJS prerequisites used for building/compiling your assets using the Laravel asset management tools – currently Laravel Mix (Based on Webpack). So with the Node modules installed you should be able to run prod and dev builds:
$ npm run dev $ npm run prod
These should complete successfully.
You can then run Laravel’s built in development server to serve your project:
$ php artisan serve
But in reality this will fire up a pretty useless server listening on the IP address 127.0.0.1 on port 8000. So it’s only accessible from the development server.
As we’re going to need to access it from our client development machine we need to serve on the actual IP of the server. The easiest way of doing this is to serve it on every IPv4 interface on the server (you probably only have one, so it shouldn’t matter). To do this use:
$ php artisan serve --host=0.0.0.0
and if you want to specify the port you can use:
$ php artisan serve --host=0.0.0.0 --port=8001
Now you can access it from any client pointing your browser at
http://192.168.0.200:8001 and begin exploring your Laravel project.
Of course serving a version of your project like this isn’t the only way to go. You should continue into dynamically building your assets using
npm run watch and maybe even using tools like
browserify to make changes happen at the browser end so you’re not building and refreshing all the time.
I also like to move away from a development web server and setup Nginx to handle serving my Laravel Project.