fresh LAMP install on AWS EC2, cannot access Laravel internal links - laravel

The out-of-the-box welcome.php works well giving me the home page, yet internal links such as login or register return a 404.
I do not get any apache error in the log.
I've read many questions here that relate to my issue with no avail.
From googling this issue, I'm assuming it has to do with the conf file, but maybe im wrong, so feel free to ask for more info.
conf:
<VirtualHost *:80>
ServerAdmin webmaster#test
DocumentRoot /var/www/testing/public_html/public
serverName www.example.com
serverAlias example.com
<Directory /var/www/testing/public_html/public>
AllowOverride All
allow from all
options +Indexes
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
If I'm not getting any errors, how can I debug this? I would be happy to learn in the process.

The answer was that I had to execute sudo a2enmod rewrite.

Related

Ubuntu Error Invalid command 'ServerAdmin', perhaps misspelled or defined by a module not included in the server configuration

I am trying to upload my laravel project on aws by installing ubuntu. I pretty much already installed everything I have to but after writing .conf inside the sites-available, and reloading the apache2.service. There is an error indicating that the ServerAdmin is misspelled.
domain.conf
<VirtualHost *:80>
SeverAdmin ...#gmail.com
ServerName domain.com
SeverAlias www.domain.com
DocumentRoot /var/www/domain/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/domain>
Require all granted
AllowOverride All
Options Indexes Multiviews FollowSymLinks
</Directory>
</VirtualHost>
Sorry about that everyone! That was a simple spelling mistake

Cannot access MapServer when using Let's Encrypt HTTPS on Apache2

I have recently built a website using MapServer for an academic course. The course is finished, but I wanted to continue developing it. The website is using Apache/2.4.53 (Debian), running on Debian 11, set up as a Virtual Host.
I have recently installed https using Let's Encrypt.
The website works when using either http (http://kina3.net/) or https (https://kina3.net/), so I know that https is working.
I can serve up a example file through MapServer when using: http://kina3.net/cgi-bin/mapserv?map=bluemarble&mode=map
However when I try using https://kina3.net/cgi-bin/mapserv?map=bluemarble&mode=map it generates the following error:
msLoadMap(): Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation failed.
My research (MS_DEFAULT_MAPFILE_PATTERN validation failed) suggests that problem is because "The map location is missing or wrongly formatted".
However in the apache2 VirtualHosts config file both references point to the same mapfile. See extract from site configuration file below:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName kina3.net
ServerAlias www.kina3.net
# Redirect permanent / https://kina3.net
DocumentRoot /var/www/kina3.net
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnv bluemarble "/var/www/map/bluemarble.map"
</VirtualHost>
### ERROR LOGS IN /var/log/apache2/access.log ###
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName kina3.net
ServerAlias www.kina3.net
DocumentRoot /var/www/kina3.net
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /****
SSLCertificateKeyFile /****
Include /****
SetEnv bluemarble "/var/www/map/bluemarble.map"
</VirtualHost>
What am i missing?
I managed to fix this problem ... and it's not glorious. Turns out that I had two VirtualHosts files running, with the other one taking precedence. So whatever changes I made in the VH example above would have no effect as the other took precedence.
So if you find yourself with a similar problem to me, try running:
sudo apachectl -S
and see what the VirtualHost configuration: is pointing to.
Also, once you post a link to your own website on StackOverflow, expect regular visits from web scrapers plus various shady IP addresses.

Laravel Framework 5.7.29 blank main page

I was having problems with a blank page in my first Laravel project. I'm currently watching the Laravel Framework course on YouTube. This is Lesson 1 called "How to install the Laravel Framework". I checked it out laravel.com for the requirements section and made sure I have all of them. After that, I installed Composer 2.0.13. Using it, I installed Laravel Framework 5.7.29. I got reports that some packages are deprecated. They were about changing the color on the console.
The next step was to change "/etc/hosts". I added the line 127.0.0.1 poligon.local The next step was to change "/opt/lampp/etc/extra/httpd-vhosts.conf". I added the lines:
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "/home/stas/projects/poligon.local/public"
ServerName poligon.local
ServerAlias www.poligon.local
<Directory /home/stas/projects/poligon.local/public>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/poligon-error.log"
CustomLog "logs/poligon-access.log" common
</VirtualHost>
Then I wrote $ sudo /opt/lampp/lampp start to start the local XAMPP server. And I have a blank page on the "poligon.local/". When I started php artisan serve, I had access to "poligon.local:8000", and there is the Laravel home page. But the author of the video got access to the "poligon.local" without php artisan serve. What do you think is my mistake?
Update: If I create /public/index.html I will get this html page.
Update2: I was experimenting now with php artisan serve --host 127.0.0.1 --port 80 and found that with the XAMPP server enabled, this socket is already in use. But when the server is turned off, I manage to run artisan command with these connection settings. As I understand it, XAMPP occupies this socket, but for some reason can't handle it on its own.
Update3: I checked it out /public/index.php the whole file and found out that it is being executed. Up to the line $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); There is no continuation after it.
Define the site you added in hosts file in the Virtual Host route.
Change this
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "/home/stas/projects/poligon.local/public"
ServerName poligon.local
ServerAlias www.poligon.local
<Directory /home/stas/projects/poligon.local/public>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/poligon-error.log"
CustomLog "logs/poligon-access.log" common
</VirtualHost>
to this
<VirtualHost poligon.local:80>
ServerAdmin admin#example.com
DocumentRoot "/home/stas/projects/poligon.local/public"
ServerName poligon.local
ServerAlias www.poligon.local
<Directory /home/stas/projects/poligon.local/public>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/poligon-error.log"
CustomLog "logs/poligon-access.log" common
</VirtualHost>
Notice that i have defined the host URL you defined in the virtual host route
From <VirtualHost *:80> to the url you defined <VirtualHost poligon.local:80>
What this * does is it gets all the requests and direct it to XAMPP homepage which is default.

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.

setting up laravel redirects to xampp

Hi I'm setting up Lavarel using a book called Laravel Starter by Shawn McCool (Packt Publishing), I've cloned the respiratory via github and have got as far as configuring my hosts file and setting up my virtual hosts. As below:
127.0.0.1 laravel.dev
<VirtualHost *:80>
ServerName laravel.dev
DocumentRoot C:/xampp/htdocs/laravel/public
</VirtualHost>
However if I visit the link http://laravel.dev I am redirected to the XAMPP page and I should be expecting the laravel splash page.
Any ideas of what I have done wrong? The document root is pointing to the correct direction as it is installed onto my localhost.
Greatly appreciate any help.
In the new xampp you should use something like this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/laravel/public"
ServerName laravel.dev
ServerAlias laravel.dev
ErrorLog "logs/laravel.log"
CustomLog "logs/custom.laravel.log" combined
<Directory "C:/xampp/htdocs/laravel/public">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
edited with the right serverName. This is my own virtual host file. I also use it for Laravel.
Go to C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf and enable virtualhost by removing the #sign in front of Include conf/extra/httpd-vhosts.conf
Albeit an old question, I found a solution to this the hard way. Do something like this:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
<Directory "C:\xampp\htdocs">
Require all granted
</Directory>
</VirtualHost>
This would enable the XAMPP Stack to point to the localhost correctly (I guess?)
And of course don't forget your drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 laraveltest.dev
Your configuration seems fine. Just don't forget to add these two.
<VirtualHost *:80>
ServerName laraveltest.dev
ServerAdmin laraveltestp#localhost.com
DocumentRoot "D:/Workspace/Projects/Playground/laravel-test/public"
#SetEnv APPLICATION_ENV "development"
<Directory "D:/Workspace/Projects/Playground/laravel-test/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
In new Laravel you need to change your Apache Vhost file to stop this redirection from server. For complete guide about how to change vhost file and run your first laravel web app go to following link : <https://answerdone.blogspot.com/2018/01/how-to-solve-laravel-xampp-dashboard.html>
probably, it is because xampp and laravel run on the same port. If so, try changing port before you start running laravel project by this command
php artisan serve --port=8080
*8080 can be changed to any other number port you want
Do you have NameVirtualHost enabled?
try uncomment #NameVirtualHost *:80 and see if it helps.
I used localhost/appName/public/. This is the only way it worked for me.

Resources