0

I have a WHM that hosts multiple websites. Each website is hosted in /home/<hostname>/public_html. One of my website is using Laravel 5.4. Apparently this website is not working properly.

So I pushed all files directly to public_html and followed this post Laravel 5 - Remove public from URL to route the asset files to public/. But the asset files are not routed to the public/ folder from the website.

This is the .htaccess file:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    #RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule ^(.*)/$ /$1 [L,R=301]

    RewriteCond %{REQUEST_URI} !(\.svg|\woff|\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|img|fonts)/(.*)$ public/$1/$2 [L,NC]


    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

It works on my testing server. I don't know why it doesn't work on my production server. When I go to the website. The apacge error_log file shows this error:

File does not exist: /usr/local/apache/htdocs/home

multiple times.

.htaccess is parsed by the apache server because I tried to messed up the file and the website shows 500 error.

I don't know if this is because of the virtual host configuration error or what. This is the virtual host configuration:

<VirtualHost 123.164.132.142:80>
    ServerName marca.com
    ServerAlias mail.marca.com www.marca.com
    DocumentRoot /home/marca/public_html
    ServerAdmin webmaster@marca.com
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/marca combined
    CustomLog /usr/local/apache/domlogs/marca.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User marca # Needed for Cpanel::ApacheConf
    UserDir enabled
    <IfModule mod_suphp.c>
        suPHP_UserGroup marca marca
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup marca marca
        </IfModule>
    </IfModule>
    <IfModule mod_ruid2.c>
        RMode config
        RUidGid marca marca
    </IfModule>
    <IfModule itk.c>
        # For more information on MPM ITK, please read:
        #   http://mpm-itk.sesse.net/
        AssignUserID marca marca
    </IfModule>

    ScriptAlias /cgi-bin/ /home/marca/public_html/cgi-bin/


    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/2_2/marca/marca.com/*.conf"
</VirtualHost>

The server is using apache 2.2.

Edited: When I access directly to the public folder. The index route shows properly. But when I go to other routes like /login, the website shows 404 error. And .env is accessable by the world.

I should have added that my server is hosting multiple websites with multiple php versions. This Laravel website is using PHP 5.6.31 with it's own config file.

/usr/local/apache/conf/php56.conf
<IfModule mod_suphp.c>
  <Directory ~ "/home/marcabymortise/public_html">
     Options +FollowSymLinks
     AllowOverride All
     AddType application/x-httpd-php56 .php
     suPHP_AddHandler application/x-httpd-php56
  </Directory>
</IfModule>

And I haven't customized the virtual host file.

And this is the /usr/local/apache/conf/httpd.conf file.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#   Direct modifications to the Apache configuration file may be lost upon subsequent regeneration of the   #
#   configuration file. To have modifications retained, all modifications must be checked into the              #
#   configuration system by running:                                                                            #
#   /usr/local/cpanel/bin/apache_conf_distiller --update   
.....
Include "/usr/local/apache/conf/php.conf"
....
<Directory "/">
    Options ExecCGI IncludesNOEXEC Indexes SymLinksIfOwnerMatch
    AllowOverride All
</Directory>

<Directory "/usr/local/apache/htdocs">
    Options Includes Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

</Directory>

<Files ~ "^error_log$">
    Order allow,deny
    Deny from all

    Satisfy All
</Files>

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    CustomLog "logs/access_log" common

    <IfModule logio_module>
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

    </IfModule>

</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

</IfModule>

<Directory "/usr/local/apache/cgi-bin">
    AllowOverride All
    Options None
    Order allow,deny
    Allow from all

</Directory>

<IfModule mod_log_config.c>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent

    CustomLog logs/access_log common

</IfModule>

....
Joshua Leung
  • 2,219
  • 7
  • 29
  • 52

1 Answers1

0

After I upgraded the server to Apache 2.4. It works fine now.

Joshua Leung
  • 2,219
  • 7
  • 29
  • 52