-
-
Save Motaibi1989/93bc70a18d1c617c95920668048e6dae to your computer and use it in GitHub Desktop.
Nginx Virtual Host example to work on localhost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Location: /etc/nginx/sites-available/domain.tld.conf | |
| server { | |
| listen 80; | |
| # listen 443 ssl; | |
| # include snippets/snakeoil.conf; | |
| root /var/www/domain.tld/public; | |
| index index.html index.php; | |
| server_name domain.tld www.domain.tld; | |
| location / { | |
| try_files $uri $uri/ /index.php; | |
| } | |
| location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ { | |
| expires max; | |
| log_not_found off; | |
| } | |
| location ~ \.php$ { | |
| include snippets/fastcgi-php.conf; | |
| fastcgi_pass unix:/var/run/php5-fpm.sock; | |
| } | |
| location ~ /\. { | |
| deny all; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Location: /etc/hosts | |
| 127.0.0.1 localhost | |
| 127.0.0.1 domain.tld |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Location: /var/www/domain.tld/public/index.php | |
| phpinfo(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Location: Anywhere | |
| sudo ln -s /etc/nginx/sites-available/domain.tld.conf /etc/nginx/sites-enabled/domain.tld.conf; | |
| sudo service nginx restart; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment