How to implement laravel in ubuntu? - laravel

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.

Related

I can see a Laravel 6 intallation in localhost

I was testing a clean Laravel 6 installation to migrate an old Laravel project in one Ubuntu 18.04 environment, no used with PHP projects before.
After install PHP, Apache, Mysql... I test one PHP page OK.
I set the permissioins to 777 in /var/www/html/ subdirectories.
I cloned my old Laravel App to migrate and did one clean Laravel 6 installation.
First, I loaded the default welcome page in Laravel 6. After, I put some routes and views from the old project and tried to load some of then, but I had errors of type:
page don't found
I checked the settings of Apache and if mod_rewrite was available... finally, I run the old project OK, but my Laravel 6 is dissapeared. I can see it in the disk, but if load the http://localhost/laravel/ directory I can't see it.
Edited
Content of /etc/apache2/sites-available/000-default.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What i can suggest you to try is to define one Virtual Host for each project in this way:
Put this (with proper information) inside /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html/YOUR_LARAVEL_PROJECT_ROOT/public"
ServerName yourProjectDomain.dev
<Directory "/var/www/html/YOUR_LARAVEL_PROJECT_ROOT/public">
AllowOverride All
Options FollowSymLinks +Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And inside /etc/hosts put
127.0.0.1 yourProjectDomain.dev
Then check the permission on /var/www/html and each subdirectory (you can use cd /var/www/html && sudo chmod -R 777 * to set everything as readable, writable and executable).
Then clear the cache of the project (delete all the files inside the bootstrap/cache folder).
Then you should be able to access that project just using yourProjectDomain.dev on every browser inside your pc.

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

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.

Magento install ubuntu

Im having problem installing Magento on ubuntu. I've created and a2ensite a site with a documentroot that points to the "installation files" I've dowloaded from magento SVN repository. I've testes localhost and it works. This is my virtualhost file under sites-available and its present in sites-enabled aswell.
My virtual host:
<VirtualHost *:80>
ServerAdmin magento#localhost.com
ServerName magento.localhost.com
DocumentRoot /srv/www/magento_dev/public_html
<Directory /srv/www/magento_dev/public_html/>
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /srv/www/magento_dev/logs/error.log
LogLevel warn
</VirtualHost>
The problem is that I can't connec to the site when I type magento.localhost.com
I understand that there are a lot of things that can be wrong here but I've doubled checked everything e.g. the doucment root is there at /srv/www/magento_dev/public_html and the site is enabled and apache2 is reloaded.
The url you are using seems to be wrong. Try with http://localhost:80/magento.

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.

how to do create http://abc.mysite.com in httpt.conf

I have a website running fine which is located at:
/var/www/html/abcde
and phpmyadmin placed in:
/var/www/html/myadmin
And I have the following in my httpd.conf:
<VirtualHost *:80>
ServerName myadmin.mysite.com
DocumentRoot /var/www/html/myadmin
</VirtualHost>
I have added a DNS record, so that going to:
http://myadmin.mysite.com
does go to a link such as:
https://myadmin.mysite.com/?collation_connection=utf8_general_ci&token=d9383416a3547b7b0e569e048ca7caed&phpMyAdmin=899v1qg8t3s0o527qcgne0s5p2s2uijh
However, the page which shows up is the "Apache 2 Test Page". I earlier had this same folder located at: /var/www/html/abcde/myadmin and I simply moved it to its present location.
Check if you have the correct permissions on your folders
you can change the permission of your root folder
sudo chmod -r 0755 rootfolder
and here is how your httpd.conf should look like
<VirtualHost 127.0.0.1:8888>
ServerName myadmin.mysite.com
DocumentRoot "/var/www/html/abcde"
DirectoryIndex index.php
<Directory /var/www/html/abcde>
AllowOverride All
Allow from All
</Directory>
phpmyadmin itself was forcing a SSL connection
$cfg['ForceSSL'] = true;
I disabled that by setting it to false and everything worked.

Resources