Apache 403 forbidden when visiting website - vagrant

I'm running Vagrant and Virtualbox on my macOS Catalina. Installed latest versions of both software and I created a vagrant file with PuPHPet and used Apache as webserver. Ran vagrant up and all fine.
I've added a vhost like I allways do and have running on a different Mac (with macOS Mojave).
However, if I access the website on de virtual machine, I get a 403, access forbidden.
The default host that is setup, with html, seems to run fine. But this is not running php, only html.
My vhost file:
<VirtualHost *:80>
ServerName www.domain.test
## Vhost docroot
DocumentRoot /var/www/domain
## Directories, there should at least be a declaration for /var/www/html
<Directory "/var/www/domain/public">
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Require all granted
<FilesMatch "\.php$">
Require all granted
SetHandler proxy:fcgi://127.0.0.1:9000
</FilesMatch>
</Directory>
## Logging
ErrorLog "/var/log/apache2/default_vhost_80_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/default_vhost_80_access.log" combined
## Custom fragment
</VirtualHost>

Try after enabling php mods, for my php5 project, I have used:
a2enmod php5
a2enmod headers
a2enmod rewrite

Related

Virtual Host not working on Mac OS (MAMP)

OS: Mac OS
Mamp 6.6 version
The virtual host is not working, when I open the host I get an error:
Not Found
The requested URL was not found on this server.
looked at a lot of articles on topic of installing virtual hosts and it seems that I did everything right
My hosts file:
enter image description here
The virtual hosts file is included in configuration file /Applications/MAMP/conf/apache/httpd.conf:
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
My httpd-vhost-conf:
NameVirtualHost *:80
<VirtualHost *>
ServerName localhost
DirectoryIndex index.html index.htm index.php
DocumentRoot "/Users/danilbondarev/Projects/php"
<Directory "/Users/danilbondarev/Projects/php">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride None
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName localhost
DirectoryIndex index.html index.htm index.php
DocumentRoot "/Users/danilbondarev/Projects/php/hybrid-main"
<Directory "/Users/danilbondarev/Projects/php/hybrid-main">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride None
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
Mamp->Preferences->Server->Document Root:
enter image description here
Error screen:
enter image description here
I want to note: I always restart apache and MAMP when I make any changes to the config files. I also tried to give directories permissions for Apache and it didn't help, although obviously this wasn't the problem
Tried these solutions:
Virtual hosts not working on MAMP
MAMP setting virtual host does not working

Laravel routes behind reverse proxy generating wrong url

Let me explain my situation. I have a server that host five sites in www/html folder using the Apache 2 server but all of them run on PHP 5.4. I was asked to upload a system on this server, but it uses PHP 7+. The system is dockerized, so it contains their own container running php 7. So, I was thinking in use a reverse proxy to redirect the requests to docker container. Ok, I managed to do it. My container is running and I can access the system in production. But the system is broken, the static files and the routes are not being well formed.
This image shows the error in console. I just hid the IPs.
https://i.stack.imgur.com/5dvVe.png
This my Apache configuration in sites-available folder. I just added the Location tag to redirect for my container.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
LimitRequestLine 16382
LimitRequestFieldSize 16382
Timeout 12000
AddDefaultCharset ISO-8859-1
SetEnv no-gzip 1
<Directory /var/www/html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
<Location "/educar">
ProxyPreserveHost On
ProxyPass "http://localhost:8001/educar"
ProxyPassReverse "http://localhost:8001/educar"
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
This is my first question here, so I just apologized for any mistake.

How to implement laravel in ubuntu?

I just installed an Ubuntu server on virtualbox and moved my laravel project to it's /html folder. After configuring Laravel.conf and my server, this is what I get to see:
It does not show the public folder, however I can visit it through /public, but no links are working. This is my Laravel.conf:
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot /var/www/html/public
ServerName 192.168.1.104
<Directory /var/www/html/public>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Anyone knows what miskake I'm making?
For your first problem the public folder is not showing but you can visit it. this is because the .htaccess file is disabling directory listing withing public folder
For your second problem which is you are unable to visit laravel index page links this is because laravel rewrite url rules are not working and to enable them you sould enable apache2 rewrite module as follow :
sudo a2enmod rewrite
then restart your webserver
sudo systemctl restart apache2
now your problem should be fixed.

How to set Aliases or VirtualHost to run a laravel project on Apache2

I'm starting to learn how to set up a lamp on a vps, and i'm trying to run a laravel project.
This is my 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
Alias /laravelproject /var/www/laravelproject/public
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
I'm trying to access using the /laravelproject and it works cause i'm redirected to a login page ip/laravelproject/login (like I set using the middleware for not logged users and it works on my local homestead virtual machine). But i got a 404 file not found error. Not a pretty designed laravel one, but a raw and ugly server error
Not Found
The requested URL /laravelproject/login was not found on this server.
Apache/2.4.10 (Ubuntu) Server at '' Port 80
Of course i don't have any laravelproject.com domain to set up, i want to access it simply with my_server_ip/laravelproject.
How can i set up a virtualhost or an alias to run it with all the routes working?
You could also try enabling apache mod-rewrite if not enabled yet.
sudo a2enmod rewrite
sudo systemctl restart apache2
You'll need to make sure the /var/www/laravelproject/public directory is set to AllowOverride All (which I believe you have taken care of by setting /var/www to All). Then make sure the .htaccess file in your public directory is correctly set up: https://github.com/laravel/laravel/blob/master/public/.htaccess
this is because Apache is looking for /public/login/index.html which is not a file. Laravel's .htaccess redirects these requests appropriately, but it has to be in your public folder and Apache has to AllowOverride
edit:
<Directory /var/www/laravelproject/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>

Magento install ubuntu

Im having problem installing Magento on ubuntu. I've created and a2ensite a site with a documentroot that points to the "installation files" I've dowloaded from magento SVN repository. I've testes localhost and it works. This is my virtualhost file under sites-available and its present in sites-enabled aswell.
My virtual host:
<VirtualHost *:80>
ServerAdmin magento#localhost.com
ServerName magento.localhost.com
DocumentRoot /srv/www/magento_dev/public_html
<Directory /srv/www/magento_dev/public_html/>
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /srv/www/magento_dev/logs/error.log
LogLevel warn
</VirtualHost>
The problem is that I can't connec to the site when I type magento.localhost.com
I understand that there are a lot of things that can be wrong here but I've doubled checked everything e.g. the doucment root is there at /srv/www/magento_dev/public_html and the site is enabled and apache2 is reloaded.
The url you are using seems to be wrong. Try with http://localhost:80/magento.

Resources