Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Nginx + Virtual Domain on Ubuntu 14 Desktop

nginx ubuntu

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 cakka


    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 190 posts

Posted 22 November 2015 - 02:57 PM

I am trying to set virtual domain on my ubuntu desktop, but it is always failed.


This is the codes for nginx "sites-available/default "

server {
	listen 80 default_server;
	listen [::]:80 default_server ipv6only=on;

	root /usr/share/nginx/html;
	index index.php index.html index.htm;
	server_name localhost;

	location / {
		try_files $uri $uri/ =404;

	error_page 404 /404.html;

	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root /usr/share/nginx/html;

	location ~ \.php$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass unix:/var/run/php5-fpm.sock;
		fastcgi_index index.php;
		include fastcgi_params;

This is for myvirtualdomain.dev in "sites-available/myvirtualdomain.dev"

server {
    listen 80;

    root /media/cakka/Data/xampp/htdocs/sentrabelanja;
    index index.php index.html index.htm;

    server_name sentrabelanja.dev;

    location / {
        try_files $uri $uri/ =404;

I have restart nginx and php5-fpm, copy the config to sites-enabled.

But, everytime I am opening myvirtualdomain.dev, itu just give 404 not found.


In nginx error.log, I got this message :



2015/11/23 05:33:50 [crit] 3747#0: *1 stat() "/media/cakka/Data/xampp/htdocs/myvirtualdomain/" failed (13: Permission denied), client:, server: myvirtualdomain.dev, request: "GET / HTTP/1.1", host: "myvirtualdomain.dev"


I also tried to move the directory to /usr/share/nginx/myvirtualdomain. But, it was failed too. I think, there is no problem with the directory location. The problem is with the configuration.


Please help me, what is wrong from my config.


Thank you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download