i use aws ec2 bitnami wordpress built a webiste. but i face one issue.
for installing SSL, I Changed .conf document. now I faced one problem.
i can open the domain abc.com (for example only) but can not open www.abc.com.when i want to open www..abc.com , it redirect the address to http://abc.comhttps//www.abc.com/.
May i now how to solve it?
Bitnami Engineer here,
Please follow these steps to force the redirection to HTTPS in our stack:
Add the following lines in the default Apache virtual host configuration file at /opt/bitnami/apache2/conf/bitnami/bitnami.conf, inside the default VirtualHost directive, so that it looks like this:
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
...
</VirtualHost>
Restart Apache to apply the changes.
sudo /opt/bitnami/ctlscript.sh restart apache
You can find more information about this redirection in our documentation
I not sure how edit .conf here, can I add the conf code here for checking?
# Default Virtual Host configuration.
<IfVersion < 2.3 >
NameVirtualHost *:80
NameVirtualHost *:443
</IfVersion>
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}
RewriteEngine On
RewriteCond %{HTTP_HOST} !^panasonicservomotor.com$
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteRule ^(.*)$ http://panasonicservomotor.com$1 [R=permanent,L]
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3 >
Require all granted
</IfVersion>
</Directory>
# Error Documents
ErrorDocument 503 /503.html
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
# Default SSL Virtual Host configuration.
<IfModule !ssl_module>
LoadModule ssl_module modules/mod_ssl.so
</IfModule>
Listen 443
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !EDH !RC4"
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:/opt/bitnami/apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout 300
<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
RewriteCond %{HTTP_HOST} !^panasonicservomotor.com$
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteRule ^(.*)$ https://panasonicservomotor.com$1 [R=permanent,L]
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/server.key"
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3 >
Require all granted
</IfVersion>
</Directory>
# Error Documents
ErrorDocument 503 /503.html
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
# Bitnami applications that uses virtual host configuration
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf"
Related
On my Apache server I have a WordPress installation working on www.domain.com and I want to add a Symfony4 installation on www.domain.com/symfony. Symfony routes are taken to the WordPress 404 page (but still are the correct URL i.e. www.domain.com/symfony/about). However, if there are NO routes defined in my Symfony app, then the base www.domain.com/symfony/ URL will correctly display the Symfony4 getting started page. What is wrong in my Apache conf files?
Web server is Apache 2.4, I have tried using Alias and AliasMatch directives in the /etc/apache2 conf files. Alias displays WordPress 404 for all Symfony routes and AliasMatch appends many /index.php's onto the URL and displays the same 404. I tried to copy what phpmyadmin does with its Alias /phpmyadmin /usr/share/phpmyadmin
# /etc/apache2/sites-available/wordpress.conf
<Directory /var/www/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin me#myemail.com
DocumentRoot /var/www/wordpress
</VirtualHost>
# /var/www/wordpress/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# /etc/apache2/sites-available/symfony.conf
Alias /symfony /var/www/symfony/app/public
<Directory /var/www/symfony/app/public>
Options FollowSymLinks
AllowOverride All
Require all granted
Allow from All
FallbackResource /index.php
</Directory>
# /var/www/symfony/app/config/routes.yaml
about_index:
path: /about
controller: App\Controller\AboutController::index
I expected www.domain.com/symfony/about to go to /var/www/symfony/app/public/index.php and route to App\Controller\AboutController::index, but it looks like WordPress is trying to find the page /symfony/about and 404's.
When I change my Alias /symfony /var/www/symfony/app/public to AliasMatch ^/symfony.* /var/www/symfony/app/public it changes the Symfony URL to www.domain.com/symfony/index.php/index.php/index.php/index.php/index.php/index.php but has the same result (WordPress 404 page). None of my changes have impacted the WordPress part at all - it still functions perfectly.
EDIT 1
Tried a new conf to test if it's my symfony config - it works as expected so I just think it must be something in my Apache confs. This config treats the symfony app as the main site and wordpress is totally disabled:
# /etc/apache2/sites-available/symfony_only.conf
<Directory /var/www/symfony/app/public>
Options FollowSymLinks
AllowOverride All
Require all granted
Allow from All
FallbackResource /index.php
</Directory>
<Directory /var/www/symfony/app/public/bundles>
FallbackResource disabled
</Directory>
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin me#myemail.com
DocumentRoot /var/www/symfony/app/public
</VirtualHost>
Looks like I got a working conf now. Not sure if it's even resulting in any different configuration than the one I had. I also did a lot of php bin/console cache:clear as I was even getting 404 and 500 errors on the little debug bar at the bottom of the symfony welcome page (not displayed on the bar, but the bar actually wouldn't properly load). The below file is my entire conf which I combined into one file. It serves from my Symfony4 app if the url path begins with /symfony, and the routes all work.
# /etc/apache2/sites-available/wordpress_symfony.conf
Alias /symfony /var/www/symfony/app/public
<Directory /var/www/symfony/app/public>
AllowOverride All
Require all granted
Allow from All
FallbackResource /index.php
</Directory>
<Directory /var/www/symfony/app/public/bundles>
FallbackResource disabled
</Directory>
<Directory /var/www/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin me#myemail.com
DocumentRoot /var/www/wordpress
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Also I added the symfony/apache-pack with composer which added this .htaccess in the symfony public directory. The docs said I can get improved performance by moving all these rules into my .conf file and disabling overrides:
# /var/www/symfony/app/public/.htaccess
DirectoryIndex index.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
I have Bitnami LAMP stack running on AWS. I have installed Wordpress in a folder called /wordpress/ using a downloaded Bitnami installer. It is visible publicly through the url: 11.11.111.11/wordpress/. I have set up an A Record for a domain name to point to the IP address. The result is that the site now is visible through the URL: mydomain.com/wordpress/.
Problem is that I want it to be visible via the url: mydomain.com (without the /wordpress/ folder).
I have tried everything that I have found on the topic for 2 days and simply cannot solve this seemingly simple task. I'm happy to provide more info on request. Please can someone help!
EDIT
I have the following two Apache configuration files:
opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf
with content:
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
<VirtualHost *:443>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
SSLEngine on
SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
opt/bitnami/apps/wordpress/conf/httpd-app.conf
with content:
RewriteEngine On
RewriteRule /<none> / [L,R]
<IfDefine USE_PHP_FPM>
<Proxy "unix:/opt/bitnami/php/var/run/wordpress.sock|fcgi://wordpress-fpm" timeout=300>
</Proxy>
</IfDefine>
<Directory "/opt/bitnami/apps/wordpress/htdocs">
Options +MultiViews +FollowSymLinks
AllowOverride None
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
<IfDefine USE_PHP_FPM>
<FilesMatch \.php$>
SetHandler "proxy:fcgi://wordpress-fpm"
</FilesMatch>
</IfDefine>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [S=1]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</Directory>
Include "/opt/bitnami/apps/wordpress/conf/htaccess.conf"
The result is that mydomain.com (registered at Godaddy) points to the root and not the wordpress directory.
My understanding of Apache is that vhosts allows you to point a domain to a document root folder and have multiple domains pointing to a single server IP address. So I don't see why this does not work.
I found the solution. Maybe this can help someone.
Do not use the /opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf config file, but instead use the /opt/bitnami/apps/wordpress/conf/httpd-prefix.conf and run the following command:
sudo /opt/bitnami/apps/wordpress/bnconfig --appurl /
Normal VHOST:
<VirtualHost *:80>
DocumentRoot /var/www/html/app/current/web
ServerAdmin me#app.foobar
ServerName app.foobar
ServerAlias www.app.foobar
<Directory /var/www/html/app/current/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options Indexes FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !HTTP/1.1$
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
</IfModule>
</VirtualHost>
HTTPS VHOST:
<VirtualHost *:443>
DocumentRoot /var/www/html/app/current/web
ServerName app.foobar
ServerAdmin me#app.foobar
<Directory /var/www/html/app/current/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite>
Options Indexes FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !HTTP/1.1$
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
SSLEngine on
SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
SSLCertificateFile /ssl/app.foobar/app.foobar.crt
SSLCertificateKeyFile /ssl/app.foobar/app.foobar.key
SSLCACertificateFile /ssl/app.foobar/app.foobar.ca-bundle
</VirtualHost>
As the title says when I use regular port 80 the urls are rewritten to use app.php but when I try to use https port 443 I get a directory listing instead. How do I get the url rewritten with https like it does with http?
I solved this by using the FallbackResource directive available in Apache 2.2.16+.
In the official Symfony docs this directive is not used to remain backwards compatible with older version of Apache. Discussion is here.
Code example:
<Directory /var/www/html/app/current/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
FallbackResource /app.php
</IfModule>
</Directory>
Here's an example of a page that works perfectly fine on the dev env and returns a 404 error on the prod env
Not Found
The requested URL /app/reporter/ was not found on this server.
Apache/2.4.7 (Ubuntu) Server at symfony.dev Port 80
don't let yourself confuse by the /app/ route, this in a real route and has nothing to do with app.php
running php app/console router:debug --env=prod does confirm there's no problem with router :
[router] Current routes
Name Method Scheme Host Path
reporter ANY ANY ANY /app/reporter/
Of course, before posting this message, I :
cleared the cache, with console cache:clear --env=prod, as well as directly deleting cache files but this didnt change anything.
double-checked mod_rewrite was on in phpinfo
Anyway, my guess is the error comes more from Apache so here's my conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName symfony.dev
SetEnv SYMFONY__TENANT__ID "123"
DocumentRoot /var/www/html/Symfony/web
# <Directory />
# Options FollowSymLinks
# AllowOverride None
# </Directory>
<Directory /var/www/html/Symfony/web >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error-symfony.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access-symfony.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
in /var/www/html/, there's only a symlink:
lrwxrwxrwx 1 root root 29 mai 13 2014 Symfony -> /home/me/path/to/symfony
and i didnt change anything in the default symfony /web/.htaccess :
without comments for readability's sake
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
Apache error log confirmed the error came from there :
[negotiation:error] [pid 1583] [client 127.0.0.1:44590] AH00687: Negotiation: discovered file(s) matching request: /var/www/html/Symfony/web/app (None could be negotiated).
As my understanding of Apache is seriously limited, i google the error and found this topic :
http://www.bennadel.com/blog/2218-negotiation-discovered-file-s-matching-request-none-could-be-negotiated.htm
So i ended up simply removing the MultiViews option of my vhost conf and it solved it.
As the above give link is mentionning,
This goes to show you how bad it is to simply enable settings when you are not sure what they do.
I am new to server deployment and I have recently deployed my symfony website to a ubuntu based server. In order to run my website without specification of app.php I added DirectoryIndex app.php in my apache conf so my website is visible on www.abc.com however any other link is not working;
for example the link below does not work
www.abc.com/route
Any help will be highly appreciated!
If you are on ubuntu and have root access, try adding this virtualhost into /etc/apache2/apache2.conf
<VirtualHost *:80>
ServerName abc.com
ServerAlias abc.com
ErrorLog /var/log/httpd/abc.com.log
DocumentRoot /var/www/html/abc.com/web/
<Directory /var/www/html/abc.com/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>