配置lnmp站点

1、在nginx的conf文件夹新建vhost文件夹,再新建conf文件,命名自定。我建的是mine.conf

2、在nginx.conf文件http中添加

include       vhost/*.conf;

表示连接到刚才创建的文件。

3、在mine.conf中添加配置。你的server_name、root、index、fastcgi_pass是什么就改成什么

server {
        listen       80;
        server_name  admin.lanyeart.com; #可添加多个,多个之间“空格”分开
        #autoindex on;#打开目录浏览,这样当没有找到index文件,就也已浏览目录中的文件
        location / {
            root   F:/LanyueArt/mall;
            index  index.html index.htm index.php;
            #此处是伪静态配置
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php/?/$1  last;
                break;
            }
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   F:/wnmp/wwwroot;
        }
        location ~ \.php$ {
            root           F:/LanyueArt;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

4、阿帕奇的vhost文件添加

<VirtualHost *:9000>
    ServerAdmin [email protected]
    DocumentRoot "F:/LanyueArt/mall"
    ServerName admin.lanyueart.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
    
    <Directory "F:/LanyueArt/mall">
        #Options Indexes FollowSymLinks
        AllowOverride all
        Require local

        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !^.*\.(js|css|ico|gif|jpg|jpeg|png|swf|txt)$
        RewriteRule ^(.*)$ index.php [L]
    </Directory>

</VirtualHost>

5、hosts文件添加域名

6、httpd文件添加监听端口

7、在网站文件目录添加index.html文件,就可以测试网站啦

猜你喜欢

转载自blog.csdn.net/qq_33514421/article/details/79589932
今日推荐