Got "The requested URL was not found on this server." error when I hosted my Symfony4 project in AWS EC2 - apache

I created a project using Symfony 4 and it works fine in my local environment. Then I hosted my project in AWS EC2 and project installed perfectly. Then I access the root, index.php file works fine and it shows symfony 4 welcome page.
But when I try to go to different URL, it gives me below 404 error.
The requested URL was not found on this server.
Apache/2.4.18 (Ubuntu) Server at 52.221.55.155 Port 80
I can't goto any routes which are defined in the routes.yaml file. But thease routes work fine in my local environment.
Below is the .conf file I used.
<VirtualHost *:80>
ServerName 52.221.55.155
DocumentRoot /var/www/html/oenele-dev-team-server-side/public/
ErrorLog ${APACHE_LOG_DIR}/oenele-dev-team-server-side-error.log
CustomLog ${APACHE_LOG_DIR}/oenele-dev-team-server-side-access.log combined
<Directory "/webhost/public/index.php">
allow from all
</Directory>
</VirtualHost>
Please help me to figure this out.

I found the issue here. Issue was in my .conf file. I change it like below and it works fine now.
<VirtualHost *:80>
ServerName 52.221.55.155
DocumentRoot /var/www/html/oenele-dev-team-server-side/public/
ErrorLog ${APACHE_LOG_DIR}/oenele-dev-team-server-side-error.log
CustomLog ${APACHE_LOG_DIR}/oenele-dev-team-server-side-access.log combined
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
<Directory /var/www/html/oenele-dev-team-server-side/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Related

This site can’t be reached - XAMPP ignores custom domain vhosts

Environment
XAMPP 7.2.4 installed on Windows 10
Apache running on ports 80 and 443
Configuration
C:\Windows\System32\drivers\etc\hosts:
127.0.0.1 www.test.local test.local
C:\xampp\apache\conf\httpd.conf:
DocumentRoot "D:/htdocs"
<Directory "D:/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
C:\xampp\apache\conf\extra\httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot D:/htdocs
ServerName localhost
<Directory "D:/htdocs">
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot D:/htdocs
ServerName test.local
<Directory "D:/htdocs">
Allow from all
</Directory>
</VirtualHost>
The problem
When I start Apache and I access to localhost is all right. The problem comes when I try to reach test.local: the browser returns a This site can’t be reached message. It's like XAMPP ignores the custom domain vhosts defined into httpd-vhost.conf file. The same message is displayed with the server off.
This site can’t be reached
The webpage at http://test.local/ might be temporarily down or it may have moved permanently to a new web address.
ERR_ADDRESS_INVALID
A few days ago the setup was working and the only changes that I made was the new software installation. I mean, no changes in Apache config files.
If all your stack were working correctly before, don't be like me and don't forget to check if some browser extension is blocking your local traffic, like some extension related with an antivirus system.
In my case it was the Kaspersky Protection extension. When something goes wrong, it shows the following graphic.
C:\Windows\System32\drivers\etc
127.0.0.1 test.local
C:\xampp\apache\conf\extra\httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "C:/wamp64/www/test"
ServerName test.local
<Directory "C:/wamp64/www/hydroboost/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Have you updated your C:\Windows\System32\drivers\etc\hosts file with a mapping like this this?
add this line to the end of the hosts file
127.0.0.1 test.local
the localhost domain works without this mapping, because the OS already recognizes "localhost" as a built in alias for the loopback IP address
(this suggestion is assuming that you are running and testing on the same local machine)

Hosting another website on linux AMAZON EC2 intance running bitnami wordpress

I have an EC2 instance created with Bitnami wordpress, I am trying to host my other website on the same instance website.tld
I followed the steps on this guide
https://docs.bitnami.com/aws/components/apache/#how-to-create-a-virtual-host
Then I went to "/opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf" and changed it to
<VirtualHost *:80>
ServerName mywordpress.com
ServerAlias mywordpress.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
<VirtualHost *:80>
ServerName website.tld
ServerAlias www.website.tld
DocumentRoot "/opt/bitnami/apps/website/htdocs"
ErrorLog "logs/website-error_log"
CustomLog "logs/website-access_log" common
</VirtualHost>
<VirtualHost *:443>
ServerName mywordpress.com
ServerAlias www.mywordpress.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
SSLEngine on
SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
I created the empty folders "/opt/bitnami/apps/website/htdocs" for my new website then added an index.html inside htdocs
Then I restarted the apache server
sudo /opt/bitnami/ctlscript.sh restart apache
mywordpress.com works fine as before, but when i try to open website.tld I get this error
Forbidden
You don't have permission to access / on this server.
Am i doing it wrong? is there any other configurations i missed?
What is more confusing is there are httpd-vhosts.conf files inside the apache2 server and inside each folder in the apps/ folder, I am not sure which of all I should be adding my new domain tag into? Following the bitnami docs I edited the one inside apps/wordrpess/config
I am not a server side guy, is there a UI for the apache server that can help me setup the virtual host?
Thank you in advance.
You have to set the permissions for this directory in apache2.conf/ httpd.conf.
<Directory [your path]>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
And set the permissions with chmod 755

OS X Apache2 vhosts hosts domain not working

Setting up my local dev environment due to an update in OS X pushing new Apache Files.
This setup works fine when going to localhost or http://127.0.0.1 but when I setup the hosts file like so
127.0.0.1 bears.dev www.bears.dev
bears.dev just comes up with "This site can't be reached" in chrome.
Below is my vhosts configuration setup. I'm stumped as to why this isn't work, i'm pretty sure it worked previously.
<VirtualHost *:80>
ServerName bears.dev
ServerAlias www.bears.dev
DocumentRoot "/Users/Bears/Dev"
ErrorLog "/private/var/log/apache2/bears.dev-error_log"
CustomLog "/private/var/log/apache2/bears.dev-error_log" common
ServerAdmin superbear9000#gmail.com
<Directory "/Users/Bears/Dev">
Options FollowSymLinks Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Thanks for the assistance!
In hosts file don't add two domains in line
right way is:
127.0.0.1 www.bears.dev
127.0.0.1 bears.dev

Apache won't start with added VirtualHost, but gives no error in error log

I am using EasyPHP (version 16.1.1) for Apache server (installed version 2.4.18 x86). I need to add a new VirtualHost, so now the whole VirtualHost section of httpd.conf looks like this:
# VIRTUAL HOSTS
## Virtualhost localweb
<VirtualHost 127.0.0.1>
DocumentRoot "C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www"
ServerName 127.0.0.1
<Directory "C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www">
Options FollowSymLinks Indexes ExecCGI
AllowOverride All
Order deny,allow
Allow from 127.0.0.1
Deny from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:8080>
UseCanonicalName Off
ServerAdmin marekbuchtela#gmail.com
ServerName posis
ServerAlias posis.tovarna
VirtualDocumentRoot "C:\Users\marek\is\tovarna\public"
</VirtualHost>
The first one is the default one made by EasyPHP, the second one is added by me. However in this setup, the Apache won't start. When I remove the second VirtualHost, everything works fine, but with it, it just won't start at all. I have checked the error log and there is no output at all.
Any ideas why is this happening/how to fix it?
Thanks
Switch VirtualDocumentRoot "C:\Users\marek\is\tovarna\public"for DocumentRoot "C:\Users\marek\is\tovarna\public"
If by any chance you keep getting the error, show error_log output
There is another instance other than the answer given by ezra-s as to why EasyPHP server won't start and the Apache error log is empty.
When declaring paths in the vhosts file, it is important that the directories referenced in those paths exist. If you provide the following VirtualHost information, for example:
<VirtualHost *:80>
DocumentRoot "D:/MyApp/public_html"
ServerName myapp.local
ErrorLog "D:/MyApp/logs/error.log"
CustomLog "D:/MyApp/logs/apache.log" common
</VirtualHost>
...but you don't have a D: drive, or the directories D:/MyApp/ and D:/MyApp/logs/ don't exist, then you'll get a "silent fail" in Apache when starting the HTTP server from the EasyPHP console.

Apache Passenger handle 'www' in url

I've an application deployed to EC2 using passenger and apache2.
I've registered a domain (not with AWS) and have two 'A' records pointing to my instance's elastic IP
appname.com.
*.appname.com.
In my apache2.conf file (below), I've got ServerName appname.com
The application is working perfectly when you type appname.com into a browser. But if you put www.appname.com into the browser, you just get the default apache page.
Does anyone know what I put in ServerName to handle both? I've tried adding another ServerName line under the first but it doesn't work.
Thanks for looking
/etc/apache2/apache2.conf
<IfModule mod_passenger.c>
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-5.0.6
PassengerDefaultRuby /usr/bin/ruby1.9.1
</IfModule>
<VirtualHost *:80>
ServerName appname.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/ubuntu/projects/appname/public
ErrorLog /home/ubuntu/projects/appname/log/error.log
RailsEnv development
<Directory /home/ubuntu/projects/appname/public>
# This relaxes Apache security settings.
AllowOverride all
Require all granted
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
I solved it thanks to this post (shame you can't thank on the other stack sites using your stackoverflow reputation)
Under
ServerName appname.com
you put
AliasName www.appname.com
or even better
AliasName *.appname.com