Deploy a lumen project in AWS ec2 with multiple Virtual Host - php

I need to deploy three site in AWS ec2 ubuntu server (same ip),
html(default site)
aaa.com(www.aaa.com)
bbb.com(www.bbb.com)
/var/www:
html
public
index.html
aaa.com
public_html
index.html
bbb.com
public_html
app
bootstrap
public
..
html and aaa.com are pure html project, and bbb.com is a lumen project, when I add a .htaccess file , the site will always get the 500 Internal Server Error.
if I remove the .htaccess the site will get the 403 Forbidden (because of Options FollowSymLinks MultiViews, I guess), how to correctly rewrite the lumen site for bbb.com ? any idea?
bbb.com.htaccess file :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
/etc/apache2/sites-available/bbb.com.conf :
<VirtualHost *:80>
ServerAdmin bbb#gmail.com
ServerName bbb.com
ServerAlias www.bbb.com
DocumentRoot /var/www/www.bbb.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/www.bbb.com/public_html>
Options FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>

Related

My redirection is removing the slash after uploading the website on Apache2 server - admin.site.comlogin instead of admin.site.com/login

I have a website built based on PHP/HTML/CSS and which follow the MVC design pattern.
The website is the following : https://admin.site.com
It works well on Localhost. However, when I upload it to my apache2 server, I encounter a problem. It seems that the "/" get removed automatically after ".com" . As I need to be authentificated to access the website, I'm directly redirected to the login page but as the "/" has been removed, it is not working.
I get https://admin.site.comlogin/ instead of https://admin.site.com/login/
Before posting here, I tried to check everything but I run out of ideas.
Especially the fact that this same website works on a different subdomain that I initiated for testing : http://sub1.site.com
The only difference is that that this one does not have any SSL certificate but I don't know it's something that may cause the problem.
Here my different files in Apache2 server.
000-defaut.conf
<VirtualHost *:80>
ServerAdmin contact#site.com
ServerName site.com
ServerAlias sub1.site.com
DocumentRoot /var/www/sub1/interface/
<Directory /var/www/sub1/interface/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin contact#site.com
ServerName site.com
ServerAlias admin.site.com
Redirect permanent "/" "https://admin.site.com"
DocumentRoot /var/www/site/interface/
<Directory /var/www/site/interface/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
defaut-ssl.conf
ServerAdmin contact#site.com
ServerName site.com
ServerAlias admin.site.com
DocumentRoot /var/www/site/interface/
<Directory /var/www/site/interface/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
...
</VirtualHost>
.htaccess
`# Remove the question mark from the request but maintain the query string
RewriteEngine On
# Uncomment the following line if your public folder isn't the web server's root
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?$1 [L,R]
Do you have any insight about why it is not working and the slash get removed ?
I solved my issue simply :
I have added a trailing slash at the end to the redirect permanent directive.
Redirect permanent "/" "https://admin.site.com/"
I had some conflict as well with some directive. So I removed all the Directory directive to my conf file and let them only on my apache2.conf .
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

XAMPP Access Forbidden

I have just downloaded the latest version of XAMPP with PHP version 7.2.4. I have made a very simple PHP validation for a HTML form and when I press submit it comes up with the following:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
I'd don't know what the problem is as I have tried changing Require none to Require all granted.
Please Help!
I have experienced this problem and found out that localhost link is not configured in
httpd_vhosts.conf.
So I added this line at the bottom part of httpd_vhosts.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs"
ServerName localhost
</VirtualHost>
Well, probably this must be happening because the localhost link is not configured in your xamp vhost, try to look for the vhosts configuration file and add the same one there. Just add this block of code making the appropriate path changes until your repository so that you can access the localhost:
# 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
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#hcode.com.br
DocumentRoot "C:\ecommerce"
ServerName www.hcodecommerce.com.br
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:\ecommerce">
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</Directory>
</VirtualHost>
By default in httpd.conf your entire system directory "/" is secured and not allowed access
in httpd.conf:
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
Add the below additional under the above
<Directory /home>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
Change /home to your hosted installation public directory - e.g. /projects or /devsite.local etc...
For more info on Apache see here: https://httpd.apache.org/docs/current/mod/core.html#directory
The 'Options' are typical .htaccess directives - change as needed
The 'AllowOverride All' gives access to the /home folder and everything under it
The 'Require local' makes sure only localhost / 127.0.0.1 has access to folder and files under /home
Hope this helps :D

How to configure wordpress application in subdirectory with simple php application using .htaccess / Apache2?

I want to configure a Wordpress application with a simple php application. The directory structure of the application is as follow :
Root directory : /var/www/demoApp/
Wordpress directory : /var/www/demoApp/wordpress/
Here i want to access the wordpress application using route http://BASE_URL/wordpress. But i am not able to configure the htaccess file. All the php pages under /var/www/demoApp/ directory are working fine using url http://BASE_URL/. While wordpress files are not being loaded correctly.
Here is my Apache configuration block :
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster#localhost
DocumentRoot /var/www/demoApp
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/demoApp>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What should be the .htaccess file?
My configuration:
domain: test.localhost
wordpress url: test.localhost/wordpress
.htaccess in the wordpress folder:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
Apache settings for the subdomain (Wamp server under windows)
<VirtualHost *:80>
DocumentRoot "e:\Sync\www\test"
ServerName localhost
ServerAlias test.localhost
<Directory "e:\Sync\www\test">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</Directory>
</VirtualHost>
I had this issue while trying to modify a few absolute paths to relative paths. The problem was that I left an extra / at the start of the relative path.
Correct Code:
About
<!--The link goes to to http://BASE_URL/wordpress_subdirectory/about-->
Errorneous code:
/About
<!--This href is relative to the 'Root'. It goes to http://BASE_URL/about-->

Apache2 - Directory URL without trailing slash redirecting to different URL

I'm having a problem auto loading index.php in subdirectories with Apache2.
This is what I see in browser console when connecting:
GET http://example.com/login HTTP 301 Moved Permanently
GET http://10.0.3.10/login/
Connection Timed Out
When I type in http://example.com/login/, it works as intended. Also,
Root directory redirects to index.php properly.
I'm fairly new to this topic, would appriciate any help.
Default virtual host settings:
#NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName example.com/
ServerAlias www.example.com/
DocumentRoot /var/www/example.com/
<Directory />
AllowOverride All
DirectoryIndex index.php
</Directory>
<Directory /var/www/example.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
...
httpd.conf:
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
No .htaccess file used.
I think your request is handled by a virtualhost with no ServerName, and at startup httpd probably warns you that it can't find a default hostname for your local IP (10.0.3.10)
Try removing the trailing slashes from your ServerName and ServerAlias. You will need to do even more if your ServerName or ServerAlias matches the systems hostname -- namely adding a dummy ServerName to your default vhost.

Can't configure virtualhosts for XAMPP+Symfony

I keep trying to configure it so that the domain symfony.local would link to the app_dev.php, but I also keep getting forwarded to the xampp page.
My hosts file is:
127.0.0.1 symfony.local
My httpd-vhost is:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName symfony.local
DocumentRoot "C:\xampp\htdocs\testAS\web"
DirectoryIndex app_dev.php
<Directory "C:\xampp\htdocs\testAS\web">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
I'm using Windows 8. Appreciate any feedback.
I assume it's a fairly recent version of xampp? There is a new directive "Require local" that popped up a few years ago. I remember being stumped by it.
<Directory "C:/home/ahundiak/zayso2016/cerad3/web">
## Options Indexes FollowSymLinks
AllowOverride All
Require local ## Add This
</Directory>
<VirtualHost *:80>
ServerName local.api.zayso.org
DocumentRoot "C:/home/ahundiak/zayso2016/cerad3/web"
</VirtualHost>
I am not an expert on configuring this. The above works for me using the Symfony 2 .htaccess file.
may be it issue of your hosts file entry of symfony.local and local ip address or may between them only TAB(on keyboard) require ...
OR if above answer not work follow below
please follow this link Click Here it help you solve your issue of not show symfony project

Categories