I checked most of question regarding to my problems as this seems to be very common error for Laravel beginners but I can't find the solutions so far :(
I use the digital ocean VPN, centos7, php5.6, apache, windows 10.
Installed laravel and configured httpd.conf, mysite.com.conf, .htaccess and hosts fies then restart apache but still welcome screen doesn't show and it shows apache screen instead.
+==================================================+
here is my settings...
1) /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
Options -Indexes +FollowSymLinks
AllowOverride None (default setting)
And added below the end of the file
ServerSignature Off
ServerTokens Prod
IncludeOptional sites-enabled/*.conf
For reference, other default settings are below
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
2) /etc/httpd/sites-available/mysite.com.conf
<VirtualHost *:80>
ServerAdmin admin#mysite.com
ServerName mysite.com
ServerAlias mysite.com
DocumentRoot /var/www/mysite.com/public_html
ErrorLog /var/log/httpd/mysite.com_error_log
CustomLog /var/log/httpd/mysite.com_access_log combined
AddDefaultCharset UTF-8
<Directory /var/www/mysite.com/public_html>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
AllowOverride All
</Directory>
</VirtualHost>
3) /var/www/mysite.com/public_html/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
4) C:/windows/system32/drivers/etc/hosts
digitaloceanDropletIp mysite.com
5) publi_html folder img
I would be really appreciated if someone can tell me what is wrong my settings.
Thanks in advance!
Change
DocumentRoot /var/www/mysite.com/public_html
To
DocumentRoot /var/www/mysite.com/public_html/public
Then restart your apache
[Solution]
By kindest people's help, I finally managed to show Laravel logo! Stupidly I didn't realised index.php is in public folder!
I kept httpd.conf and hosts as same as above, but changed mysite.com.conf below and completely removed/deleted public_html/.htaccess (I may need it future but this stage I don't need).
<VirtualHost *:80>
ServerName mysite.com
ServerAlias mysite.com
ServerAdmin admin#mysite.com
DocumentRoot "/var/www/mysite.com/public_html/public"
ErrorLog /var/log/httpd/mysite.com_error_log
CustomLog /var/log/httpd/mysite.com_access_log combined
AddDefaultCharset UTF-8
<Directory "/var/www/mysite.com/public_html/public">
AllowOverride All
</Directory>
</VirtualHost>
After this change, 403 Error came up (seems to be this happens for apache) so I added the below line just before 'RewriteEngine On' in public/.htaccess Refer: non English website
Options +FollowSymLinks
Then 500 Error came up, so I used putty for the blow command (I had to do this even thought I previously did 'chmod 777 storage') Refere: Laravel blank white screen.
chmod -R guo+w storage
Then finally 'Laravel' showed up :) Anyway thanks for all help!
Related
I just deploy my vue js project to apache server. My file /dist located in /var/www/html/dist. When i visit the page it's work fine. But when i visit in another page and i refresh the page, in browser say 404 Not found. How can i fix this ?
You need a configuration something similar to this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
It will automatically serve index.html file for every request that doesn't have a corresponding static file. You will have to put this .htaccess file. The use of IfModule is explained here.
I have same error, on ubuntu after i install apache.
First i added in /etc/apache2/apache2.conf
AllowOverride All
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
In /etc/apache2/sites-available
<VirtualHost test.ru:80>
ServerName www.test.ru
ServerAlias test.ru
ServerAdmin webmaster#localhost
DocumentRoot /var/www/test.ru
<Directory /var/www/test.ru>
#Разрешение на перезапись всех директив при помощи .htaccess
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Then in console activate rewrite module and restart apache
sudo a2enmod rewrite
service apache2 restart
I have been trying to get symfony to run, next to a directadmin install. However, after trying several solutions, I have no clue how I can fix the httpd.conf file to get it to work. I'm only getting "Apache is functioning normally" right now.
Would anyone have an idea as to what my httpd.conf should look like?
I created the httpd.conf file by setting up a custom template for directadmin, basically working from what directadmin normally supplies by itself.
This is what the part for this subdomain looks like (IP/Domain have been hidden):
<VirtualHost IP:443 >
SSLEngine on
SSLCertificateFile /usr/local/directadmin/data/users/admin/domains/DOMAIN.cert
SSLCertificateKeyFile /usr/local/directadmin/data/users/admin/domains/DOMAIN.key
SSLCACertificateFile /usr/local/directadmin/data/users/admin/domains/DOMAIN.cacert
ServerName www.sym.DOMAIN
ServerAlias www.sym.DOMAIN sym.DOMAIN
ServerAdmin webmaster#DOMAIN
DocumentRoot /home/admin/domains/DOMAIN/private_html/sym/web
ScriptAlias /cgi-bin/ /home/admin/domains/DOMAIN/public_html/sym/cgi-bin/
UseCanonicalName OFF
<IfModule !mod_ruid2.c>
SuexecUserGroup admin admin
</IfModule>
CustomLog /var/log/httpd/domains/DOMAIN.sym.bytes bytes
CustomLog /var/log/httpd/domains/DOMAIN.sym.log combined
ErrorLog /var/log/httpd/domains/DOMAIN.sym.error.log
<FilesMatch "\.(inc|php|phtml|phps|php70)$">
AddHandler "proxy:unix:/usr/local/php70/sockets/admin.sock|fcgi://localhost" .php70
</FilesMatch>
<Directory /home/admin/domains/DOMAIN/private_html/sym/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
The differences in here compared to a default subdomain generated by directadmin, are the addition of /web behind the documentroot, and the complete "directory" settings.
We have a problem with access to multiple Symfony3 projects that are in different folders and targeted to the same IP address but in different ports on EC2, for example:
project1:
52.1.1.1:8080/login
/var/www/html/projects/project1/
project2:
52.1.1.1:8181/login
/var/www/html/projects/project2/
Happens that when entering the Project 1 (52.1.1.1:8080) it is displayed correctly, but afterward when accessing to Project 2 (52.1.1.1:8181), this fails, strangely deploys the information from Project 1.
In another scenario, when rebooting the apache service and entering the Project2 (52.1.1.1:8181) all is displayed correctly, but if after entering in the Project2, we enter the Project 1 (52.1.1.1:8080) the information from Project2 is displayed, instead of that of the Project 1.
Ports 8080 and 8181 are open.
Apache configuration on the server is the following:
Listen 8181
<VirtualHost *:8181>
DocumentRoot "/var/www/html/projects/project1/web"
DirectoryIndex app.php
<Directory "/var/www/html/projects/project1/web">
Require all granted
Order allow,deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
<Directory /var/www/html/projects/project1>
Options FollowSymlinks
</Directory>
<Directory /var/www/html/projects/project1/web/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
CustomLog /var/www/html/projects/project1/var/logs/reg-access.log combined
ErrorLog /var/www/html/projects/project1/var/logs/reg.error.log
</VirtualHost>
Listen 8080
<VirtualHost *:8080>
DocumentRoot "/var/www/html/projects/project2/web"
DirectoryIndex app.php
<Directory "/var/www/html/projects/project2/web">
Require all granted
Order allow,deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
<Directory /var/www/html/projects/project2>
Options FollowSymlinks
</Directory>
<Directory /var/www/html/projects/project2/web/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
CustomLog /var/www/html/projects/project2/var/logs/reg-rm.log combined
ErrorLog /var/www/html/projects/project2/var/logs/reg.error.log
</VirtualHost>
Any help or ideas about what happens?
UPDATED
To access the Project 1, logs the following error:
[2016-08-17 07:33:12] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Error: Cannot redeclare class Doctrine\Common\Annotations\Annotation\Target" at /var/www/html/projects/project2/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php line 31 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 0): Error: Cannot redeclare class Doctrine\Common\Annotations\Annotation\Target at /var/www/html/projects/project2/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php:31)"} []
"Vendors" is referenced strangely to another project
I found a temporary solution, I had to modify the "app/autoload.php" file
Before
$ loader = require __DIR__.'/../vendor/autoload.php';
After
$ loader = require __DIR__.'/../../project1/vendor/autoload.php';
And it all worked properly.
But I communicated with Javier Eguiluz and he suggested to try installing APC on the server, I installed it, rolled back the changes to the file "app/autoload.php" and it worked properly.
EDIT #2 based on your comment.
Listen 8181
<VirtualHost *:8181>
Servername project1.com
...
Listen 8080
<VirtualHost *:8080>
Servername project2.com
DocumentRoot "/var/www/html/projects/project2/web"
DirectoryIndex app.php
On a remote host edit your hosts file to include the above host names.
For example, if you are on a remote Windows host, edit the file "c:\Windows\System32\Drivers\etc\hosts" as follows:
52.1.1.1 project1.com
52.1.1.1 project2.com
Then in your browser use:
http://project1.com:8181
http://project2.com:8080
This should work. Please investigate first before downvoting. Thanks!
This is my virtual host entry.
Version: Apache/2.2.15 (Unix)
<VirtualHost *:80>
ServerName web1.net
ServerAlias www.web1.net
ServerAdmin webmaster#web1.net
DirectoryIndex index.html index.php
LogLevel warn
ErrorLog /var/log/httpd/web1.net_error_log
CustomLog /var/log/httpd/web1.net_access_log combined
DocumentRoot /web/web1.net/htdocs
<Directory "/web/web1.net/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
AllowOverride All
RewriteEngine On #This is not working
</Directory>
</VirtualHost>
.htaccess file
RewriteEngine on # It works.
#abc5
RewriteCond %{HTTP_HOST} ^example\.org$ [NC]
RewriteRule .* http://www.example.com
When I put the same (RewriteEngine on) in .htaccess file it starts working, why I need require to put this in .htaccess when it is present in virtual host.
Do I need any other changes in Apache config?
You need to have RewriteEngine on in each directory's .htaccess if you want to enable rewriting. So in short:
RewriteEngine on from server config doesn't come into effect for DocumentRoot/.htaccess
RewriteEngine on in DocumentRoot/.htaccess doesn't come into effect for any /subdir/.htaccess
I added to C:/windows/system32/drivers/etc/hosts:
127.0.0.1 mywebiste
and in httpd-vhosts.conf added:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "C:/xampp/htdocs/mywebiste"
ServerName mywebsite
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
<Directory "C:/xampp/htdocs/mywebiste">
Options Indexes FollowSymLinks Multiviews
Options -Indexes
AllowOverride None
Order allow,deny
allow from all
#RedirectMatch ^/$ / index.php
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</Directory>
</VirtualHost>
And now when I want to add new website to hosts file and httpd-vhosts.conf it renders 'mywebsite' and I cant access that website, even if I delete my virtualhost in httpd-vhosts.conf and remove my entry from hosts file it still renders 'mywebsite'. What should I do to fix this, I have no clue?
I believe you need
NameVirtualHost *:80
Prior to any <VirtualHost...> lines
See here
Nevermind, you have to restart the apache to apply new settings :) sorry. Btw it doesnt work at all wit NamevirtualHost.