I've installed Laravel 5 on CentOS 7 with ease. Made .htaccess changes and and generated application key. My .conf file is like this:
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot "/var/www/html/laravel/public"
ServerAlias www.mydomain.com
ServerAdmin x#localhost
<Directory "/var/www/html/laravel">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
But when i try to open it via www.mydomain.com it opens Apache Testing 123.. page. And when i try www.mydomain.com/laravel/public, i can see default laravel page.
What am i missing?
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot "/var/www/html/laravel"
ServerAlias www.mydomain.com
ServerAdmin x#localhost
<Directory "/var/www/html/laravel">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
Directory and document root should be the same
I had the exact same problem some months ago, check in your .htaccess for the following lines
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
If it's like this, include index.php so when apache is looking in the public folder it will use that file to redirect your routes. Also be sure you are loading the php module.
LoadModule php7_module modules/libphp7.so
Related
I am using AWS Lamp apache service. Here htdocs folder is the default root directory. I have a folder named my-folder inside htdocs.
htdocs
my-folder
I want to set my-folder as a root directory.
But How?
I have edited /opt/bitnami/apache/conf/httpd.conf
Here are the edited codes in httpd.conf file.
# DocumentRoot "/opt/bitnami/apache/htdocs"
# <Directory "/opt/bitnami/apache/htdocs">
DocumentRoot "/opt/bitnami/apache/htdocs/my-folder"
<Directory "/opt/bitnami/apache/htdocs/my-folder">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
But it doesn't work!
Please correct me.
Problem Solved
I just modified /opt/bitnami/apache/conf/vhosts/00_status-vhost.conf as below.
<VirtualHost 127.0.0.1:80 _default_:80>
ServerAlias *
DocumentRoot /opt/bitnami/apache/htdocs/my-folder
<Directory "/opt/bitnami/apache/htdocs/my-folder">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
#for https
<VirtualHost 127.0.0.1:443 _default_:443>
ServerAlias *
DocumentRoot /opt/bitnami/apache/htdocs/my-folder
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/bitnami/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/bitnami/certs/server.key"
<Directory "/opt/bitnami/apache/htdocs/my-folder">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
and it's working!
Documention provided by AWS Create A Virtual Host For A Custom Application
I am new to Symfony, and I've just created a new project on Windows server + Php7.3 + Apache 2.4.
The project folder is located at C:\Apache24\htdocs\symfony.
When I access that folder from my web browser, I see the directory listing page it should show the index page in the public folder.
Here is my code in apache:
<VirtualHost *:90>
ServerAdmin abc#abc.com
DocumentRoot "${SRVROOT}/htdocs/"
ServerName localhost
<Directory "${SRVROOT}/htdocs/symfony/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
And i tried to use .htacess option as in Symfony guideline with install symfony/apache-pack, but no luck:
<VirtualHost *:90>
ServerAdmin abc#abc.com
DocumentRoot "${SRVROOT}/htdocs/"
ServerName localhost
<Directory "${SRVROOT}/htdocs/symfony/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
the .htaccess file had been created in public folder.
i have tried to install the demo application too, the same issue.
Wordpress or other applications have been installed without issue.
Thank you.
Shouldn't the DocumentRoot also be pointing to the Symfony public directory?
<VirtualHost *:90>
ServerAdmin abc#abc.com
DocumentRoot "${SRVROOT}/htdocs/symfony/public"
ServerName localhost
<Directory "${SRVROOT}/htdocs/symfony/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
We are trying to go live with our Laravel project on an Ubuntu server running Apache. While all routes and functionality works locally, after going live, all routes that are not the home route result in a 404 error.
I am using the default laravel .htaccess in the /public directory.
My /etc/apache2/sites-available looks as follows:
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/mydomain.com/public
<Directory /var/www/mydomain.com/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The /mydomain.com/ root directory does not currently contain any .htaccess.
I enabled modrewrite using a2enmod rewrite and restarted apache after every change.
Has anyone else run into this issue? I appreciate any suggestions on how to resolve.
Thanks in advance!
You write mydomin.com in every rows. But later you talk about mydomain.com folder. (Note the A). Is it just a mistyping?
Update: The problem is an other mistyping: directories should be the same on the following lines:
DocumentRoot /var/www/html/mydomain.com/public
<Directory /var/www/html/mydomain.com/public>
I want my domain to run two separate laravel applications depending the url
for instance
domain.com to /home/sites/1
domain.com/account to /home/sites/2
I have this working, however the laravel instance running on site 2 thinks domain.com/account is the homepage.
When i goto domain.com/account i see the homepage of site 2 - not the route for setup for /account.
here is my vhost file
<VirtualHost *:443>
ServerName domain.com
ServerAdmin webmaster#localhost
UseCanonicalName Off
DocumentRoot /home/sites/1/public/
DirectoryIndex index.php
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /home/sites/1/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Alias /account/ /home/sites/2/public/
<Directory /home/sites/2/public/>
Require all granted
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
RewriteEngine On
</Directory>
</VirtualHost>
Add this to your custom apache virtualhost file
<VirtualHost *:80>
ServerAdmin xx#xxx.com
ServerName xxx.com
DocumentRoot /path/to/site1/public
Alias /account /path/to/site2/public
<Directory /path/to/site1/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now you need to change .htaccess file of public folder of the alias -
add RewriteBase /directory_name_of_site2/ right after the RewriteEngine On in .htacess file
you can add as many aliases you want just remember to modify the .htaceess file of every projects
When I try to change the web root path to any other folder it give me a 403 error (Forbidden), The default path is /Library/WebServer/Documents, but since this rather annoying for me, I changed it too /Users/Xero/WebServer
Permissions I got the permissions from /Library/WebServer/Documents by right clicking and selecting Get info (http://i.imgur.com/f21D7z0.png What it looks like)
So I changed it to be the exact same for /Users/Xero/WebServer. But it give me a 403 error still.
Attempt to fix
So, I looked it up on Google, and I tried these solutions to fix my problem:
http://www.cyberciti.biz/faq/apache-403-forbidden-error-and-solution/
Error message "Forbidden You don't have permission to access / on this server" (Stack Overflow)
But they didn't help.
Other Notes
Remember I'm using the preinstalled Apache on OS X Snow leopard. And, my virtual host isn't local, so it's not part or the hosts file issue (It's hosted off my DNS, and my IP as a backup, neither work)
My Virtual Hosts:
<VirtualHost *:80> ( Edited 2 )
DocumentRoot "/Users/Xero/WebServer"
</VirtualHost>
<VirtualHost *:80>
Options Indexes FollowSymLinks Includes ExecCGI
DocumentRoot "/Users/Xero/WebServer"
ServerName wrks.tk
ErrorLog "/Logs/Workarea/wrks-err"
CustomLog "/Logs/Workarea/wrks-acc" common
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
<Directory "/Users/Xero/WebServer">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Xero/WebServer"
ServerName 209.169.203.53
ErrorLog "/Logs/Workarea/ip"
CustomLog "/Logs/Workarea/ip-acc" common
<Directory "/Users/Xero/WebServer">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Also, I have my httpd.conf User and Group setup like this:
User _www
Group _www
Responses to Answers
Edits
So, I fixed the path's to the document's, but it still giving me the same error, 403.
I checked my FireWall settings and it's off. I also checked my `Sharing Preferences`, `File Sharing` and `Web Sharing` are on.
I edited the duplicate of `DirectoryIndex Home.php Home.html` in the `wrks.tk` VirtualHost, but still, I'm getting the same error. (See Other Notes)
Added more too Other Notes.
Fixed directory, but still didn't fix problem.
Added another to Answer Responses.
Tried a computer restart, did not work.
I put a `index.html` in the folder, still got the same 403 error, I tried accessing `/index.html`, still, 403.
What file exactly are you getting all of this from?
<VirtualHost *:80> ( Edited 2 )
DocumentRoot "/Users/Xero/WebServer"
</VirtualHost>
<VirtualHost *:80>
Options Indexes FollowSymLinks Includes ExecCGI
DocumentRoot "/Users/Xero/WebServer"
ServerName wrks.tk
ErrorLog "/Logs/Workarea/wrks-err"
CustomLog "/Logs/Workarea/wrks-acc" common
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
<Directory "/Users/Xero/WebServer">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Xero/WebServer"
ServerName 209.169.203.53
ErrorLog "/Logs/Workarea/ip"
CustomLog "/Logs/Workarea/ip-acc" common
<Directory "/Users/Xero/WebServer">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
There are more than one file for those settings. If you have apache, then take a look in the sites-enabled and sites-available folders.
Change the bottom part of your httpd.conf file to:
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
Make a new file index.html and put the following in it:
<!DOCTYPE html>
<html>
<body>
<h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body>
</html>
Then place the index.html file into the empty directory.
create a file in /etc/apache2/users/ called yourusername.conf (yourusername being the account short name, e.g. hulu – it's usually the name of your home folder in /Users) with the following contents:
<Directory "/Users/yourusername/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>