Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi. After
sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/
Necessary
sudo unlink /etc/nginx/sites-enabled/default
I followed exactly what your tutorials said. But PHP installation was unsuccessful.
Can I expect a solution for this?
Thanks.
I followed these steps and a basic Wordpress install works, but I cannot upload anything larger than 2MB and cannot find the right info to adjust php memory limits. where do I need to make adjustments? Nginx.conf, php.conf, php.ini in various directories or .htaccess. or multiple places? some suggestions online seems to break the website. Considering 36% of websites are wordpress this should be definitely included in this setup or referenced where to make those changes. Thanks in advance
Just to note, Ubuntu 20.04 is now default MySQL 8.0 (not 5.7) and PHP is now default 7.4 (not 7.0 or 7.2). Before in Ubuntu 18.04 you can run `apt install php-fpm7.2’ and append the version, but seems not anymore unless you add some custom PPA to your Ubuntu 20.04 stacks.
@mthimm If you want LEMP stack with WordPress, you can try the FOSS script like SlickStack: https://github.com/littlebizzy/slickstack
…automatic optimize PHP, Nginx, MySQL settings and working great on the DigitalOcean datacenter, very very fast speed.
And remember that LEMP (Nginx) server has no Apache htaccess files which makes Nginx more secure and stable. Cuz many WordPress malware will hack the htaccess to redirect your domain, so Nginx is actually safer and frontend cannot modify it.
I was having trouble on the last step. I was unable to connect to the database using the php script. It was showing the following error:
“Error!: SQLSTATE[HY000] [1045] Access denied for user”
I was able to log-in from the terminal using the same credential and was able to see the records on the table, but the php script was showing the connection error for the same credential, which was weird!
After searching all the posts on stackoverflow, found no solution for this. Finally don’t know why, I ran the php file from the terminal like this instead of the browser:
‘php /var/www/your_domain/todo_list.php’
which was showing me an error on line 3, which was the line with the password. It was telling me something like an empty value and indicating the last 2 characters of the password. I then noticed that in my password, before these last two characters, I have a “$” sign, which is the reserved symbol in php to indicate a variable!
So I changed my mysql user password with the following command:
“ALTER USER ‘userName’@‘localhost’ IDENTIFIED BY ‘New-Password-Here’;”
And updated the php script accordingly. Voila! All worked perfectly afterwards!
Lesson learned: Do not have “$” sign on your password.
Hope it will save others an hour of tension on my same situation!
I have some lines of feedback as well. They concern step4.
Before being able to open a new configuration file in Nginx’s sites-available directory using your preferred command-line editor, you need to create the sites-available folder inside the /etc/nginx/ directory. Without doing so, only the default folder is present and you get the error inside the nano editor that it is not possible to put the script in the folder since it doesn’t exist.
So here’s what you should do to create the folder:
*Next, assign ownership of the directory with the $USER environment variable, which will reference your current system user:
sudo chown -R $USER:$USER /var/www/your_domain
Then create the sites-available folder inside the /etc/nginx/ directory.
sudo mkdir /etc/nginx/sites-available/
Then, open a new configuration file in Nginx’s sites-available directory using your preferred command-line editor. Here, we’ll use nano:
sudo nano /etc/nginx/sites-available/your_domain
Just a note here to the author that in a newer version of this article, it might be wise to advice developers to have their websites properly secured with f.e. Certbot. This is because some browsers give errors at the end of step 4.
Maybe include a link to this tutorial after the installation of Nginx at step 1?
When I tested the PHP with Nginx configuration at step 5, after creating the info.php file I got a 502 Bad Connection error at my website page. After checking the error log with tail -f /var/log/nginx/error.log the terminal returned the following error:
connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)
I solved it with this code:
sudo apt-get install php7.4-fpm
sudo service nginx restart
sudo service php7.4-fpm restart
My sources:
One final comment and then I’ve reached the end of this tutorial succesfully :). After creating the todo list in step 6, I got this php error in my browser:
Error! could not find driver.
I solved it with this code:
apt-get install php-mysql
Source: https://www.codegrepper.com/code-examples/php/php+Error!%3A+could+not+find+driver
I had to go through the steps to install an SSL for this to work with most browsers. Even when specifying the request on HTTP, it did not connect. Other methods like wget, curl and using Postman worked but browsers failed.