I want to deploy an Angular 2 application on an Apache server. I've read various guides like this and this but none of them is working. I have npm and ng installed on the server.
In a nutshell, here's what I did:
Cloned complete project repository on my server.
Installed dependencies using npm install.
Used ng build --prod command and it created a dist directory.
Changed apache root to /var/www/html/dist directory.
Enabled mod_rewrite, restarted apache and added this .htaccess in my dist directory.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
But only my home page domain.com works, other pages like domain.com/login, domain.com/register etc. throw 404 error. Even domain.com/index.html/login doesn't work.
The application works fine on my local system where I'm developing it using ng serve. What am i missing?
Create .htaccess file in the root folder and paste this in .htaccess
<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 appears i was missing this in my /etc/apache2/sites-enabled/000-default.conf file. After adding this and restarting apache, website runs fine.
<Directory "/var/www/html/dist">
AllowOverride All
</Directory>
1) Change base tag in index.html file
<base href="./">
2) Build Project:
ng build --prod --base-href /myproject/
3) Add your dist files in "/usr/local/apache2/htdocs/myproject/"
4)On Apache Server 2.4 (httpd)
In File: /usr/local/apache2/conf/httpd.conf setup "FallbackResource"
<Directory "/usr/local/apache2/htdocs">
...
FallbackResource /myproject/index.html
</Directory>
full file "/usr/local/apache2/conf/httpd.conf":
ServerRoot "/usr/local/apache2"
Listen 80
LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
<IfModule !mpm_prefork_module>
#LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
#LoadModule cgi_module modules/mod_cgi.so
</IfModule>
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin you#example.com
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
FallbackResource /myproject/index.html
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog /proc/self/fd/2
LogLevel warn
<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
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog /proc/self/fd/1 common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "/usr/local/apache2/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Change base tag in index.html file
<base href="./">
Create a build after that
ng build --prod
Now you will have a new folder dist, deploy dist folder now. It should work.
For Apache, to redirect any request to index.html, you need a .htaccess file in the root.
Just create a .htaccess in your dist folder (same level as index.html), I assume that's the public root of your app, and paste this in the .htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# not rewrite css, js and images
RewriteCond %{REQUEST_URI} !\.(?:css|js|map|jpe?g|gif|png)$ [NC]
RewriteRule ^(.*)$ /index.html?path=$1 [NC,L,QSA]
Now, no matter what path you're requesting, Apache will always serve your index.html file, except requests to actual existing files (RewriteCond %{REQUEST_FILENAME} !-f) and requests to css, js etc. (RewriteCond %{REQUEST_URI} !.(?:css|js|map|jpe?g|gif|png)$) - which needed to be excluded, because you actually want those.
Also, the Apache's mod_rewrite extension needs to be enabled for this to work. Most often, it is enabled. If not, ask your hosting provider
Change base tag in index.html file
Run:
ng build --prod -bh "http://example.net"
open your index.html in dist directory after
ng build --prod
and Chang base element to your site DNS name for example for my local apache server
I changed from
<base href="/">
to
<base href="//localhost/angular2/ng2-cli/dist/">
I have create distribution directory as public. I have changed only virtual host setting of apache.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName frontend.loc
DocumentRoot /var/www/frontend/public
<Directory "/var/www/frontend/public/">
Options FollowSymLinks
Allow from all
AllowOverride All
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.html
</IfModule>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
~
As per official Angular documentation for angular deployment (https://angular.io/guide/deployment)
A routed application should support "deep links".
We need to enable mod_rewrite module, there are various ways to do this. On an ubuntu machine we can run following commands:
sudo a2enmod rewrite
sudo systemctl restart apache2
we also need to allowoverride in configuration file so that .htaccess file can run:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Then in .htaccess file, copy following lines for rewriting:
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
If it still doesn't work then best solution is check error log, in my case I solved the issue by checking logs where I find that mod_rewrite module was not installed so I had installed mod_rewrite manually and it worked.
Related
I am using Awstats for many years and before my upgrade on Debian 10, everything was working fine.
I have a special configuration with an Apache2 server behind a Zope framework. I apply rewrite rules from Apache2 to forward request to Zope.
Here my configuration for Apache2 (this file is called vhost.conf):
<VirtualHost *:443>
# Test local
ServerAdmin henry#example.com
ServerName example.com
ServerAlias www.example.com
# LOG
CustomLog /var/log/apache2/access.log combined
#CustomLog /var/log/apache2/access.log common
# ACTIVATE SSL
SSLEngine On
# CONFIG FOR LETSENCRYPT
SSLProtocol -ALL -SSLv3 +TLSv1 +TLSv1.1 +TLSv1.2
SSLHonorCipherOrder On
SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
Alias /awstats-icon "/usr/share/awstats/icon"
RewriteEngine On
# www to non www for HTTPS
# checking for the same thing again
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
# some people might argue second redirect here is excessive since you already arrived at correct host, but I'd leave this for you to sort out
RewriteRule ^/(.*) https://example.com/$1 [R=301,L]
# your /cgi-bin checks can be merged into one regex
# See also : https://stackoverflow.com/questions/60732096/awstats-tool-issue-with-missing-icons-and-histogram-bars-on-main-page-of-awsta/61178404#61178404
RewriteCond %{REQUEST_URI} !^/awstats [NC]
RewriteCond %{REQUEST_URI} !^/cgi-bin/(search|awstats) [NC]
RewriteRule ^/(.*) https://localhost:8443/++vh++https:%{SERVER_NAME}:443/++/$1 [P,L]
SSLProxyEngine On
RequestHeader set Front-End-Https "On"
#CacheDisable *
<Files "awstats.pl">
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
SetHandler cgi-script
Satisfy any
Order deny,allow
Deny from all
AuthType Basic
AuthName "Advanced Web Statistics"
AuthUserFile /etc/apache2/awstats-users.pwd
Require valid-user
</Files>
<Directory "/usr/share/awstats/icon">
AllowOverride None
/Files>
<Directory "/usr/share/awstats/icon">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "/usr/lib/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
SSLRequireSSL
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin henry#example.com
ServerName example.com
ServerAlias www.example.com
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect to ww.xx.yy.zz
RewriteCond %{HTTP_HOST} ^ww\.xx\.yy\.zz
RewriteRule (.*) http://example2.com$1 [R=301,L]
# www to non www for HTTP and HTTPS
RewriteCond %{REQUEST_URI} ^/www\. [NC,OR]
RewriteCond %{REQUEST_URI} !^/cars/video [NC]
# Rewrite below works : redirect 80 => https
RewriteRule ^/(.*) https://example.com/$1 [R=301,L]
# www to non www for HTTP
# if you want to keep your `/cars/video` on http check it first
#RewriteCond %{REQUEST_URI} !^/cars/video [NC]
RewriteRule ^/(.*) http://localhost:9674/++vh++http:%{SERVER_NAME}:80/++/$1 [P,L]
</IfModule>
</VirtualHost>
Unfortunately, the number of daily visits is almost null:
whereas before the upgrade to Debian 10, I had a mean of 200 unique visits a day.
I have included this configuration file above "vhost.conf" into "/etc/apache2/httpd.conf" file like this:
# If you prefer a single logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
CustomLog /var/log/apache2/access.log combined
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
#LoadModule proxy_ftp_module /usr/lib/apache2/modules/mod_proxy_ftp.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule proxy_connect_module /usr/lib/apache2/modules/mod_proxy_connect.so
#LoadModule authn_alias_module /usr/lib/apache2/modules/mod_authn_alias.so
LoadModule vhost_alias_module /usr/lib/apache2/modules/mod_vhost_alias.so
LoadModule cgid_module /usr/lib/apache2/modules/mod_cgid.so
#LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
LoadModule mime_magic_module /usr/lib/apache2/modules/mod_mime_magic.so
LoadModule cache_module /usr/lib/apache2/modules/mod_cache.so
#LoadModule disk_cache_module /usr/lib/apache2/modules/mod_disk_cache.so
LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
# Get back visitors for awstats
#LoadModule remoteip_module /usr/lib/apache2/modules/mod_remoteip.so
#LogLevel debug
LogLevel alert rewrite:trace3
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T %v" full
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %P %T" debug
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
NameVirtualHost *:80
include vhost.conf
What might be wrong here?
By the way, the log file access.log seems to be correctly filled when there are visitors: I don't understand what's happened.
Update
Here I provide a link of my current setup of awstats.conf :
awstats.conf
All the Apache configuration related information you posted appears to be sound except for an entry that allows the AWStats CGI(Perl) script to be accessed/executed. The fact that you indicated the Apache access.log is being populated makes me think this is an issue with how AWStats is configured. On Debian, you'll want to look in the folder:
/etc/awstats
and find a .conf file that matches your Apache vhost configuration. Be sure that the .conf file is properly referencing your Apache access.log file as the source for producing the statistics.
Some other considerations include checking that AWStats is configured to parse your log files on a regular basis via CRON routines or maybe even on demand based on the AWStats' configuration file mentioned above. If it's not configured to run on demand then a CRON job will need to be implemented to parse the logs on a regular basis.
Don't assume your prior AWStats configuration is still relevant after an upgrade. If not configured correctly your upgrade to Debian may have wiped out your previous settings.
Follow-up
Based on the awstats.conf file you posted be sure and define the host aliases attribute with all the virtual host extensions you expect:
HostAliases="localhost 127.0.0.1 REGEX [.com|net|org$]"
The DNS lookup should NOT be required. Set this to:
DNSLookup=2
Then in your Apache conf files you will want to be sure that you are allowing the AWStats Perl script to be executed in the directory that you wish to access these statistics. Something along these lines in each virtual domain conf you want AWStats to be accessible:
# Virtual host container
ScriptAlias /cgi-bin/ /path/to/cgi-bin/
<Directory "/path/to/htdocs/virtual-domain/cgi-bin">
AllowOverride None
Options +ExecCGI +SymLinksIfOwnerMatch
Require all granted
</Directory>
I'm working on a Laravel project locally using WAMP 3.1.0 and everything was working correctly until there was a windows update today.
When I go to my project I get an error page
I followed this post WAMP Virtual Host not working but that didn't solve my problem.
I've edited my C:\Windows\System32\drivers\etc\hosts file in admin mode which looks like this:
127.0.0.1 localhost
::1 localhost
127.0.0.1 test.dev
::1 test.dev
127.0.0.1 shoppingcart.dev
::1 shoppingcart.dev
127.0.0.1 gitproject.dev
::1 gitproject.dev
I've also edited my C:\wamp64\bin\apache\apache2.4.27\conf\extra\httpd-vhosts.conf file which looks like this:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot "${INSTALL_DIR}/www"
</VirtualHost>
<VirtualHost *:80>
ServerName test.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/test/public"
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "${INSTALL_DIR}/www/test/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName shoppingcart.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/shoppingcart/public"
#<Directory "${INSTALL_DIR}/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
#</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName gitproject.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/git_project/public"
#<Directory "${INSTALL_DIR}/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
#</Directory>
</VirtualHost>
When I visit my page like this http://localhost/test/public/order/23456 my page loads but when I try http://test.dev/order/23456 it doesn't.
I'm using apache 2.4.27
Can anyone tell me what's going on?
Also, this is my C:\wamp64\bin\apache\apache2.4.27\conf\httpd.conf file :
ServerSignature On
ServerTokens Full
Define APACHE24 Apache2.4
Define VERSION_APACHE 2.4.27
Define INSTALL_DIR c:/wamp64
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}
ServerRoot "${APACHE_DIR}"
Listen 0.0.0.0:80
Listen [::0]:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module "${INSTALL_DIR}/bin/php/php5.6.31/php5apache2_4.dll"
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin wampserver#wampserver.invalid
ServerName localhost:80
<Directory />
AllowOverride none
Require all denied
</Directory>
HostnameLookups Off
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Require local
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "${INSTALL_DIR}/logs/apache_error.log"
LogLevel warn
<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
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "${INSTALL_DIR}/logs/access.log" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "${INSTALL_DIR}/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "${INSTALL_DIR}/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
</IfModule>
EnableSendfile off
AcceptFilter http none
AcceptFilter https none
Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-vhosts.conf
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Include "${INSTALL_DIR}/alias/*"
The first thing you should know is that the .dev tLD is now a real tLD and has been bought by Google. So as of Chrome 63 (out since December 2017), Chrome itself will force all domains ending on .dev (and .foo) to be redirected to HTTPS via a preloaded HTTP Strict Transport Security (HSTS) header.
So we should all stop using .dev and use something else, suggestions are to use .localhost or .test.
A simple test for this would be to try using FireFox or IE instead of Chrome to access your current configured site. If it runs in another browser, some of your problem is related to the Chrome changes that redirect .dev domains automatically.
Secondly, your Virtual Host definitions are not good. For some time now in WAMPServer there has been a tool provided within WAMPServer to help you create Virtual Hosts easily and correctly. Look at the WAMPSever homepage under the Tools menu for a link called Add Virtual Host (see below).
All you need to do is first create the folder that you want the site to live in before running the "Add Virtual Host" tool.
I suggest you revert your httpd-vhosts.conf file back to its initial state which contains only a definition for localhost
#
# Virtual Hosts
#
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
And then using the "Add Virtual Host" menu, create your Virtual Hosts again, but this time using paycafe.localhost for example.
summary:
my-host-here.com/app_dev.php/main = works
my-host-here.com/main = 404 error
my-host-here.com/app.php/main = also gets a 404 error
I've looked at various links (symfony.com and discussions here in SO) and tried their suggestions/answers but no luck here.
Any ideas on how to fix it? Thanks a lot!
I'm using Apache 2.4.x/PHP 5.4.x which were installed using the yum repository on RHEL7.
snippet of httpd.conf
Include conf.modules.d/*.conf
snippet of 00-base.conf which resides inside conf.modules.d
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule slotmem_plain_module modules/mod_slotmem_plain.so
snippet of 10-php.conf which resides inside conf.modules.d
LoadModule php5_module modules/libphp5.so
snippet of my virtualhost config file
<VirtualHost *:80>
ServerName my-host-here.com
DocumentRoot /opt/www/my-host-here/web
<Directory /opt/www/my-host-here/web/>
DirectoryIndex app.php
AllowOverride All
Require all granted
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
The contents of the .htaccess inside /opt/www/my-host-here/web is whatever Symfony came with. I never changed it. Symfony project was created using the command:
symfony new my_project_name lts
Here is my settings:
/etc/apache2/sites-available/project.conf
<VirtualHost *:80>
ServerName project
DocumentRoot /path/to/project/web
<Directory /path/to/project/web >
Options Indexes FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /path/to/project/error.log
CustomLog /path/to/project/access.log combined
</VirtualHost>
web/.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Explicitly disable rewriting for front controllers
# RewriteRule ^app.php - [L]
RewriteRule ^app_dev.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
# RewriteRule ^(.*)$ app.php [QSA,L]
RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>
So the page is loading slow... Wants do download 4.4MB of page according to pingdom. I tried using disk cache, but spiceworks wont start up when adding the configurations to httpd.conf
httpd.conf:
ServerRoot "C:/Program Files/Spiceworks/httpd"
ServerTokens Min
Listen 9002
TraceEnable off
UseCanonicalPhysicalPort On
AllowEncodedSlashes On
EnableSendfile Off
EnableMMAP Off
ThreadsPerChild 150
Win32DisableAcceptEx
PidFile "log/httpd.pid"
LoadModule log_config_module modules/mod_log_config.so
LoadModule log_rotate_module modules/mod_log_rotate.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule alias_module modules/mod_alias.so
LoadModule cache_module modules/mod_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule expires_module modules/mod_expires.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule headers_module modules/mod_headers.so
LoadModule disk_cache_module modules/mod_disk_cache.so
# uncomment the following to enable compression from server to client
# depending on your network, this may increase performance
#LoadModule deflate_module modules/mod_deflate.so
# for debugging
#LoadModule dumpio_module modules/mod_dumpio.so
# Restrictive default access configuration
<Directory />
AllowOverride None
Order deny,allow
Deny from all
</Directory>
# No directory overrides are allowed in the rest of this config, but should
# someone customize it, don't allow download of the config files
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
# server logging
# values: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
ErrorLog "log/error.log"
<IfModule dumpio_module>
# Full request logging
# Also change LogLevel above
DumpIOInput On
DumpIOLogLevel debug
</IfModule>
<IfModule log_config_module>
# CustomLog formats
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
# Use combined logging by default
CustomLog "log/access.log" combined
</IfModule>
<IfModule log_rotate_module>
RotateLogs On
RotateLogsLocalTime On
RotateInterval 86400
</IfModule>
# for debugging rewrites
#RewriteLog "log/rewrite.log"
#RewriteLogLevel 5
# If not specified or undetermined by mime_module
DefaultType text/plain
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule deflate_module>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript application/x-javascript text/css
</IfModule>
<IfModule mem_cache_module>
CacheEnable mem /
CacheIgnoreHeaders Set-Cookie
MCacheSize 50000
MCacheMaxObjectCount 1009
MCacheMinObjectSize 1
</IfModule>
# client-side caching for assets
<IfModule expires_module>
ExpiresActive On
# 10 minutes by default
<FilesMatch "(i?)\.(ico|gif|jpe?g|png|html|css(\.gz)?|js(\.gz)?)$">
ExpiresDefault "access plus 10 minutes"
</FilesMatch>
# 1 year for assets with cache-buster ("labeled" using location prefix in rewrite rules below)
<Location "/.asset/">
ExpiresDefault "access plus 1 year"
</Location>
</IfModule>
# error documents
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
ErrorDocument 503 /503.html
ErrorDocument 502 /500.html
ErrorDocument 504 /503.html
ProxyErrorOverride Off
<IfModule proxy_scgi_module>
Include conf/scgi_proxy.conf
</IfModule>
Alias /.asset "C:/Program Files/Spiceworks/pkg/gems/spiceworks_public-7.5.00065"
<Proxy http://static.spiceworks.com >
ProxySet retry=0 max=4 smax=1 ttl=15 connectiontimeout=10 acquire=30000 timeout=30
</Proxy>
<Proxy http://community.spiceworks.com >
ProxySet retry=0 max=4 smax=1 ttl=15 connectiontimeout=10 acquire=30000 timeout=30
</Proxy>
DocumentRoot "C:/Program Files/Spiceworks/pkg/gems/spiceworks_public-7.5.00065"
<Directory "C:/Program Files/Spiceworks/pkg/gems/spiceworks_public-7.5.00065">
Options FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
Allow from all
RewriteEngine On
<IfModule expires_module>
# find assets with cache-buster (e.g. "filename?123456")
# label with location ".asset" and pass through (PT) block above to blow out the client-side expires time
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} \.(ico|gif|jpe?g|png|html|css|js)$ [NC]
RewriteCond %{QUERY_STRING} ^[0-9]+$
RewriteRule . .asset%{REQUEST_URI}?asset [QSA,NS,PT]
</IfModule>
# proxy to community server to pull in community content
RewriteRule ^content_points/cdn/(.*) http://static.spiceworks.com/$1 [QSA,NS,L,P]
RewriteRule ^content_points/pass/(.*) http://community.spiceworks.com/$1?app_render=true&product_version=7.5.00065 [QSA,NS,L,P]
RewriteRule ^content_points/([^/]+) http://community.spiceworks.com/app/deliveries/$1?product_version=7.5.00065 [QSA,NS,L,P]
# tray opens up to /splash or /first_splash
# this is just a static file
RewriteRule ^(first_splash|splash)$ splash.html [NS,L]
# redirect non files to rails
# RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
<IfModule proxy_scgi_module>
RewriteRule .? .scgi%{REQUEST_URI} [E=X_HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,NS,L]
</IfModule>
<IfModule headers_module>
Header set X-UA-Compatible "IE=Edge,chrome=1"
</IfModule>
</Directory>
# this section is included only when you run httpdconf with the files
# ssl-cert.pem and ssl-private-key.pem in the ssl subdirectory
<IfModule ssl_module>
Listen 9003
SSLCompression off
And what im trying to add:
<IfModule cache_module>
LoadModule cache_disk_module modules/mod_cache_disk.so
<IfModule cache_disk_module>
CacheDefaultExpire 3600
CacheEnable disk /
CacheRoot "/cache/"
CacheDirLevels 2
CacheDirLength 1
</IfModule>
</IfModule>
What am I doing wrong?
How long is the loading time?
And any more information?
Like, where does it load very long?
How big is the TTFB(http://www.bytecheck.com/) etc..
I have to append a QUERY_STRING at the end of URL while redirecting to remote server on the basis of string found in the REQUEST_URI.
My httpd.conf looks like this :
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/site1$
RewriteRule ^/ /?Id=1 [QSA]
This is not working.
I want to add QUERY_STRING "?Id=1" if REQUEST_URI contains word "site1".
Pelase help.. Thanks.
Listen 9010
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
<IfModule proxy_html_module>
Include conf/extra/httpd-proxy-html.conf
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/site1$
RewriteRule .* ?tenantId=1 [QSA,L]
<VirtualHost *:9010>
ServerName localhost
ProxyPass /site1 http://localhost:7001
ProxyPassReverse /site1 http://localhost:7001
</VirtualHost>
I would be doing something wrong for sure.. Please help.
See if this works. If not, it should point you in the right direction.
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/site1$
RewriteRule .* ?Id=1 [QSA,L]