Laravel artisan serve problems - php

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?

Related

Why isn't apache2 redirecting to https, or acting how I expect with mediawiki?

I have a mediawiki site on Ubuntu 14.04, that is working perfectly, and is housed at /var/www/html
I'm trying to get https setup on the server, and I haven't been able to get that done yet. Here's my current port 80 configs, and I'll show what I'm trying below that.
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerName mywiki.com
ServerAlias http://mywiki.com
DocumentRoot /var/www/html
</VirtualHost>
/var/www/html/LocalSettings.php
#this is the only relevant line...I think.
$wgServer = "http://mywiki.com"
The changes I'm making, in order, are below
1. Change $wgServer value to //mywiki.com
2. Edit /etc/apache2/sites-available/default-ssl.conf to the following
<VirtualHost _default_:80>
ServerName mywiki.com
Redirect permanent / https://mywiki.com
</VirtualHost>
<VirtualHost _default_:443>
ServerName mywiki.com
ServerAlias https://mywiki.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/my.crt
SSLCertificateKeyFile /etc/apache2/ssl/my.key
</VirtualHost>
3. Stop apache from using the old 000-default.conf file by running sudo a2dissite 000-default.
4. Start using the new ssl default file by running sudo a2ensite default-ssl.
5. Restart Apache2 sudo /etc/init.d/apache2 restart
At this point, apache2 restarts correctly, and there are no errors from the output or in the error.log. However, when I go to the site by typing mywiki.com it doesn't redirect me to https, and now it shows the :80 section of the site as the Index of / html/.
When I try to manually go to https://mywiki.com, I get a page not available, like it's not even trying.
Where am I going wrong?
This was a silly solution, but I imagine on a product like mediawiki, I won't be the last to make this mistake.
I never enabled the ssl module
sudo a2enmod ssl
I went through tens of tutorials on how to setup ssl on mediawiki, and none of them mentioned this. It's pretty obvious if you work on lots of websites, but I don't, and hopefully this helps someone in the future.
You are missing a ServerName. This might be it. Could you attempt this configuration:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mywiki.com
Redirect permanent / https://mywiki.com
</VirtualHost>
<VirtualHost _default_:443>
ServerName mywiki.com
ServerAlias www.mywiki.com
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/my.crt
SSLCertificateKeyFile /etc/apache2/ssl/my.key
</VirtualHost>

Laravel wrong view path

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

How to point default virtual host in Ubuntu 14.04 LTS

I recently purchased linode hosting where i did successfully hosted a website. And its opening by domain-name.com and also when i enter server IP it opens default /var/www/domain-name.com/public_html
Now i want to host another site in it and created another virtual host with domain-name-2.com and enabled that and did reload my apache server.
Now when i enter again the server IP in browser like http://11.22.33.44/ it shows the first website (/var/www/domain-name.com/public_html) i hosted by default.
But i want to point some other folder so that when i hit http://11.22.33.44 it will show that folder's index.html not /var/www/domain-name.com/public_html
How to do that?
Not sure if I understand correctly, you want
http://11.22.33.44/ -> /var/www/domain-name.com/some_other_folder
http://domain-name.com/ -> /var/www/domain-name.com/public_html
Am I correct?
If that is the case, go to /etc/apach2/site-available
in 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/domain-name.com/some_other_folder
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Create a new file called "domain-name.com.conf" in the same folder
Write the following into the file:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/domain-name.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
To enable virtual host, type into terminal:
$ sudo a2ensite domain-name.com
Basically 000-default.conf wasn't working as it was disabled.
enable it by following command -
sudo a2ensite 000-default.conf
I was wondering why it opening my 000-domain-name.com.conf it's because may be as default conf has been disabled so apache search for other conf file alphabetically as act that as default conf.
Also if you want to disable default conf
sudo a2dissite 000-default.conf
Both above command require apache to be restarted by following command -
sudo service apache2 restart

apache2 multiple virtualhost but only first one works

I am running Apache/2.4.12 on Ubuntu and I added 2 .conf files in the /etc/apache2/sites-available/ folder, and enabled them. Both sites are using the same Symfony PHP files.
aaa.conf
Listen 8080
<VirtualHost *:8080>
ServerName local.aaa.com
ServerAlias www.local.aaa.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/aaa/web
<Directory "/var/www/html/aaa/web">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/aaa_error.log
CustomLog ${APACHE_LOG_DIR}/aaa_access.log combined
</VirtualHost>
bbb.conf
Listen 8081
<VirtualHost *:8081>
ServerName local.bbb.com
ServerAlias www.local.bbb.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/bbb/web
<Directory "/var/www/html/bbb/web">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/bbb_error.log
CustomLog ${APACHE_LOG_DIR}/bbb_access.log combined
</VirtualHost>
The problem I am having is that after a service apache2 reload only the first site that I open works. So for example:
1st scenario
- I do the reload
- I open local.aaa.com:8080 it works
- I open local.bbb.com:8081 it doesn't work, I get a PHP Fatal error: Class 'AppBundle\\AppBundle' not found
2nd scenario
- I do the reload
- I open local.bbb.com:8081 it works
- I open local.aaa.com:8080 it doesn't work, I get a PHP Fatal error: Class 'AppBundle\\AppBundle' not found
EDIT
#Ryan Vincent:
netstat -a shows both sites runnnig
All your Listen directives should be in the main apache configuration file provided by Ubuntu(/etc/apache2/apache2.conf).
The sites-enabled folder must only contain the proper symbolic links generated with a2ensite to sites-available, which is where you have to place your virtualhost configurations.
Once you moved them there, enable every virtualhost and reload apache.
sudo a2ensite aaa.conf
sudo a2ensite bbb.conf
sudo service apache2 reload
I had the same problem.
It has been solved by adding a rule on my firewall (UFW).
The ports i use are 18180 and 18181.
Connexion on port 18180 was OK, but not with 18181.
I tried with UFW disabled, but it didn't work, so i decided to add the rules "allow 18181/tcp" and "allow 18181/udp" and the problem is solved.
It's weird it didn't work with UFW disabled, but it's like that lol
I hope this will help

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