Skip to main content

How to deploy angular2 with Apache server ?

How to deploy angular2 with Apache server  and angular cli?

  1. ng build --prod
  2. It will create dist folder in the application
  3. Copy the dist folder all files to /var/www/html/
  4. Create .htaccess file in the path of /var/www/html/
  5. Write this code   in .htaccess file
    • <IfModule mod_rewrite.c> 
    •  RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L]
    •  RewriteCond %{REQUEST_FILENAME} !-f 
    •  RewriteCond %{REQUEST_FILENAME} !-d 
    •  RewriteRule . /index.html [L]
    • </IfModule>
  • sudo service apache2 restart



Comments