Laravel wrong view path - php

When i update a view file i get the view file from the old path.
I have a domain that points to an IP (vps) where i have a laravel installation.
lets call this 123.com and when i visit the domain i get the old view path, a path to the folder where i copied the laravel installation from.
This folder is nammed var/www/111.com/
After the copy i put the source in var/www/123.com/
When i acccess 123.com i get view files from var/www/111.com/ instead of var/www/123.com/
My .conf is like this in the sites-available i have restarted apache many times with sudo service apache2 restart no luck.
<VirtualHost *:80>
ServerName 123.com
ServerAlias www.123.com
ServerAdmin 123#123.com
DocumentRoot /var/www/123.com/public_html/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The direect IP .conf looks like this.
<VirtualHost *:80>
ServerName 111.111.dk
DocumentRoot /var/www/111.111.dk/public/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/111.111.dk/public/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Is the problem with my conf setup in apache2/vps?
I have removed the .conf file with sudo a2dissite 111.111.dk.conf and restarted with sudo /etc/init.d/apache2 force-reload no luck there.
I have also tried with
php artisan route:clear
php artisan view:clear
No luck there.
Kind regards.

I finaly figured it out, it was my config file in laravel, bootstrap/cache/config.php that had wrong paths.
so i ran php artisan config:cache and after that everything works :)
Thanks for all your help.

Try clearing the caches - via the terminal:
php artisan route:clear
php artisan view:clear

Related

Laravel artisan serve problems

I've just installed Laravel on my vps, but I have some problems when running the command php artisan serve. It tells me that the application is running on https://127.0.0.1:8000. That means that it is running on my vps. But when I go to my vps in the browser I get this:
I've searched the whole internet for a solution and find one which tells me to create a new file: /etc/apache2/sites-available/laravel.conf and put this code in it:
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot /var/www/html/development/public
ServerName subdomain.mywebsite.nl
<Directory /var/www/html/development/public>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Btw, The ServerName is changed to my own website but I inserted an example here for privacy.
I also have changed the A record of the subdomain to the ip address of my vps.
After all I need to run the commands sudo a2ensite laravel.conf and sudo a2enmod rewrite
Ok, Now I need to restart my apache with sudo systemctl restart apache2.
But when I go to my subdomain is see this:
What am I doing wrong in here?

Laravel 7 - server only serving root page

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.

How can I run my Laravel project without cmd command "php artisan serve"?

<VirtualHost *:80>
ServerAdmin webmaster#hujjaj.dev
DocumentRoot "C:\xampp\htdocs\hujjaj_app_new\public"
ServerName hujjaj.dev
ErrorLog "logs/hujjaj.dev-error.log"
CustomLog "logs/hujjaj.dev-access.log" common
I am doing so in my virtual host file and update 127.0.0.1 hujjaj.dev then i restart XAMPP and after that I navigate to localhost/hujjaj.dev but showing 404|Not Found.
Please try the following
<VirtualHost 127.0.0.2:80>
DocumentRoot “D:\laravel-gkb\public”
DirectoryIndex index.php
ServerName laravel-gkb.test
<Directory “D:\laravel-gkb\public”>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
Then add the save domain in your hosts file
127.0.0.2 hujjaj.dev
Refer this for more details : link
Yes, There is another way to run laravel project, with following command..
php -S 127.0.0.1:8001 server.php
This will run your application at 127.0.0.1:8001 mentioned address.
Note: laravel default entry point is server.php thats why we mentioned it. other wise it will be index.php

not able to access some routes in laravel

I am getting a 404 when trying to access any other routes except '/' in my laravel project
my dhavalchheda.conf file is as follows
<VirtualHost *:80>
ServerAdmin admin#dhavalchheda.com
DocumentRoot /var/www/html/dhavalchheda/public/
ServerName dhavalchheda.com
ServerAlias www.dhavalchheda.com
<Directory /var/www/html/dhavalchheda/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/dhavalchheda.com-error_log
CustomLog /var/log/apache2/dhavalchheda.com-access_log common
</VirtualHost>
my laravel folder structure is
dhavalchheda -> full laravel project
I am not able to understand the mistake so please assist
I think you have to enable your rewrite module of apache service. So try with below command to run your all other routes:
sudo a2enmod rewrite
and restart the apache service:
sudo service apache2 restart
Hope this works for you too.
Follow this link
Follow these steps will help you.

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