laravel after change domain dont work links - laravel-5

Laraval project was in development mode on public IP without domain. Everything worked perfectly, but after changing DNS in my domain to public IP, the project laravel works only on the main page and all links https://mainpage.com/links show The requested URL was not found on this server.
all commands used, without help
php artisan cache:clear
php artisan config:clear
composer dump-autoload
php artisan route:cache
.env changed APP_URL=http://mainpage.com
when i change APP_DEBUG=true dont work
Any suggestion ?

found solution, problem was with apache virtualhost conf file.
missing:
<Directory /home/user/projects/laravel_project/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>

Related

laravel php artisan serve command works but localhost url not working in ubuntu 18.10

Login route using localhost/project/public/login url shows error:
The requested URL /test/public/login was not found on this server.
Apache/2.4.34 (Ubuntu) Server at localhost Port 80
But using php artisan serve command it works perfectly fine.
What could be wrong?
solved:
OS: ubuntu 18.10
/etc/apache2/apache2.conf
add this line into this apache2.conf file:
<Directory /var/www/html/> AllowOverride all </Directory>
There are many reasons why your local host is not working.
Following could be one of the reasons:
1.Make sure that in /etc/apache2/sites-available/your-conf.conf file contains these things :
ServerName www.your-url.test
ServerAlias your-url.test
ServerAdmin webmaster#localhost
DocumentRoot /your-path/your-project/public
<Directory /your-path/your-project>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Problem could be with your PHP version. In our machine, there are two php:
1. For CLI(command line interface)
2. For apache server
Your laravel application may require higher or lower version of php in apache server.
For fixing that either update your php version in apache server to your required version or either setup the fpm for your projects. Then your localhost will start working.
There could be an error in your laravel application.
For checking that use command:
sudo tail -f /var/log/apache2/error.log
After hitting this command you'll see the errors that your laravel application is throwing.
But since your laravel application is running fine using serve command, so most likely problem in your case will be because of different PHP versions in CLI and apache server(front-end).
So you should either setup fpm or either upgrade or downgrade the apache server php version.
I had the same problem and i fixed it by setting up the fpm for my projects.
Thanks
The most common error in this situaion is related to unable mod_rewrite in apache do this :
sudo a2enmod rewrite
systemctl restart apache2

Laravel MAMP Vhosts issue

Have the below config in vhosts. Its always returns 500 error when i run it through MAMP. Not sure what is wrong. Stopped mamp and ran it using valet. laravel website runs successfully. Permissions of bootstrap/cache and storage looks good. Error logs are empty cant debug and debug setting set to true in .env file. Only access log exists with 500 error. Below is the vhosts config that i have for MAMP. Other website in vhosts file work.
<VirtualHost *:80>
ServerName elearn.localhost
ServerAlias elearn.localhost
DocumentRoot "/Users/user1/code/elearn/public"
ErrorLog "/Users/user1/logs/elearn.localhost-error_log"
CustomLog "/Users/user1/logs/elearn.localhost-access_log" common
<Directory "/Users/user1/code/elearn/public">
DirectoryIndex index.php
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
Satisfy Any
</Directory>
</VirtualHost>
What version of Laravel are you using, if it is 5.6 make sure you're running PHP at at least 7.1 in MAMP - fallen foul of that myself a couple of times?
Alrighty, checklist:
is MAMP running under your user?
make sure it's not permissions issues: commit, chmod 777 on project root, try again, if you still get 500 then it's ruled out
stop valet, restart mamp, just to be sure no services parts are conflicting
remove the vendor folder and composer install again, better be safe then sorry
lastly, add a dd() to any route and test it, if you see the dd, means it's not related to mamp, valet or laravel, probably config, driver or other issues.

deploying laravel error on shared host

I am deploying my laravel 5.4 project on a shared host using subdomain
I installed composer, changed paths of index.php , vendor paths , DB host, username , etc..
I am getting the following error
Fatal error: Uncaught UnexpectedValueException: There is no existing directory at "/storage/logs" and its not buildable: Permission denied in
/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:171
I tried the following commands :
php artisan cache:clear
php artisan clear-compiled
sudo chmod -R 777 storage/ -R
but (composer dump-autoload ) gives an error because php -v is 5 although I am choosing it to be 7 in the cpanel
I tried also setenforce 0
but nothing happened .. can any one help please??
php artisan route:clear
php artisan config:clear
php artisan cache:clear
works for me!
This is a Duplicate of: see here
Check in laravel root folder your .env file :
a) Check if you have .env file , if not copy-paste .env.example to .env
b) APP_DEBUG = true (when deploying to a server, after checking your app - change on false)
c) APP_KEY = (these must be empty)
d) Save .env file
e) Run php artisan key:generate
f) Open your website (all another errors server return)
Run composer install
This is my solution for apache2 on Ubuntu 20.4
I assume you already did the Steps from phwt & Taras. These are still necessary.
You need to change:
ServerName to your IP Address or Domain
DocumentRoot to the Path to your public Laravel directory
RewriteCond %{SERVER_NAME} = to your IP Address or Domain
File: /etc/apache2/sites-available/laravel.conf
<VirtualHost *:80>
ServerName www.mylaravelproject.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/laravel/public/
<Directory /var/www/laravel/public/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mylaravelproject.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
After Saving this run:
sudo a2ensite laravel.conf
sudo systemctl restart apache2
(Optional, but recommended) If you want to use an SSL Cert do:
sudo certbot
and follow the instructions

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>

Laravel 4 pretty urls

Ok I was working on a project using laravel 4. I never bothered setting up vhosts for pretty urls. I was just using localhost/myapp/public...
Everything was working fine. Now I have decided to set up vhosts. And I'm getting the following error when $user->save(); is called:
ReflectionException
Class confide.repository does not exist.
Auto-loading is not working why??
What am I forgetting??
Here is my vhost.conf set up:
<VirtualHost 127.0.0.6>
DocumentRoot "C:\xampp\htdocs\myapp\public"
ServerName myapp.dev
<Directory "C:\xampp\htdocs\myapp\public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
</Directory>
</VirtualHost>
And my hosts setup:
127.0.0.6 myapp.dev
UPDATE: when I configure vhosts with: ServerName myapp instead of ServerName myapp.dev
It works great, however I want the .dev so that that I can use facebooks api.
Any help greatly appreciated.
I see you're on a Windows machine.
VHosts (Windows) related:
I'm using vhosts myself. Here's a copy of what I'm using in my WAMP Environment:
# Virtual Hosts Settings
NameVirtualHost *:80
<VirtualHost *:80>
ServerName appdomain.local
DocumentRoot "D:/Program Files/wamp/www/appname"
ErrorLog "D:/Program Files/wamp/www/appname/server_logs/errors.log"
TransferLog "D:/Program Files/wamp/www/appname/server_logs/access.log"
</VirtualHost>
…and in the hosts file I use:
127.0.0.1 appdomain.local
Try these settings and see if it works.
BTW.: Why are you using 127.0.0.6? Localhost is equal to 127.0.0.1... To use another IP some other settings need to be set / adjusted in Windows.
Laravel 4 related:
Have you checked the User model and composer.json file?
Did you follow the necessary installation instructions on https://github.com/Zizaco/confide#quick-start ?
Double check that.
Also look at this: https://github.com/Zizaco/confide/issues/9
About my App/Config/app.php config file:
I've setup a "production" and "local" app config. The main differences for the local version are:
- debug => true (production => false)
- url => THE_APP_LOCAL_DOMAIN (production => THE_APP_DOMAIN)
Everything else is set in the production config.
Providers example:
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...,
),
Aliases example:
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Carbon' => 'Carbon\Carbon',
...,
),
I always update the autoload (> composer dump-autoload) on:
namespace changes
composer.json edits
composer updates (e.g. after adding a new package from like packagist)
and config changes, just to be save
Also try the following commands: (don't forget to cd to the project directory first)
composer dump-autoload
php artisan dump-autoload
php artisan cache:clear

Resources