PHP和wampserver使用虚拟主机在用户计算机上加载数据太慢

时间:2018-11-05 11:24:30

标签: php apache performance wamp virtualhost

我有一个基于PHP-MySQL的单页应用程序(使用Angular 6),在本地网络上工作。

我们将etc/hosts设置如下:

#127.0.0.1 localhost
#::1 localhost

192.168.0.217   dev.local
::1 dev.local

#127.0.0.1  angular.local
#::1    angular.local

127.0.0.1 localhost
::1 localhost

192.168.0.217   angular.local
::1 angular.local

angular.local是在用户窗口上打开的应用程序,dev.local是用于访问PHP脚本进行登录,添加,编辑...的应用程序。

httpd-vhosts如下:

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    #Require local
    Allow from 192.168.10.0
    Allow from 192.168.0.217
Require all granted
  </Directory>
</VirtualHost>


#dev.local
<VirtualHost *:80>

    ServerAdmin it@m.org
    DocumentRoot "c:/wamp64/www/dev"
    ServerName dev.local    
    ServerAlias www.dev.local

    <Directory  "c:/wamp64/www/dev/">   
        AllowOverride All
        Require ip 192.168.0
        Require ip 192.168.1    
        Require ip 192.168.10
        Require all granted     
                Allow from all
    </Directory>
</VirtualHost>


#
<VirtualHost *:80>
    ServerName angular.local
    DocumentRoot "c:/wamp64/www/angular/"
    ServerAlias angular.local
    <Directory  "c:/wamp64/www/angular/">
        #Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require ip 192.168
        Require all granted
        Allow from all
    </Directory>
</VirtualHost>

在服务器端,运行应用程序时,获得1.11 seconds约有11000多个记录:

enter image description here

在用户计算机上,我们允许他将其etc/hosts文件更改为以下位置来访问应用程序:

#127.0.0.1  host1
#::1    host1
#127.0.0.1 aff.local
#127.0.0.1 primero.test
#127.0.0.1 localhost
#::1 localhost
127.0.0.1 dev.local

192.168.0.217   angular.local
192.168.0.217 dev.local
::1 angular.local

获取11000多个记录的请求花费了13.25 seconds,这是一个非常糟糕的时机:

enter image description here

我做了所有用此answer编写的内容,但仍然存在相同的问题,并且在某些计算机上花费了25 seconds

如本link中所述,我将所有AllowOverride All更改为AllowOverride None

文档说:

  

然后Apache将尝试打开/.htaccess、/www/.htaccess和   /www/htdocs/.htaccess。解决方案与先前的情况相似   选项FollowSymLinks。为了获得最高性能,请使用AllowOverride   文件系统中的任何地方都没有。

但仍然存在相同的问题。

然后我检查了此link并禁用了xdebug,但仍然存在相同的问题。

0 个答案:

没有答案