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.
Related
I install LAMP on my droplet in digital ocean, it did works good but now just tell "this site can't be reached, refused to connection" my IP is 157.230.139.112
My project worked well, however, from one day to the next, that simply appeared. I did not have anything important and decided to delete it and create a new droplet, however the same thing happens, I can make migrations and connect with the bd but only rejects the connection.
I did install composer, all the packages, configure my db and my etc/apache2/sites-enabled/000-default.conf and point to the public folder.
Am I doing something wrong?
Your apache server block might not be pointing to your laravel location correctly.
So, you might try configuring Apahce2 site configuration file for Laravel.
Run the command below to create a new configuration file called laravel.conf
sudo nano /etc/apache2/sites-available/laravel.conf
Copy paste the content below into the file and save it. Remember to replace 'Mywebsite' with your own domain name and directory root location.Remember to point to laravel public folder for security.
<VirtualHost *:80>
ServerAdmin admin#MyWebsite.com
DocumentRoot /var/www/html/MyWebsite/public
ServerName example.com
<Directory /var/www/html/MyWebsite/public>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save the file and exit.
Enable the Laravel and Rewrite Module
Enable the VirtualHost by running ..
sudo a2ensite laravel.conf
sudo a2enmod rewrite
Alternatively, compare your localhost apache serverblock configuration with that on the server, ie. if you are running apache locally
I have a question about a bad practice in Laravel.
I have only one server folder available for Laravel (in IIS).
There, I have the production site.
If I want to add a copy for development and testing against the test database, where must I place it?
Inside the production's version public folder? I donth think because it's unsafe. Sure will be an obvious best practice for that.
You can open a new port for it.
Example:
Config Virtual host with Production site:
Create a configuration file our laravel production project by typing the following commands
cd /etc/apache2/sites-available
sudo nano production.conf
In the production.conf file created paste the following content to the file and close it after saving.
Replace laravelproduction.com with the domain name of your website inside the file.
<VirtualHost *:80>
ServerName laravelproduction.com
DocumentRoot /var/www/html/production/public
<Directory /var/www/html/production>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the newly created .conf file and disable the default .conf which is pre-created by apache and enable mode rewrite for this to function appropriately. These are the comand to help you do that.
sudo a2dissite 000-default.conf (disable the default .conf file)
sudo a2ensite production.conf (enables the newly created .conf file)
sudo a2enmod rewrite (enables the rewrite)
Also, restart your apache server so that it can pick the changes that you have made by typing this command
sudo service apache2 restart
Config Virtual Host With Dev site
Create a configuration file our laravel dev project by typing the following commands
cd /etc/apache2/sites-available
sudo nano dev.conf
In the dev.conf file created paste the following content to the file and close it after saving.
Listen 8100
<VirtualHost *:8100>
ServerName laraveldev.com
DocumentRoot /var/www/html/dev/public
<Directory /var/www/html/dev>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the newly created .conf file and disable the default .conf which is pre-created by apache and enable mode rewrite for this to function appropriately. These are the comand to help you do that.
sudo a2ensite dev.conf
Finally restart your apache server so that it can pick the changes that you have made by typing this command
sudo service apache2 restart
This is how I usually use it. I hope to help you. ^_^
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.
I am trying to access my API and I get error 500 after uploading it to my FTP.
Laravel located at: MYDOMAIN.COM/v2/api
no error logs are generated.
My public index.php is the default one. Tried to play with it, but the paths seem fine.
What could have gone wrong?
For the reminder, it is a different domain. I do edit the config/app.php
Some things i experienced:
Run a composer install in case you moved your project. (I did this sometimes and skipped the vendor folder)
Just give your storage folder the right permissions:
chown -R www-data.www-data /var/www/laravel
$ chmod -R 755 /var/www/laravel
$ chmod -R 777 /var/www/laravel/app/storage
assad
Finally check your server settings. If your virtualhost has a wrong directory path the things above doesn't matter.
ServerName laravel.example.com
DocumentRoot /var/www/laravel/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/laravel>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Credit: http://tecadmin.net/install-laravel-framework-on-ubuntu/#
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.