Setting up an Apache VirtualHost for Symfony - symfony

Admittedly I am utterly new to Symfony and I am irritated.
I am using the docu here: [0]. After setting everything up with "symfony/apache-pack" I get the ".htaccess" file with heaps of stuff in the "/public" directory. Now I wanted to be smart and moved all the rewrite rules to a proper VirtualHost and deleted the "htaccess" file. BANG, the required script files are not being loaded from the vendor directory and not style appear on the website. After killing all rewrite rules from the VirtualHost we website is up and running again.
Because of this sentence "A performance improvement can be achieved by moving the rewrite rules from the .htaccess file into the VirtualHost block of your Apache configuration and then changing AllowOverride All to AllowOverride None in your VirtualHost block." I am confused now since it suggests that I imperatively need rewrite rules for Symfony.
Note that I changed to AllowOverride None.
Can anyone shed some light onto this. I somehow feel that I am doing something dead wrong.
[0] https://symfony.com/doc/current/setup/web_server_configuration.html#web-server-apache-mod-php

Related

GCP: install mod_headers

It seems my server setup does not support headers in .htaccess
When I try to add this below code in .htaccess file, My site breaks.
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|svg|js|css|swf)$">
Header set Cache-Control "max-age=84600, public"
</filesMatch>
So my question is how do I install mod_headers in the GCP where my apache server is.
For the httpd.conf file: following is the tutorial
https://www.onepagezen.com/add-expires-headers-wordpress-bitnami/
But my server uses apache2.conf file instead of the httpd.conf
Can't find the solution, any inputs?
Man, I've had the same issue.
First off, next time you setup a wordpress via GCP, try out KUSANAGI OS, incredibly fast.
You need to make sure you put the FilesMatch config in the right spot.
httpd/apache2 and the way they load conf seems to be rather complex, so I can't provide a specific reason as why it doesn't work when you place it.
BUT!
according to: https://serverfault.com/questions/648262/filesmatch-configuration-to-restrict-file-extensions-served
you might have a chance by trying to place it in v_host.conf, as per:
The FilesMatch directive is applied against the "directory" hit prior to the mod-dir
DirectoryIndex directive assignment to "index.htm." As a result, a "null" condition
must pass the test in order for the request to be handled. With that, this set up
(all the same except for this change to the V_HOST.conf file) works:...

Wordpress Apache2 mod_speling not working

I am in the process of migrating my site to Wordpress from IIS.
I have run into an issue:
I have URL's that are a mix of upper and lower case that reference images. These URL's are getting a 404 because the case of the URL does not match the case of the file location.
For example, in my article I have a URL:
https://aaa.bbb.com/wp-content/migrate/ABC/abc.png
The file this is referencing is: /var/www/aaa/wp-content/migrate/abc/abc.png
When I change the URL to the same case as the file, it works, however how can I make it ignore the case of the folder on disk?
I tired the mod_speling module by putting this into /etc/apache2/apache2.conf but this just does not work for me. Also tried putting this into .htaccess in the root of my web directory but that made no difference.
<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>
I have read various threads on here but I'm completely stuck.
I managed to find a work around to this.
I ended up writing a rewrite rule in the VirtualHost file to rewrite everything to lowercase apart from anything within the directory of assets imported from Windows.

Wordpress on Nginx server - .htaccess vs. nginx.conf

I have recently changed from Apache to Nginx server and running a Wordpress installation that was migrated onto this new Nginx server.
I only just realised that (the server provider forgot to mention) that the .htaccess file is no longer supported and shouldn't be used with Nginx.
Instead the nginx.conf file should be used. I know I can convert the contents of my current .htaccess file to nginx.conf using one of the convertors, but I don't even have the nginx.conf file.
Can I just create one?? And If I create one, do I place it into the root where currently my .htaccess file is??
Do I then delete the existing .htaccess file?
How should I go about this?
You definitely have nginx.conf - without it, your site wouldn't work. It is in /etc/nginx/ folder, and some additional configs can exist there and in subfolders.
Standard recommendations for WordPress with nginx you can find here in Codex. But if your site works, you have nothing else to do.
Unlike Apache with .htaccess files, nginx does not use any configuration files in WordPress folders. Everything is centralized in /etc/nginx/.
.htaccess files are ignored by nginx and can be deleted or kept in WordPress folders - it doesn't matter.
However, if you have some non-standard tuning in .htaccess files, you should implement relevant directives in nginx conf files. Convertors not very good for it, and produce errors sometimes, unfortunately. You should learn Apache rules used and create similar for nginx by yourself.

Enable open directory (folder browsing) .htaccess and httpd.conf

I am running WordPress on an AWS instance. I would like to open up a single directory on my server to allow folder browsing.
I have tried adding an .htaccess file to folder with the line
Options +Indexes
I have also tried modifying the httpd.conf file in /opt/bitnami/apache2/conf and adding
<Directory "/publicFolder">
Options +Indexes
AllowOverride All
Require all granted
order allow,deny
Allow from all
</Directory>
I have tried various combinations of the above options, but nothing seems to work. I have made sure to reboot the AWS instance after updating httpd.conf.
When I try to access the folder, I get a default WordPress page with the message "OOPS! THAT PAGE CAN’T BE FOUND." It is probably a simple mistake, but this is all new to me.
Thanks!
Directory is used for absolute file system paths. Make sure you speficy the whole path instead of just the relative path from documentroot.
Extra Note: Don't mix 2.2 and 2.4 directives. Remove Order/Allow directives.

Expires headers on an Amazon EC2 with Bitnami Wordpress

I'm working with a client who has a Wordpress installation (via Bitnami) set up on an Amazon EC2. I didn't put this together, and for background I am a Front-end Developer who is used to cPanel and has limited knowledge for the command line.
I'm trying to modify the expires headers to improve the speed of the client's site. Following this tutorial (http://www.theitbaby.com/wordpress/2013/10/14/optimizing-bitnami-for-pagespeed-insights-and-gtmetrix/) I was looking for the htaccess.conf file in my opt/bitnami/apps/wordpress/conf/ folder, however none existed. Do I make my changes in the httpd-app.conf file?
Alternatively I saw a few other resources out there with a line to include the htaccess.conf file added to httpd-app.conf - something like
Include /opt/bitnami/apps/wordpress/conf/htaccess.conf
Do I add this to the httpd-app.conf file and then create htaccess.conf and work there? Sorry for the confusion, just looking for some direction as I try to do my typical performance boost work.
So the option what you are describing: creating and htaccess.conf file and then adding it as an Include statement in the httpd-app.conf file under /opt/bitnami/apps/wordpress/conf/ is correct.
Make sure your Include statement is within the Directory directive and in the htaccess.conf file you don't need to have the Directory directive:
<Directory "/opt/bitnami/apps/wordpress/htdocs">
...
Include /opt/bitnami/apps/wordpress/conf/htaccess.conf
...
</Directory>
You can also add the pagespeed configs directly to the http-app.conf file if you'd like to inside the Directory directive too.
There's another option, but not necessarily popular if you have access to the main apache configuration files. You can create a .htaccess file under /opt/bitnami/apps/wordpress/htdocs and put your pagespeed statements there. In this care you need the following statement preconfigured by the sysadmin in the http-app.conf file.
<Directory "/opt/bitnami/apps/wordpress/htdocs">
...
AllowOverride All
...
</Directory>
You can read more about .htaccess here: http://httpd.apache.org/docs/current/howto/htaccess.html
Hope this helps.

Resources