By cooliojones
Looking for help from someone out there. I’ve searched through a lot of tutorials, and I feel like I’m close to a solution, but haven’t gotten it yet.
I’m running CentOS 7 on a new droplet. I want to run nginx to serve multiple virtual hosts. Here’s the list of commands I used to attempt to get nginx running from beginning to end:
sudo yum install nginx -y
sudo nano /etc/php-fpm.d/www.conf
change apache to nginx in this section: Unix user/group of processes
sudo nano /etc/nginx/nginx.conf
change worker_processes to 4
add this under http: server_names_hash_bucket_size 64;
sudo nano /etc/nginx/conf.d/virtual.conf
this configuration is pasted into the blank file:
server {
listen 80;
server_name example.com www.example.com;
error_log /home/user/public_html/example.com/error.log;
location / {
root /home/user/public_html/example.com;
index index.php index.html index.htm;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
root /home/user/example.com;
fastcgi_param SCRIPT_FILENAME /home/user/public_html/example.com$fastcgi_script_name;
include fastcgi_params;
}
}
mkdir -p /home/user/public_html/example.com
chmod -R 755 /home/user/public_html
nano /home/user/public_html/example.com/index.html
paste this code in the file:
<html>
<head>
<title>domain1.com</title>
</head>
<body>
<h1>domain1.com</h1>
</body>
</html>
sudo systemctl start nginx && systemctl enable nginx.service
My DNS is pointing to the IP of the server. The issue I’m having is that I continue to get a ‘403 forbidden error’ message when I try to visit the site. After a while the other posts found on Google start to repeat themselves so I’m not getting any new answers that way. Anyone have any ideas as to why this isn’t working?
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! Do you see any errors in nginx’s error log?
tail /home/user/public_html/example.com/error.log
What are the permissions on the home directory? Please post the output of ls -ld /home/user.
I finally got it. I found this page and used the permissions he listed, and it finally made nginx work:
http://www.server-world.info/en/note?os=CentOS_6&p=nginx&f=3
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.