Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Michel Kuguio

vehost dinamico com nginx vagrant (tenho vhost base do apache)

Recommended Posts

Olá, estou aprendendo a trabalhar com server, e tentei configurar uma maquina com nginx e consegui mais ou menos, te consegui com exito no apache, tenho modelo de vhost q quero fazer, como vm estou usando o virtualbox com o vagrant. a minha meta é q todos meu s sites com .dev seja apontado para paste com nome dele. segue exemplo funcionando do apache.

 

 

<Virtualhost *:80>
    VirtualDocumentRoot "/vagrant/sites/%1/public"
    ServerName sites.dev
    ServerAlias *.dev
    UseCanonicalName Off
    <Directory "/vagrant/sites/*">
        Options Indexes FollowSymLinks MultiViews


        AllowOverride All

        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
</Virtualhost>

<Virtualhost *:80>
    VirtualDocumentRoot "/vagrant/sites"
    ServerName localhost
    ServerAlias localhost
    UseCanonicalName Off
    <Directory "/vagrant/sites/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
</Virtualhost>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Resolvi =)

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

	root /vagrant/sites/;
	index index.html index.htm index.php index.phtml;

	# Make site accessible from http://localhost/
	server_name localhost;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/  =404;
		# Uncomment to enable naxsi on this location
		# include /etc/nginx/naxsi.rules
	}

	# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
	#location /RequestDenied {
	#	proxy_pass http://127.0.0.1:8080;    
	#}

	error_page 404 /404.html;

	# redirect server error pages to the static page /50x.html
	#
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root /vagrant/sites/;
	}


	location ~* \.(?:ico|css|js|gif|png|jpe?g)$ {
		expires max;
		add_header Pragma public;
		add_header Cache-Control "public, must-revalidate, proxy-revalidate";
	}

	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	location ~ \.(php|phtml)$ {

		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

		# With php5-cgi alone:
		#fastcgi_pass 127.0.0.1:9000;
		# With php5-fpm:

		fastcgi_pass unix:/var/run/php5-fpm.sock;
		#fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $request_filename;
		include fastcgi_params;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny all;
	}
}

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

        # Make site accessible from http://localhost/
        server_name   ~^(?<domain>.+)\.dev$;


        root /vagrant/sites/$domain/public;
        index index.html index.htm index.php index.phtml;


        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/  =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #       proxy_pass http://127.0.0.1:8080;
        #}

        error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /vagrant/sites/$domain/public;
        }


        location ~* \.(?:ico|css|js|gif|png|jpe?g)$ {
                expires max;
                add_header Pragma public;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.(php|phtml)$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                # With php5-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:

                fastcgi_pass unix:/var/run/php5-fpm.sock;
                #fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                include fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny all;
        }
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.