Building a LNMP (LAMP) Stack!
Time To do: 30/1hr mins
Instead of a lamp stack it’ll be a LNMP stack (replacing Apache with Nginx, and mysql with mariaDb)
Run sudo apt-get install nginx
Go to the IP Address of your raspberry Pi (on your browser) and you should see a welcome to nginx page!
Step 2: Install PHP
sudo apt-get install php-fpm php-mysql
You can check if PHP is installed by running php -v
Once you’ve done that you should then do this:
Go to sudo nano /etc/nginx/sites-available/default
And then change your config file to look like this:
Once changed, exit out of nano (ctrl-x and then y for yes to saving the changes)
Then run nginx -t
Once ran you should see a message saying that the configuration test is successful
After that run sudo service nginx reload
Go to where you created the PHP file and see if it loads!
That should be PHP setup!
To test your php is working you can write this
and then when you go to view it on your raspberry Pi web server you should have information appearing like so:
This means you’ve setup PHP correctly!
Now to setup MySQL (Last part of the LANP stack!)
sudo apt-get install mariadb-server-10.0
This installs mariadb
sudo mysql_secure_installation
Press continue
then y and type your password
press y three times
and then y to reload prviilleges
This setups a password for the root user so we can use mariadb
To login run sudo mysql
Then you should be in your MariaDB client, to check a database exists run show databases;
ctrl + c
to break out of mariaDB client and back into your terminal
Adding to the LAMP Stack (making websites, what we’re here for!)
(explain how they can with filezilla and use that as a way to transfer files across).
And you should now have your LMNP stack working, here’s a short breakdown of what you can do with it! Enjoy!