I’m trying to install Wordpress on a LEMP Stack on CentOS 8, but I don’t know what I’m doing wrong because it only shows the default page of NGINX
Code on /etc/nginx/conf.d/wordpress.conf
upstream php {
server unix:/tmp/php-cgi.socket;
server 127.0.0.1:9000;
}
server {
server_name sitename;
root /var/www/html/public_html/;
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
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 @kvny,
At first glance, I can see a couple of errors. It’s okay, we’ll go through them together.
The first one is changing the name of your config, not that it’s wrong but it’s taken as a standard. So what you need to change is the name first. changing it from
/etc/nginx/conf.d/wordpress.conf
to
/etc/nginx/sites-available/example.com
Notice the folder as well, it’s not in conf.d but in the sites-available one. Next in the file add the following
server {
listen 80;
listen [::]:80;
root /var/www/html/public_html;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
}
You just need to replace example.com with your domain name.
Next one, you need to create a symlink:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
Again change the example.com with your domain.com.conf.
Now that you are done, restart Nginx and you are good to go
sudo systemctl restart nginx
Regards, KFSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.