Laravel 7 - server only serving root page - php

I'm trying to serve a Laravel 7 site on my server, built using a Raspberry Pi and storing the files on an external hard drive.
I cloned my Laravel project from Github, ran composer install and after a bit of fiddling and configuration, the root page loaded. However, the root page is the only route that will load. Neither my own routes nor the auth routes generated by Laravel work. Any attempt to access a different route leads to a 404 error thrown by Apache on my server.
Here is my VirtualHost config file in Apache:
<VirtualHost *:80>
ServerName myurl.tld
ServerAdmin myemail#example.com
DocumentRoot /mnt/external/public_html/MyProject/public
<Directory /mnt/external/public_html/MyProject>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Not sure what is going on here. The same thing happens with projects generated on the server as well as the cloned project.
Permissions on /mnt/external/public_html/MyProject are set to 775 all the way up to external, and the whole path is owned by the www-data user.

Try the below VirtualHost config
<VirtualHost *:80>
ServerName myurl.tld
ServerAdmin myemail#example.com
DocumentRoot /mnt/external/public_html/MyProject/public
<Directory /mnt/external/public_html/MyProject/public>
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Restart Apache.

Related

i want to host a php site on apache2 on port 82. how will be the virtual host config file? I am new

<VirtualHost *:82>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerAdmin abc#gmail.com
DocumentRoot /var/www/html/crm_new
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName air.in
ServerAlias www.air.in
</VirtualHost>
this is my config file. but it not loading index.php
I would suggest:
Removing any directives you have listed twice (eg. DocumentRoot, ErrorLog, CustomLog)
Remember that every time you change this file, you need to restart Apache.
When you restart Apache, pay attention to any warnings/errors that display, as these will tell you if you if there are any problems.
Have a look at the log file you specified in ErrorLog ("tail /path/to/log/file") to see if any problems are listed.
If any of the log files you listed don't exist, you may need to create them first and make sure they are writeable by the Apache user.
Before trying to get php working, try getting a static html file working. This way you can get the Apache and port issues resolved first and then get it working with php.

Need some assistance with my apache2 site config file

I'm trying to get apache2 to point to a PHP based application (word press in this case but the config needs to be generic enough to work for any php application).
and it either displays some basic HTML file access page or errors with "You don't have permission". I don't really know apache and I don't know PHP at all. Here's my current site_config file as it stands(with retractions replaced with ):
<VirtualHost *:80>
ServerAdmin <app_user>#localhost
ServerName amazonaws.com/<app_name>
ServerAlias *.amazonaws.com/<app_name>
DocumentRoot /home/<app_user>/<app_location>/staging/current
<Directory /home/<app_user>/<app_location>/staging/current >
AllowOverride All
Options -Indexes
Order allow,deny
Allow from all
</Directory>
LogLevel error
ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>
I would also like to make it so you can have multiple websites on the same box but I'm not sure how to change the VirtualHost arg *:80 to account for that, I just get loads of ignoring errors.
I also have the following line in my apache2.conf:
DirectoryIndex index.php index.html
Folder permissions are set to 0755 for all files & folders in the project directory
output of apache2 -v:
Server version: Apache/2.4.7 (Ubuntu)
P.s. I know nothing about PHP and very little about apache2 so for this, speak to me as a total noob.
To solve The first problem I had to change the following lines:
Order allow,deny
Allow from all
to:
Require all granted
this finally allowed apache to allow users access to the folders, the second thing was to add an alias:
Alias /<app_name> "/home/<app_user>/<app_location>/staging/current"
and it started working as expected so now my site config looks like:
Alias /<app_name>"/home/<app_user>/<app_name>/<app_environment>/current"
<Directory "/<app_name>"/home/<app_user>/<app_name>/<app_environment>/current">
AllowOverride All
Options -Indexes
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot "/<app_name>"/home/<app_user>/<app_name>/<app_environment>/current"
ErrorLog "/var/log/apache2/<app_name>.error_log"
CustomLog "/var/log/apache2/<app_name>.access_log" combined
</VirtualHost>

Configure htaccess to symfony project

I have a hosting with my personal project in Symfony2 installed it inside a folder "public_html", then when I want to access to my project I have to write the next
url: "mydomian.net/myprojectSymfony/web/", instead of "mydomain.net".
If I just write mydomain.net the server shows me the directory "public_html" with all folders inside him. How can I write my .htaccess file to solve this problem?
I tried with Redirect 301 but I don't know if the right way.
In my opinion the best approach is to configure your apache vhost as explained there:
http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html
<VirtualHost *:80>
ServerName mydomain.net
ServerAlias www.mydomain.net
DocumentRoot /var/www/myprojectSymfony/web
<Directory /var/www/myprojectSymfony/web>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

How to fix 403 error when i am trying laravel 5 project

I am trying to run the laravel 5 project using linux-mint and apache. My conf of virtual host /apache2/sites-available/mysite.local.conf
<VirtualHost *:80>
ServerName mysite.local
ServerAlias www.mysite.local
DocumentRoot /home/kolya/workspace/mysite/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Rights issued a folder storage,
.htaccess is set defaulted laravel5,
I have error 403
Make sure that /home/kolya/workspace/mysite/public has set it's permissions to be readable by the user group where the apache engine belongs.

Laravel virtual server routing doesn't work

I have installed newest Laravel on my Apache2. I run in Terminal
php artisan serve --port=8080
And It works. I have sub-pages and everything I need. But I want to have access without run this command.
I have next mylaravel.com.conf file in /etc/apache2/sites-available
<VirtualHost *:80>
ServerName mylaravel.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/mylaravel/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
My Laravel files is of course in /var/www/mylaravel. In this configuration mylaravel.com works, but when I try for simple mylaravel.com/auth/register Apache return
When I used php artisan [...] this works fine. How can I fix it?
I had this same problem a while ago. From here:
If you don't have AllowOverride set to All, your Laravel .htaccess file (/public/.htaccess) won't be able to enable mod_rewrite, and your routes won't work.
Try adding the following to your <VirtualHost> block:
<Directory "/var/www/mylaravel/public">
Options All
AllowOverride All
Allow from all
</Directory>
So all up you'd have:
<VirtualHost *:80>
ServerName mylaravel.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/mylaravel/public
<Directory "/var/www/mylaravel/public">
Options All
AllowOverride All
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I found something. I added Sadurnias code and run in Terminal
sudo a2enmod rewrite
sudo service apache2 restart
Of course I changed chmod of /var/www to 755.
It's working fine, only when I run mylaravel.com/css FireFox doesn't end this request, but others is fine.

Categories