Kill a hung EventMachine WebSockets server

Sometimes (very often) when I restart Apache, my Rails application running in Passenger fails to open port for Web Sockets server running on top of EventMachine:

em.run ... port is in use or requires root privileges

It proves that old Web Sockets server hung while doing service httpd stop and is taking the port.

How to make sure that on stopping Apache all the resources are freed?

EventMachine.run {
   EventMachine::WebSocket.start(:host => '0.0.0.0', :port => EnvParams.web_sockets.port) do |ws|
      #..............
   end
}

Apache ignores Document root

I have the following VirtualHost file:

 <VirtualHost *:80>

        ServerName www.domain.com
        ServerAlias domain.com

        ServerAdmin [email protected]
        DocumentRoot /var/www/html/xxx/public

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>

Apache seems to ignore my Document Root and shows me instead a file which is located in the

/var/www/html

directory. Is there anything I need to change in order to get this running?

Migration to liveserver laravel shows first page but no route is working (except /)

So I've just moved a laravel project from localhost to a live server and I can open the page if I type the address. DB connection works, everything else is fine. Only thing that doesn't work are all of my routes except for the first page.

I've tried a couple of things, such as changing this line:

'url' => 'http://localhost', 

to my pages address, have tried the both different .htaccess files laravel provides... Nothing seems to help.

I'm using apache 2.4.10, php 5.6.2 on ubuntu 14.04 LTS, no C-panel, no Plesk.

Can someone tell me what I've been missing. Thanks!

Point subdomain to Port [on hold]

What i want is for paste.mysite.com to show the contents of mysite.com:7777

I have a script that runs on port 7777 that i would lke the world to access. I know about vhost and whatnot but cannot get subdomain to point to correct port.

I have tried the following.

< VirtualHost *:80>
ServerName paste.mysite.com
ProxyPass / http://127.0.0.1:7777/
ProxyPassReverse / http://127.0.0.1:7777/
</VirtualHost>

What am i missing here?

Also tried this:

<VirtualHost *:80>
ServerName paste.example.com
redirect / http://example.com:7777/
< /VirtualHost>

Internal Server Error While Uploading Files

I'm working on a yelp-like listings website where a provider can upload his company logo amongst other details. This works brilliantly on my local system, but when i put it on apache passenger, it shows an internal server error.

Here are the givens that i've found:

  • params are working fine and have been passed successfully
  • File.* are working fine
  • No db/activerecord issues
  • FileUtils.copy and FileUtils.mkdir_p seems to be the issue

I'm guessing that this is a permissions issue? if so, how do i go about rectifying it?

Here is the code:

    include FileUtils::Verbose
    set :public_folder, File.join(File.dirname(__FILE__), 'public')
    set :files, File.join(settings.public_folder, "images/#{Time.now.strftime('%Y')}/#{Time.now.strftime('%m')}")

    if params[:file][:filename] && params[:file][:tempfile]
        filename = "#{params[:company_name]}_" + params[:file][:filename]
        file = params[:file][:tempfile]

        if File.directory?(settings.files)
            copy(file.path, File.join(settings.files, filename))
        else
            mkdir_p(settings.files)
            copy(file.path, File.join(settings.files, filename))
        end
        file_path = "/images/#{Time.now.strftime('%Y')}/#{Time.now.strftime('%m')}/#{filename}"
        provider.update_attribute("file_name", file_path)
    end

RewriteRule Needed

i recently built my own web page. Now i want to use RewriteRules to be able to e.g. call "www.exampleurl.de/events" and let the server display "www.exampleurl.de/page/index.php?task=events". In the future there will be alot more pages, so a dynamic rule is needed.

The server structure looks like this:

  • css
    • core.css
  • image
    • header.png
    • navbar.jpg
  • page
    • events.php
    • home.php
    • index.php
  • .htaccess

My .htaccess file looks like this by now:

<IfModule mo_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteRule ^(.*)$ page/index.php?task=$1 [L]
</IfModule>

I hope you can help me! Thank you

RegEx to remove part of a file name

To help control caching on our site I'm looking to name some of the resource files (css & js) with a version number in their url (eg. site.v104.css) which will allow us to push updates through to users when we want, but to reduce maintenance and renaming the actual file each time I want to setup a .htaccess rule which will automatically rewrite these urls from the browser and present the content from its actual location.

If the file is in the css folder and ends with .vNNN.css then I want to server up the content from .vNNN, so for example if the file in the HTML of the site is: "site_media/css/site.v104.css" then I want it to load the content from "site_media/css/site.css" and the below rule works for this.

In my .htaccess file I have added the following line:

RewriteRule ^(site_media/css/.*).v\d+(\.css)        /$1$2           [U,L]

However if I have a file with multiple '.' (eg. "site_media/css/site.prod.v104.css") then it doesn't work it returns "site_media/css/site.css" instead of "site_media/css/site.prod.css".

I could live without checking that the file is in the correct folder but I want to be safe and control exactly which ones it replaces.