Install and setup a Lemp Stack in Debian/Ubuntu server
**LEMP** software stack is a group of software that can be use to sever dynamic web pages and web applications written in *php*. This stack includes:
- [nginx]
- [mysql]
- [php]
* [nginx and php]
- [phpmyadmin (optional)
* [nginx and PhpMyAdmin]
All this is for **ubuntu server 20.04** it should work in **debian 10** but phpmyadmin needs to be install from source
Install web server NGINX
Install nginx
When the istallation is done, check in your web browser
It will show something like "Welcome to nginx!"
Check [here](https://darknesscode.xyz/notes/nginx-setup) to setup nginx. Nginx is setup only to work with html in it base configuration you need to create a new server block to work with php.
Install MySQL (database)
Install mysql
When the installation is done, run a security script that comes pre-installed with MySQL
Follow the instructions to setup the root password and other security checks for MySQL. Then run
To check that everything works fine. If you have problems with your passwork check [here](https://darknesscode.xyz/notes/reset-mysql-root-password/) to reset the root password for MySQL.
Install PHP
Install PHP to process code and generate dynamic content for the web server
Now that everything is install, let's jump to the fun part
Setting Nginx to Use the PHP Processor
Create a new server block to work with php, this is a new server that will point to a new website out of the html/ directory
First create a new directory (replace mydomain.xyz for your domain)
Create a new nginx block in sites-avaible
Copy and paste this block, and make all the changes you need
When you done, save it and close it. Then enable your new domain
Now reload nginx
And if you like you can re-start nginx as well
Before your test your new server, create a php file in your root directory
Now test your new php web site, it will show all the informations for php.
Install PhpMyAdmin (Optional)
I like to use phpmyadmin to manage my databases, it's simple. To install if run
In the installation process phpmyadmin will ask some question to setup the config of ti. Answer to the questions
- Configure database for phpmyadmin with dbconfig-common?
* **Answer YES**
- MySQL application passwork for phpmyadmin
* **write it down the password you setup in MySQL**
- Web server to configure automatically
* **Don't select nothing in here, just press ok**
Setting Nginx and PhpMyAdmin
In here we need to create a new nginx server block with another domain or alias, in this case i will use and alias phpadmin.mydomain.xyz
Create a new file in
Copy and past this block, and make all the changes you need
Save it and close the new file. phpMyAdmin files are storage in **/usr/shara/phpmyadmin** direcotry
Test nginx configurations
If any errors aren't show realod nginx
Now go and test the domain you setup, in this case has phpadmin.mydmoain.xyz if everything whent well you will see phpmyadmin login.
Try out the script to automate all the process
----------
----------
© DarknessCode