Running Angular 2 on Ubuntu Server - Blank Screen No Errors - php

I have an angular 2 project, when I run on my locally via XAMPP it works fine, but when I add Angular 2 to my Ubuntu Server, I get a blank white screen with no errors. I add an .htaccess file and it looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
I also enabled Apache's mod_rewrite extension and adjusted my VirtualHosts in /etc/apache2/sites-available/laravel.conf file so it looks like this:
<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>
But all I get is a blank screen with no errors on the page.
I am running Angular CLI: 1.6.2, node v8.11.3, npm 6.3.0
PLEASE HELP!

Related

Configuring Symfony 5 Application on Apache server

I need some help with configuring Symfony on apache2 web server.
My current project category structure is:
var/www/domain.com/public_html
Inside public_html is where my Symfony application is located.
I am stuck at figuring our what I am doing wrong in my either .htaccess or /etc/apache2/sites-available/domain.com.conf files.
I am using symfony/apache-pack. My .htaccess files live inside /public folder as per documentation. Here it is:
DirectoryIndex index.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
RewriteRule .* - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
And here is my /etc/apache2/sites-available/domain.com.conf
<VirtualHost *:80>
ServerAdmin someemail#example.com
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/mydomain.com/public_html/public
<Directory /var/www/mydomain.com/public_html/public>
AllowOverride All
Order allow,deny
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
I also read this and updated 000-default.conf as follows:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerAlias www.mydomain.com
DocumentRoot /var/www/mydomain.com/public_html/public
<Directory /var/www/domain.com/public_html/public>
Options FollowSymlinks MultiViews
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml >
</IfModule>
</VirtualHost>
For the moment I am still seeing symfony project folder structure.
I tried:
inside .htaccess changing DirectoryIndex to /public/index.php
inside .conf file changin DocumentRoot to /va/www/domain.com/public_html/public
tried clearing cache
SO far nothings seems to help.
Would be extremely helpful for any advice.
I see that you are editing vhost which begins with
<VirtualHost *:80>......
That mean your website should be reachable by 80 port or in other words by http protocol. But! If in reality you are accessing your website by https protocol then make sure you are editing right Apache2 .conf file.
If the website is reachable by https protocol (especially if you use LetEncrypt), then try locating /etc/apache2/sites-available/....-le-ssl.conf config file (or similar one with corresponding domain title and with ssl prefix or postfix in it's name).
After editing that file do not forget to restart Apache2 webserver with $sudo service apache2 restart and test website again.

Wordpress paramlinks change from plain to post name resulting in 404 not found

Hello I have a WordPress site and I changed the paramlinks from plain to post name. All my posts are showing 404 not found. I tried to check all possible causes but I could not find why it is not working.
My .htaccess is as below:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Apache mode rewrite is enabled, the command a2enmod rewrite gives:
Module rewrite already enabled
PHP info shows mod_rewrite in Loaded Modules.
My vhost is as following:
<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
ServerAdmin webmaster#mysite.com
DocumentRoot /var/www/mysite/public_html
ErrorLog /var/www/mysite/logs/error.log
CustomLog /var/www/mysite/logs/access.log combined
<Directory "/var/www/mysite/public_html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Any help on this please? Thanks.

setting .htaccess file in slim

I am having issues redirecting to index.php in my slim app with .htaccess file.
Routes work if I add the index.php at the end of the URL
So slimapp.dev/hello/myname gets error
Not Found The requested URL /hello/myname was not found on this server.
while slimapp.dev/index.php/hello/myname works
Here is my .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index.php [QSA,L]
I am using Apache 2 on Ubuntu 18.04
File structure
public_html
|_index.php
|_ vendor
|_.htaccess
virtualHost 000-default.conf
<VirtualHost *:80>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
If I use the php -S localhost:3000 it works as expected but if I use the Apache web server, I most add the index.php to the end of the URL to make it work. Thanks
You are doing wrong.This is quite simple with just two lines of code:
RewriteEngine On
RewriteRule ^myname/(.*)$ /$1 [L]

Installing laravel 5 in sub-directory

I wanted to isntall laravel in a sub directory inside my dev machine http://dev-machine/applis/main/laravel
My default document root is F:/data/web
My .htaccess file is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /applis/main/laravel
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
My httpd.conf file has below code
<VirtualHost *:80>
ServerName http://dev-machine/applis/main/laravel/public
DocumentRoot F:/data/web/applis/main/laravel/public
<Directory "applis/main/laravel/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I have also tried the belwo virtual host config
<VirtualHost *:80>
ServerName http://dev-machine/applis/main/laravel/public
Alias /laravel applis/main/laravel/public
DocumentRoot F:/data/web/applis/main/laravel/public
<Directory "/applis/main/laravel/public">
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
But stil I am unable to access the app via
http://dev-machine/applis/main/laravel/public
I am getting he below error
Not Found
The requested URL /applis/main/laravel/public/ was not found on this server.
After adding the virtual host when it is not even loading the index.php file when I try loading it directly via http://dev-machine/applis/main/laravel/public/index.php

Laravel 5.1 .htaccess not working (pretty url's)

So I have tried both versions of the .htaccess, the one that comes with it in project creation and the one in the documentation. I am currently using the one in the documentation:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I have my virtualhost set up like so:
<VirtualHost *:80>
ServerAdmin <my email>
ServerName projectflyer.<my domain>.com
DocumentRoot /var/www/html/projects/project-flyer/public
DirectoryIndex index.php
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
However when I go to projectflyer.mydomain.com/some/route I get back a 404. Any ideas? Yes I can go to the base url just fine.
I solved this by adding this to my virtualhost .conf file:
<Directory /path/to/your/install/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Thanks to http://laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116 for the answer

Categories