Jump to content
n0sleeves

Need help with Apache on a LAMP stack to work with PW .htaccess and Virtual Hosts

Recommended Posts

I have been pulling my hair out for over a week now and frankly can not study anymore because I am exhausted and on the verge of throwing in the towel. I have switched to a Linux dev enviroment recently (Manjaro which is Arch based) and love everything about it. It's another story why I made the switch from Windows but I can tell you that I have never experienced trouble before because I was using Wamp and everything just seemed to work out the box. With setting up Apache myself on this particular Linux distro, things are a "whole lot different".

So here goes:

I got virtual hosts working with Apache 2.4.10 and everything is fine; PHP 5.6 works, my /etc/hosts files are pointing correctly and all that good stuff. I believe I have enabled all the required modules which Processwire needs (and then-some) : Mod_Rewrite being the most important. However, when I download my Production files (live server) onto  my Development machine, it doesn't go as smooth as the WAMP days :( I have narrowed it down to something which must not be configured correctly for .htaccess to take affect. Again, this really is my first attempt (although been at it for over a week) to get a LAMP stack installed so it's probably something I am not understanding or doing right. Btw, MySQL (MariaDB) is working correctly and all the databases have been imported from my Production .sql file.

Here is my virtual host file: Maybe something in here isn't correct.

<VirtualHost *:80>
    DocumentRoot /srv/http/site2.dev
    ServerName dev.site2.com
    ErrorLog /var/log/httpd/site2_log

    <Directory /srv/http/site2.dev>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

The .htaccess directives are for Processwire 2.3. I have never had to touch them before, but I tried commenting / un-commenting almost everything which has been reccomend thus far and nothing has worked :(  This 500 Internal Server Error will not leave me!

Thanks so much for any help / tips you can provide.
Thank You

 

Share this post


Link to post
Share on other sites

Sorry you are having such a rough time of it - it can seem like voodoo sometimes :)

Have you tried a simple index.html file in the root of a virtual host DocumentRoot directory? Does that work? Is it just a PW install that is giving you the 500 error?

I could be completely off, but is it possible it's the period in your site2.dev folder name?

PW has this restriction, although it is for dirs "beginning" with a period, so probably not.

  # -----------------------------------------------------------------------------------------------
  # Access Restrictions: Keep web users out of dirs that begin with a period
  # -----------------------------------------------------------------------------------------------

  RewriteRule "(^|/)\." - [F]

Share this post


Link to post
Share on other sites

May not be anything, however have you made a change in your config.php file to reflect the local website?

$config->httpHosts = array('www.yourlocalwebsite.com', 'yourlocalwebsite.com');

Share this post


Link to post
Share on other sites

Sorry you are having such a rough time of it - it can seem like voodoo sometimes :)

Have you tried a simple index.html file in the root of a virtual host DocumentRoot directory? Does that work? Is it just a PW install that is giving you the 500 error?

I could be completely off, but is it possible it's the period in your site2.dev folder name?

PW has this restriction, although it is for dirs "beginning" with a period, so probably not.

  # -----------------------------------------------------------------------------------------------
  # Access Restrictions: Keep web users out of dirs that begin with a period
  # -----------------------------------------------------------------------------------------------

  RewriteRule "(^|/)\." - [F]

Thanks for responding. I removed the period just for the hell of it but that didn't work. A plain PHP or HTML file inside the directory works fine. It's just PW (all of the site) which isn't getting picked up :/ This isn't a new install - it's a git clone from my live server.

May not be anything, however have you made a change in your config.php file to reflect the local website?

$config->httpHosts = array('www.yourlocalwebsite.com', 'yourlocalwebsite.com');

That wasn't in my config file so I added it (still no luck). You do mean the config file in my site directory, correct?

Share this post


Link to post
Share on other sites

I am working on Fedora 20.  May be this would help you. 

<VirtualHost *:80>
   DocumentRoot "/home/user-2/dev/php/ProcessWire/pwire-2"
   ServerName pwire-2.localhost
   # This should be omitted in the production environment
   SetEnv APPLICATION_ENV development
   <Directory "/home/user-2/dev/php/ProcessWire/pwire-2">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
       # New directive needed in Apache 2.4.3: 
       Require all granted
   </Directory>
</VirtualHost>

Thanks

------------------------------------------------------------------------

Edit: Add a comment for the new directive used for Apache 2.4.3 under <Directory> tag 

  • Like 2

Share this post


Link to post
Share on other sites

Have you gone through the list on Nico's troubleshooting page?

http://processwire.com/docs/tutorials/troubleshooting-guide/

Yes. No Luck

Thanks so much man for the links and taking the time to search for those. However, I have already been to each of those and tried everything they have said at least 5x it seems. I really have exhausted Google :/

Share this post


Link to post
Share on other sites

One Linux distro can be very different from another Linux distro in what comes pre configured or pre installed.

Sometimes when you finish a Linux distro installation you still have to install some packages or do configurations

for everything to work what you need. Example, I have become very fond of Linux Antix because it is both very

user friendly and fast on cheap motherboards. After doing a Linux antix installation your wifi does not show up

because you have to manually add the wlan card to the network configuration.

So maybe in your case simply installing another Linux distro might solve you from difficult to find configurations

that did not came during the Manjaro installation.

The Manjaro distro is based on Arch Linux so I recommend to go through this Lamp page step by step:

https://wiki.archlinux.org/index.php/LAMP

  • Like 3

Share this post


Link to post
Share on other sites

The other approach you may want to look at is installing Virtualmin/Webmin to control everything from setting up virtuals with set packages to creating samba shares and so on.

  • Like 1

Share this post


Link to post
Share on other sites
A plain PHP or HTML file inside the directory works fine. It's just PW (all of the site) which isn't getting picked up :/ This isn't a new install - it's a git clone from my live server.

This suggests to me that everything is set up ok from the apache side of things. Have you tried a fresh install of PW on this server to see if that goes ok? Maybe it will report what the problem is?

  • Like 1

Share this post


Link to post
Share on other sites

One Linux distro can be very different from another Linux distro in what comes pre configured or pre installed.

Sometimes when you finish a Linux distro installation you still have to install some packages or do configurations

for everything to work what you need. Example, I have become very fond of Linux Antix because it is both very

user friendly and fast on cheap motherboards. After doing a Linux antix installation your wifi does not show up

because you have to manually add the wlan card to the network configuration.

So maybe in your case simply installing another Linux distro might solve you from difficult to find configurations

that did not came during the Manjaro installation.

The Manjaro distro is based on Arch Linux so I recommend to go through this Lamp page step by step:

https://wiki.archlinux.org/index.php/LAMP

Good point. I was using Mint a while back with no problems, but once I switched to Manjaro, I haven't looked back due to it's speed and bare  enviroment. I know it comes at a cost of high frustration for some things but I'll give it just a wee bit longer before I consider switching again :/ I'm one of those types that wants to know "why" something isn't working. Nice to see another Nix user here!

I am working on Fedora 20.  May be this would help you. 

<VirtualHost *:80>
   DocumentRoot "/home/user-2/dev/php/ProcessWire/pwire-2"
   ServerName pwire-2.localhost
   # This should be omitted in the production environment
   SetEnv APPLICATION_ENV development
   <Directory "/home/user-2/dev/php/ProcessWire/pwire-2">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
       # New directive needed in Apache 2.4.3: 
       Require all granted
   </Directory>
</VirtualHost>

Thanks

------------------------------------------------------------------------

Edit: Add a comment for the new directive used for Apache 2.4.3 under <Directory> tag 

I have the same Virtual Host config. Thank you for providing this however.

The other approach you may want to look at is installing Virtualmin/Webmin to control everything from setting up virtuals with set packages to creating samba shares and so on.

Webmin looks like an interesting piece of software. Even though I prefer to keeping things in the command line as much as possible (I'm not even using PhpMyAdmin), I like the idea and premise. Thanks for sharing!

This suggests to me that everything is set up ok from the apache side of things. Have you tried a fresh install of PW on this server to see if that goes ok? Maybe it will report what the problem is?

That's what my next step is. I'll do that and let you know my results!

What is the value of 'AllowOverride' in your apache config file?

 I changed them all to "All". Still same results :/

Share this post


Link to post
Share on other sites

And the value (if any) of 'AccessFileName' in your config file?

When I had an AccessFileName in my config, Apache told me that it was no longer supported ???. So, I removed it.

Share this post


Link to post
Share on other sites

A fresh copy of Processwire installed on my machine with no trouble or errors reported. It was also installed on another virtual host with the same configs.  :mellow:

Not sure what gives at this point :/

Share this post


Link to post
Share on other sites

Sorry n0sleeves, I have no ideas for you.
 
Have you tried posting on the Manjaro forums or asking about this in #httpd on freenode?

Share this post


Link to post
Share on other sites

Please update?!

A lot of great suggestions were given and I tried them all but nothing worked. I basically ended up doing a fresh PW install. 

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By FrancisChung
      I was wondering if anyone has used AMPPS before? Seems like a decent MAMP replacement for Ubuntu, but I'm wondering if anyone can give their take or experiences on it.
       
    • By rareyush
      I moved my site to Google cloud platform and i am stuck some where.
      my homepage is working fine but when it comes to other pages it says 404 not found
      and when i add this on virtual host 
       
      <Directory "/var/www"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> or <Directory "/var/www"> AllowOverride All </Directory>  
          I receive internal server error 
       
       
       
      I tried comment out this line to but still same thing 
      # RewriteBase /
      and
        # RewriteRule ^(.*)$ /index.php?it=$1 [L,QSA]
    • By rolisx
      Hi Everyone
      I have a problem here. I have built a site with Processwire on localhost and then transferred to my customer's server. a) it's a windows server (unfortunately) and b) there is a domain-mapping for this site, the domain points to a folder of another domain. Sorry, I can't explain it any better, I don't really understand the different types of servers (why do they have to be different anyway...).
      My problem is, that I see the main website but not the admin page. Do I have to add anything to my .htaccess file?
      I also tried to include web.config file. Not .htaccess nor web.config file have an impact when changing its content. I really have no clue what to do!!
      Links: mcconnellacademy.ch, mcconnellacademy.ch/admin
      Thanks for any pointing in the right direction!
    • By Petra
      Hello everyone,
      I am a newbie in the world of website editing and I have been given a task to figure out how to redirect a long list of some old client's web pages which give 404 error. We have been able to redirect about two thirds of url's by using php database. Unfortunately the rest does not work, using php, due to containing special characters and the command I have tried to generate for couple of web pages, using the tool https://websiteadvantage.com.au/HtAccess-301-Redirect-Generator#heading-ToolResult  is not working using the .htaccess file.
      Would anyone be able to help with the following example?
      1) https://www.berlitzpraha.cz/en/eshop/individual-language-courses?orderby=product_name
      ... to be redirected to https://www.berlitzpraha.cz/en/language-courses-berlitz-shop-online/individual-language-courses-3

      command generated with the tool (not working):
      RewriteEngine On
      RewriteCond %{QUERY_STRING}  ^orderby=product_name$ [NC]
      RewriteRule ^en/eshop/individual-language-courses$ https://www.berlitzpraha.cz/en/language-courses-berlitz-shop-online/individual-language-courses-3? [R=301,NE,NC,L]
      2)
      http://www.berlitzpraha.cz/cs/skupinove-kurzy-jazyku/hledani/zkouset/function.implode ... to be redirected to https://www.berlitzpraha.cz/cs/skupinove-jazykove-kurzy-pro-firmy/
      command generated with the tool (not working):
      RewriteEngine On
      RewriteCond %{HTTP_HOST}  ^www\.berlitzpraha\.cz$ [NC]
      RewriteCond %{QUERY_STRING}  ^$
      RewriteRule ^cs/skupinove-kurzy-jazyku/hledani/zkouset/function\.implode$ https://www.berlitzpraha.cz/cs/skupinove-jazykove-kurzy-pro-firmy/? [R=301,NE,NC,L]
      3)
      https://www.berlitzpraha.cz/en/language-courses-berlitz-shop-online/virtual-language-courses?orderby=product_sku&showall=1 ... to be redirected to https://www.berlitzpraha.cz/en/virtual-language-courses-shop-online/virtual-language-courses-4

      RewriteEngine On
      RewriteCond %{QUERY_STRING}  ^orderby=product_sku&showall=1$ [NC]
      RewriteRule ^en/language-courses-berlitz-shop-online/virtual-language-courses$ https://www.berlitzpraha.cz/en/virtual-language-courses-shop-online/virtual-language-courses-4? [R=301,NE,NC,L]
       
      Thank you very much in advance.
      Petra
    • By VirtuallyCreative
      So being a LAMP server guy, recently at my work I've had to use Microsoft's' Azure Cloud to host some micro-apps of ours and I got to playing around with the platform. It's pretty nifty!
      Naturally, I tried to install ProcessWire to play around with Web Apps + SQL App Service to see what I can get away with on the Free Tier (rather then spinning up a full LAMP VM machine which is the way Bitnami installs ProcessWire, costing $60CAD/mo).
      Turns out installing ProcessWire is pretty smooth sailing except for one part: .htaccess mod_rewrite rules when you're not using Apache, as this is Azure Cloud so it's running PHP7 on IIS Microsoft Server and requires rewrite rules to be in a web.config file instead.

      Doing some digging, I found tools that convert .htaccess over to web.config and was curious if anyone with experience using Microsoft .NET could see if the rules from the .htaccess actually do translate in the same way when written in XML for web.config?
      Default ProcessWire v3.0 .htaccess file (comments, commented out commands removed):
      Options -Indexes Options +FollowSymLinks ErrorDocument 404 /index.php <Files favicon.ico> ErrorDocument 404 "The requested file favicon.ico was not found. </Files> <Files robots.txt> ErrorDocument 404 "The requested file robots.txt was not found. </Files> <IfModule mod_headers.c> Header always append X-Frame-Options SAMEORIGIN Header set X-XSS-Protection "1; mode=block" </IfModule> <FilesMatch "\.(inc|info|info\.json|module|sh|sql)$|^\..*$|composer\.(json|lock)$"> <IfModule mod_authz_core.c> Require all denied </IfModule> <IfModule !mod_authz_core.c> Order allow,deny </IfModule> </FilesMatch> <IfModule mod_php5.c> php_flag magic_quotes_gpc off php_flag magic_quotes_sybase off php_flag register_globals off </IfModule> DirectoryIndex index.php index.html index.htm <IfModule mod_rewrite.c> RewriteEngine On AddDefaultCharset UTF-8 <IfModule mod_env.c> SetEnv HTTP_MOD_REWRITE On </IfModule> RewriteRule "(^|/)\.(?!well-known)" - [F] RewriteCond %{REQUEST_URI} !(^|/)site-[^/]+/install/[^/]+\.(jpg|jpeg|png|gif)$ [OR] RewriteCond %{REQUEST_URI} (^|/)\.htaccess$ [NC,OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$) [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/install($|/.*$) [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets.*/-.+/.* [OR] RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$ [OR] RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$ [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets($|/|/.*\.php)$ [OR] RewriteCond %{REQUEST_URI} (^|/)wire/(core|modules)/.*\.(php|inc|tpl|module|info\.json)$ [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module|info\.json)$ [OR] RewriteCond %{REQUEST_URI} (^|/)(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md|textile)$ [OR] RewriteCond %{REQUEST_URI} (^|/)site-default/ RewriteRule ^.*$ - [F,L] RewriteCond %{REQUEST_URI} "^/~?[-_.a-zA-Z0-9/]*$" [OR] RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} !-d [OR] RewriteCond %{REQUEST_FILENAME} !(favicon\.ico|robots\.txt) [OR] RewriteRule ^(.*)$ index.php?it=$1 [L,QSA] </IfModule>  
      Converted web.config file:
      <rewrite> <rules> <rule name="www_mysite_com:non-80"> <match url="&quot;(^|/)\.(?!well-known)&quot;" ignoreCase="false" /> <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> </rule> <rule name="www_mysite_com:80" stopProcessing="true"> <match url="^.*$" ignoreCase="false" /> <conditions logicalGrouping="MatchAny"> <add input="{URL}" pattern="(^|/)site-[^/]+/install/[^/]+\.(jpg|jpeg|png|gif)$" ignoreCase="false" negate="true" /> <add input="{URL}" pattern="(^|/)\.htaccess$" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$)" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/install($|/.*$)" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/assets.*/-.+/.*" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/assets($|/|/.*\.php)$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)wire/(core|modules)/.*\.(php|inc|tpl|module|info\.json)$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module|info\.json)$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md|textile)$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)site-default/" ignoreCase="false" /> </conditions> <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> </rule> <rule name="www_mysite_com:80" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAny"> <add input="{URL}" pattern="&quot;^/~?[-_.a-zA-Z0-9/]*$&quot;" ignoreCase="false" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" pattern="(favicon\.ico|robots\.txt)" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php?it={R:1}" appendQueryString="true" /> </rule> </rules> </rewrite>
×
×
  • Create New...