• Apache和nginx 域名配置


    apache配置

    .hosts配置:

    1.用编辑器打开hosts文件,位置:C:WindowsSystem32driversetc目录下

    2.hosts文件里添加自己的域名配置,配置规则如下:

    127.0.0.1 域名1

    127.0.0.1 域名2

    ..........

    .apache配置:

    1.编辑httpd.conf文件,开启虚拟主机,位置:在apache的安装目录,即phpstudy安装目录下的phpStudyApacheconf,找到Include conf/extra/httpd-vhosts.conf,去掉前面的#

    2.进入开启的虚拟主机文件httpd-vhosts.conf进行域名配置,位置:phpStudyApacheconfextra目录下

    配置规则:
    # localhost 默认的
    <VirtualHost *:80>
        DocumentRoot "F:GZJwww"
        ServerName localhost
        ServerAlias
      <Directory "F:GZJwww">
          Options FollowSymLinks ExecCGI
          AllowOverride All
          Order allow,deny
          Allow from all
          Require all granted
      </Directory>
    </VirtualHost>

    新配置的
    <VirtualHost *:80>
        DocumentRoot "F:GZJwwwdatong"           地址
        ServerName dt.cn    域名
        ServerAlias
      <Directory "F:GZJwwwdatong">
          Options FollowSymLinks ExecCGI
          AllowOverride All
          Order allow,deny
          Allow from all
          Require all granted
      </Directory>
    </VirtualHost>

    nginx配置

    Nginx  -t 查看nginx配置的正确性

    配置host

    1cd /etc/hosts

    增加自定义域名127.0.0.1 自定义域名”     对应conf.d下的server_name的值

    2直接复制nginx下的sites-enabled下的default con.d目录下新命名一个你需要的名字;(每个域名 在conf.d目录下配置一个新配置文件来对应每个域名)

    3设置nginx下的conf.d 下刚刚自定义.conf 文件 内容如下:(配置根据自己存放地址等不同)

    Server{

    Listen 80;

    Root (后面跟上项目地址);

    Index index.php;

    Server_name (配置得域名 和/etc/hosts)里添加得域名要一致;

    Location / {

    Try_files $uri $uri/ =404;

    }

    Location  ~  .php {

    Root  (后面跟上项目地址);

    Include fastcgi.conf;

    Fastcgi_index index.php;

    Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    Fastcgi_pass unix:/run/php/php7.o-fpm.sock;

    }

    }

    配置这些前 先到php里面去掉分号

    路径 /etc/php/7.0/fpm/pool.d/www.conf

    去掉 listen = /var/run/php/php7.0-fpm.sock 前面得分号

     

    作者地址:https://www.cnblogs.com/G921123/
    创作也有乐趣 知识分享 转载注明出处 相互理解 谢谢! WeChat:17321295203
  • 相关阅读:
    centos7上安装memcached以及PHP安装memcached扩展(二)
    centos7上安装memcached以及PHP安装memcached扩展(一)
    centos7上安装redis以及PHP安装redis扩展(二)
    centos7上安装redis以及PHP安装redis扩展(一)
    Redis Desktop Manager无法连接虚拟机中启动的redis服务问题排查步骤
    CentOS 7设置开机启动服务,添加自定义系统服务
    delphi 选择文件夹目录保存
    mysql drop database ERROR 2013
    delphi 在别的方法 调用keypress事件
    delphi Inc Dec用法
  • 原文地址:https://www.cnblogs.com/G921123/p/10156966.html
Copyright © 2020-2023  润新知