Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Ubuntu服务器上运行Angular 2-空白屏幕无错误_Php_Angular_Ubuntu - Fatal编程技术网

Php 在Ubuntu服务器上运行Angular 2-空白屏幕无错误

Php 在Ubuntu服务器上运行Angular 2-空白屏幕无错误,php,angular,ubuntu,Php,Angular,Ubuntu,我有一个angular 2项目,当我通过XAMPP在本地运行时,它工作得很好,但是当我将angular 2添加到我的Ubuntu服务器时,我会得到一个没有错误的白屏。我添加了一个.htaccess文件,它如下所示: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f Re

我有一个angular 2项目,当我通过XAMPP在本地运行时,它工作得很好,但是当我将angular 2添加到我的Ubuntu服务器时,我会得到一个没有错误的白屏。我添加了一个.htaccess文件,它如下所示:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>
<VirtualHost *:80>
    ServerName example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/front/src
    <Directory /var/www/html/front>
        AllowOverride All
    </Directory>
    Alias /api  /var/www/html/api/public
    <Directory /var/www/html/api>
        AllowOverride All
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

重新启动发动机
重写基/
重写规则^index\.html$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.html[L]
我还启用了Apache的mod_rewrite扩展,并在/etc/apache2/sites available/laravel.conf文件中调整了我的虚拟主机,使其看起来像这样:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>
<VirtualHost *:80>
    ServerName example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/front/src
    <Directory /var/www/html/front>
        AllowOverride All
    </Directory>
    Alias /api  /var/www/html/api/public
    <Directory /var/www/html/api>
        AllowOverride All
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

ServerName example.com
服务器管理员webmaster@localhost
DocumentRoot/var/www/html/front/src
允许超越所有
别名/api/var/www/html/api/public
允许超越所有
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
但我得到的只是一个空白屏幕,页面上没有错误

我正在运行Angular CLI:1.6.2,节点v8.11.3,npm 6.3.0


请帮忙

检查浏览器控制台
/var/www/html/front/src
您是否构建了项目并将dist的内容放在这里?浏览器控制台中没有任何内容。我的索引文件在src文件夹中是的,是的,但是您是否
构建了您的项目?我不认为简单地指向索引就行了,特别是当你使用apache的时候。好的,我会尝试在我的src文件夹中构建……ng serve正确吗?不,一点也不正确。我想让你看看这些文件