Deploy laravel apache (public access forbidden) - laravel

I deploy laravel project on apache web server and this is my .conf
this is my conf
and in my public_html I've 4 project
list of project
but when i go to mydomain.com/sso_NAP (for example) my browser show this error
error when i put /public in my conf
need help

Some Options parameters need the +/- syntax
Change:
Options Indexes FollowSymLinks MultiViews
to:
Options +Indexes +FollowSymLinks +MultiViews

if it is in linux/ubuntu, have you checked the directory permissions?
I had the same problem with my project in ubuntu, the solution in my case:
sudo chown -R www-data:www-data laravel-project/ && sudo chmod -R g+rw laravel-project/

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.

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.

Laravel returns error 500 after uploading to web host via FTP

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/#

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>

Magento: Your web server is configured incorrectly

From a live magento setup I made a tar.gz, moved that to an domains of another DirectAdmin user, extracted the tar.gz, copied the database, changed the URL of domain in the database. Front-end works good.
Backend gives me the following error:
Your web server is configured incorrectly. As a result, configuration files with sensitive information are accessible from the outside. Please contact your hosting provider.”
I already check the folder and file permission. Also tried to change the rights from the user:group settings with SSH access to the same user as the DirectAdmin user name. But that did not work either.
Note that this installation is on the same server as the live environment.
Live: (working) http://imageshack.us/photo/my-images/197/nrhj.png/
Test: (not working) http://imageshack.us/photo/my-images/542/uklz.png/
Specifically check the permissions on app/etc/local.xml as usually this means it is world readable.
Also, there is supposed to be a .htaccess file in app/etc/ that denies the contents from being served out by the web server. Check just in case your tar backup didn't include it. Usually this problem comes about from using an FTP client to do the transfer that has had hidden file visibility turned off.
For Apache 2.4.x you have to add Require all granted So it would look something like this:
<Directory /var/www/magento>
AllowOverride All
# New directive needed in Apache 2.4.3:
Require all granted
</Directory>
Source: Apache: client denied by server configuration
Im using a Debian 7 with Apache 2.2.22 and Magento 1.9.1, adding
<Directory /var/www/magento/>
AllowOverride All
</Directory>
in /etc/apache2/sites-available/default
works for me
Similar to John Veldboom's answer I added this to /etc/apache2/apache2.conf since my magento install was in a different directory /var/www/html (eg. the directory path is wherever magento was extracted):
<Directory /var/www/html/>
AllowOverride All
Require all granted
</Directory>
With the following apache2 and ubuntu distro:
root#test-VirtualBox:/var/www/html# dpkg -l apache2 && lsb_release -a
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii apache2 2.4.7-1ubunt amd64 Apache HTTP Server
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty
I had this issue on Debian and found my server-level site config (in /etc/apache2/sites-available/default) had AllowOverride None set. Changing that line to AllowOverride All fixed it.
Thanks Haselnussstrauch, your answer worked for me. My setting was in apache2.conf
sudo nano /etc/apache2/apache2.conf
Change the default AllowOverride None to AllowOverride All
<Directory /var/www/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Then restart Apache:
sudo service apache2 restart
Many other places suggest that you can block ip addresses to your server by adding this to your httpd.conf
<Location />
order allow,deny
allow from all
deny from aa.bb.cc.dd
</Location>
however this for some reason causes all other .htaccess files to be ignored, including .htaccess files that are in place to protect magento.
I have fixed issue, there is no .htaccess fine inside sub folder (especially app).

Resources