window下phpstudy的nginx配置虚拟主机
2018-01-25 14:25
483 查看
由于很长时间没有配置Apache,虽然说知道怎么配置nginx,但是还是花费了一些时间这次记下来下次直接用
在其他选项文件菜单中->打开配置文件->选择vhosts-conf
nginx的话使用
server { listen 80; server_name 你的虚拟目录名称; root "你要操作的目录路径"; location / { index index.html index.htm index.php; #autoindex on; if ($request_filename !~ (static|robots/.txt|index/.php.*)) { rewrite ^/(.*)$ /index.php?$1 last; break; } } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
之后最重要一点就是DNS解析了:在C:\Windows\System32\drivers\etc下打开hosts
加入你配置的域名解析到本地的代码例如
127.0.0.1 localhost 这个是默认有的 127.0.0.1 www.mycomment.com
apache的虚拟主机的话代码可以参考
<VirtualHost *:80> ServerAdmin fudesign2008@163.com DocumentRoot "F:\workspace\vim\YNote\src" ServerName editor.fuyg.cn ServerAlias editor.fuyg.cn ErrorLog "logs/dummy-host.localhost-error.log" CustomLog "logs/dummy-host.localhost-access.log" combined <Directory "F:\workspace\vim\YNote\src"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
以下为亲测有效:
<VirtualHost _default_:80> DocumentRoot "D:\phpstudy\PHPTutorial\WWW" <Directory "D:\phpstudy\PHPTutorial\WWW"> Options -Indexes -FollowSymLinks +ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin hzym.com DocumentRoot "D:\phpstudy\PHPTutorial\WWW\welltrend\www" ServerName hzym.com ServerAlias hzym.com ErrorLog "logs/dummy-host.localhost-error.log" CustomLog "logs/dummy-host.localhost-access.log" combined <Directory "D:\phpstudy\PHPTutorial\WWW\welltrend\www"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
相关文章推荐
- window下phpstudy的nginx配置虚拟主机和伪静态
- window下phpstudy的nginx配置虚拟主机
- window下phpstudy的nginx配置虚拟主机
- docker映射window本地文件夹的nginx的虚拟主机配置文件vhost.nginx.conf
- window下配置nginx 及虚拟主机
- Nginx作为WEB服务相关配置(性能优化,网络连接,访问控制,虚拟主机,https等等)
- nginx下多项目虚拟主机配置
- Linux实战第八篇:CentOS7.3下Nginx虚拟主机配置实战(基于端口)
- nginx虚拟主机别名配置
- Nginx配置基于域名的虚拟主机
- Nginx 虚拟目录和虚拟主机的配置
- Nginx配置虚拟主机
- nginx的高级配置(1)——为某个虚拟主机添加用户验证
- 默认虚拟主机,Nginx用户认证,Nginx解析php相关配置,Nginx代理
- nginx配置虚拟主机
- NGINX:虚拟主机配置
- Nginx实现多个站点使用一个端口(配置Nginx的虚拟主机)
- Ubuntu--nginx配置虚拟主机
- nginx 配置虚拟主机的三种方法
- 【nginx运维基础(2)】Nginx的配置文件说明及虚拟主机配置示例