httpd subdomain 404 error

I have a working site at on the Top level of a domain, I now want to add a subdomain on the same domain and the same server.

The files for this site are located in the public html folder (/var/www/html)

I have the following virtualhosts/directory config in httpd.conf

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/joomla3
    ServerName support.somesite.com
    ErrorLog logs/support.somesite.com_error.log
    CustomLog logs/support.somesite.com-access_log common
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/moodle
    ServerName support.somesite.com/moodle
    ErrorLog logs/moodle.error.log
    CustomLog logs/moodle.access.log common
</VirtualHost>

<Directory "/var/www/html/moodle">
DirectoryIndex index.php
AcceptPathInfo on
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

No errors are reported on the start/restart of httpd

Nothing is reported in the httpd error log. The below entry is shown in the Access log so the request is reaching the webserver but appears to be not being handled properly by the webserver.

192.168.4.202 - - [05/Jan/2015:12:49:14 +0000] "GET /moodle HTTP/1.1" 404 290

I have configured something similar before but I can't figure out the problem here. I might have missed something obvious, Can you see where the problem is, Thanks?

I am running CentOS 6.5 for reference.

Malformed Apache requests

I am facing an issue where the Apache requests are malformed and is causing unusual behavior with the application. We have Webcache servers in front of Apache webservers. The requests in the Webcache servers are fine but they end malformed at Apache webservers.

Request in Webcache access log: Request is well formed with GET or POST (xx.xx.xx.xx - - [Timestamp] "GET /abc/def.htm HTTP/1.1" 501 559 "referrer URL" "browser/5.0 (Linux; U; Android 4.2.2; locale; SM-G386F Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 " "" 0.009315)

Corresponding request at Apache webserver is malformed as yy.yy.yy.yy xx.xx.xx.xx - - [timestamp] "GET /abc/def.htm HTTP/1.1" 501 990 "referrer URL" "-"

Some characters are getting added before the actual request ("GET /abc/def.htm HTTP/1.1") and such requests are not getting blocked/ handled at Apache but are making it to the Application servers that are behind the webserver.

Apache version: Apache/2.2.27 OS: SunOS

Please let me know if anyone has faced such an issue and how can this be handled.

Thanks

Linux Performance issue High disk IO r/w [on hold]

Need your help n determining my server issue. My site is intermittently slow.

Following is the iostat output.

iostat
Linux 2.6.32-504.3.3.el6.x86_64      01/05/2015      _x86_64_        (16 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           8.77    0.09    1.27    0.05    0.00   89.81

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             141.03      1011.83      3668.84  124475718  451342400

Is this load normal for a 12GB RAM instance with 16 processor cores?.

Thanks

How to redirect to a URL with a query string?

I've seen questions regarding redirecting a URL with a query string to a new URL that doesn't contain a query string.

Unfortunately I have to do this in reverse, my knowledge of redirecting in Apache isn't good, and I can't find any information about doing this.

So for example I need to redirect something like:

/news/news-item

to:

/news?item=news-item

The new URL structure is obviously not ideal, but this is something that is out of my control.

I've tried:

RedirectMatch 301 /news/news-item http://www.example.com/news?item=news-item

But obviously this doesn't work.

From what I understand I need to use RewriteRule, can somebody point me in the right direction?

A big issue with re-direction via .htaccess in some complex case

I have a web directory site that was previously in the root folder, but because of having to re-develop the site, I moved this to a folder, a few days ago so it is at http://bit.ly/1v5wwlA. Google on the hand, the primary provider of guests still has thousands of links it assumes are still located in root folder & so I have been getting hundreds of page not found errors.

At the time I moved this directory, I placed a Wordpress-based site in the root folder & submitted site maps for both to Google, though I guess it will take a while before the urls are in the Google db.

For the old site, I still need it for a couple of months and moved it to site.com/oldsite, ... all links are still valid only that, they have the directory "oldsite" appended to site.com/oldsite. So for a link in the Google database like site.com/countryA/xxx/abc/123.html, this becomes site.com/oldsite/countryA/xxx/abc/123.html. The regional directory covers about 20 different countries.

Links like "site.com/countryA/xxx/abc/123.html" or like site.com/countryC/xxx/axyzc/atrez/187.html will indeed never exist again & until the old site is discontinued, will have that directory added as explained above. I wonder how to best deal with that.

Is it for example possible or does it make sense to say use some code in .htaccess for all links directed to site.com/countryA/.../.../abc.html, or site.com/countryB/.../foo.html, or ... site.com/countryX by Google to be redirected to their new locations site.com/oldsite/countryA/.../.../abc.html, site.com/countryB/.../foo.html, ... site.com/oldsite/countryX/ .... without creating any error messages?

If so, what exactly would this .htaccess code look like? (Not a coder ;) ). If that is possible, I can add this code, if I had it.

I must add that, the directories like countryA, countryB, etc do not exist in root folder & are created dynamically. This is because I saw in some tutorial I think that a directory named in some .htaccess code for re-direction must exist & have content, or something like that.

Since the new site in root folder is Wordpress-based, I thought I could use one of the many re-direction page not found plugins, but most of these mostly deal wit simple re-direction or work for WP sites, but the directory in this case is not WP-based.

The link structure generally for directory links only changes with the new folder being placed after ".com" so we have something like ".com/countryname/..." changing to ".com/oldsite/countryname/...", otherwise everything is the same. There are otherwise thousands of listings in total, but each listing basically begins with a country directory, etc so we have something like => site.com/countryname/main-category/subcategory/.../abc.html now => site.com/oldsite/countryname/main-category/subcategory/.../abc.html, etc

The writer of the directory script says something like they can "add many redirection rules to the .htaccess file of your WordPress. We will need to add these rules in the way they will not effect WordPress links. " ... but the hefty price frightened me & made me come to request for help here, which I would appreciate.

I would do this myself if I could code ... ,)

I can also clarify specific issues if asked.

Any assistance would be very much appreciated.

Kind regards & thank you in advance

How do I use JCIFS with apache VFS to access an SMB URL – part 2?

I had the same problem: How do I use JCIFS with apache VFS to access an SMB URL?

... after including commons-vfs-sandbox-2.1-SNAPSHOT.jar in the classpath I now get this exception:

Exception in thread "main" org.apache.commons.vfs2.FileSystemException: Could not determine the type of file "smb://10.10.18.210/CIFS/123/asd".
    at org.apache.commons.vfs2.provider.AbstractFileObject.attach(AbstractFileObject.java:1522)
    at org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:489)
    at org.apache.commons.vfs2.provider.AbstractFileObject.exists(AbstractFileObject.java:477)
    at VFSTest.main(VFSTest.java:19)
Caused by: jcifs.smb.SmbAuthException: Logon failure: account currently disabled.
    at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:549)
    at jcifs.smb.SmbTransport.send(SmbTransport.java:667)
    at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:390)
    at jcifs.smb.SmbSession.send(SmbSession.java:218)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176)
    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    at jcifs.smb.SmbFile.connect(SmbFile.java:954)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    at jcifs.smb.SmbFile.queryPath(SmbFile.java:1335)
    at jcifs.smb.SmbFile.exists(SmbFile.java:1417)
    at jcifs.smb.SmbFile.isDirectory(SmbFile.java:1490)
    at org.apache.commons.vfs2.provider.smb.SmbFileObject.createSmbFile(SmbFileObject.java:118)
    at org.apache.commons.vfs2.provider.smb.SmbFileObject.doAttach(SmbFileObject.java:70)
    at org.apache.commons.vfs2.provider.AbstractFileObject.attach(AbstractFileObject.java:1505)
    ... 3 more

Please advice.

PHP unable to create directories or files on AWS EC2 instance running RHEL v7.0

After having installed Apache and PHP on a fresh EC2 instance running Red Hat Enterprise Linux and after going over all the instructions about setting file permissions in Amazon's tutorial on installing a LAMP stack, running scripts that contains calls to functions such as mkdir or file_put_contents from a browser continue to fail due to inadequate file permissions, as per the received errors:

Message:  file_put_contents(./dist/js/1be6169d48b8d39917769068f05f9972.js): failed to open stream: Permission denied

In addition to the tutorial from Amazon, after noticing that the set group | user pair within the httpd.conf file is Apache | Apache, I've also added the user Apache to the www group, but to no success.

What is the deal with the file permissions errors?

Apache PHP with XCache, do I need to optimize Apache modules?

In Centos 6.5 machine, 3 CPU total 9 GHz, 8 GB RAM, Plesk 12. PHP 5.4.36, Apache/2.2.15, Apache run PHP as PHP module, XCache 3.2.0.

Currently I see 180-200 simultaneous visitors in popular hours. 40-50 simultaneous visitors average.
Current httpd.conf values:

Timeout 60
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

xcache.ini values:

xcache.size  24M
xcache.count 1
xcache.slots    8K
xcache.var_size 1M
xcache.var_count    1

xcache screenshot 1
xcache screenshot 2

I'm checking what can I do more to optimize Apache. I checked top state, it's like this:
Top results image
Note that each Apache process takes 55-100 mb, where shared memory for each httpd process is 18m.

I'm curious that whether disabling some Apache modules is good or bad.
Because of XCache is it meaningful to disable unused modules ?
Or is it not logical to disable them because in peak times system creates 30-32 httpd processes and it doesn't take too much ?
Currently active apache modules are like this: screenshot

httpd process' memory, cpu and count graph

Edit:
I restarted httpd process and I see following values: top image
Note that average httpd process decreased 67 mb to 34 mb.

skip subdirectory when replacing underscore to hyphen from urls using .htaccess code

I have to replace _ (underscore) with -(hyphen) from urls for the SEO purpose.I have hundreds of files so I can't change filenames one by one.So I wrote some .htaccess code to do that.

This is the code I am using.

RewriteRule ^([^_]*)_(.*)$ /$1-$2 [R=301,L] 

It successfully changing my urls from underscore to hyphen.

Now I have one subdirectory named "administrator" and I dont want this directory urls to replace from underscore to hyphen.

So I want to skip urls of this directory to skip from .htaccess code.

Please help me how to skip this.

Thanks!

Running multi tenancy on same port with apache web server – NameBasedVirtualHsoting

I have been working to get multi tenancy running on same port on same ip address. I have achieved the objective with different ports but I can't run the same on one port only. Here the apache web server redirects the request to weblogic host on same machine. I have gone through multiple guides but it is not working as expected. I have configured two virtual hosts for same port with URL as localhost:9010/site1 and localhost:9010/site2. The configuration in httpd.conf is mentioned below. I don't know where I have made the mistake so I have kept whole configuration file.

    Define SRVROOT "D:\Apache24"
    ServerRoot "${SRVROOT}"


    Listen 9010
    #Listen 9011


    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 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 cgi_module modules/mod_cgi.so
    LoadModule dir_module modules/mod_dir.so
    LoadModule env_module modules/mod_env.so
    LoadModule headers_module modules/mod_headers.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 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 setenvif_module modules/mod_setenvif.so
    LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
    LoadModule ssl_module modules/mod_ssl.so
    LoadModule xml2enc_module modules/mod_xml2enc.so

    <IfModule unixd_module>
    User daemon
    Group daemon
    </IfModule>

    <Directory />
            AllowOverride ALL
            Require all granted
    </Directory>

    DocumentRoot "${SRVROOT}/htdocs"
    <Directory "${SRVROOT}/htdocs">
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>

    <IfModule dir_module>
            DirectoryIndex /home
    </IfModule>

    <Files ".ht*">
            Require all denied
    </Files>

    ErrorLog "logs/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 "logs/access.log" common

    </IfModule>

    <IfModule alias_module>
            ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"
    </IfModule>

    <IfModule cgid_module>
    </IfModule>

    <Directory "${SRVROOT}/cgi-bin">
            AllowOverride None
            Options None
            Require all granted
    </Directory>

    <IfModule mime_module>
            TypesConfig conf/mime.types
            AddType application/x-compress .Z
            AddType application/x-gzip .gz .tgz
            AddType text/css .css
            AddType text/javascript .js
    </IfModule>

    <IfModule proxy_html_module>
    Include conf/extra/httpd-proxy-html.conf
    </IfModule>

    <IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
    </IfModule>

    ProxyRequests on

    ProxyIOBufferSize 65536


    SSLProxyEngine on

    ErrorDocument 403 /home
    ErrorDocument 404 /home

    NameVirtualHost *:9010

    <VirtualHost *:9010>
        ServerName localhost:9010/site2
        LogLevel info

        <Location />
            SetHandler weblogic-handler
        </Location>

        ProxyPass /site2 http://localhost:7001
        ProxyPassReverse /site2 http://localhost:7001
        ProxyPass /Login.zul http://localhost:7001/Login.zul
        ProxyPassReverse /Login.zul http://localhost:7001/Login.zul

        <IfModule mod_weblogic.c>
            WebLogichost localhost
            WebLogicPort 7001
            debug OFF
            FileCaching OFF
            MatchExpression *
            KeepAliveSecs 540
        </IfModule>
    </VirtualHost>


    <VirtualHost localhost:9010>
        ServerName localhost:9010/site1
        LogLevel info

        <Location />
            SetHandler weblogic-handler
        </Location>

        ProxyPass /site1 http://localhost:7001
        ProxyPassReverse /site1 http://localhost:7001
        ProxyPass /Login.zul http://localhost:7001/Login.zul
        ProxyPassReverse /Login.zul http://localhost:7001/Login.zul
        <IfModule mod_weblogic.c>
            WebLogichost localhost
            WebLogicPort 7001
            debug OFF
            FileCaching OFF
            MatchExpression *
            KeepAliveSecs 540
        </IfModule>
    </VirtualHost>

Whenever I use different ports for site1 and site2, it runs fine. But keeping the same port does not work for me. Only the virtualhost defined first works and the other returns eorro 404. Also I found that it is called as Name based virtual hosting. The guides suggests that NameVirtualHost directive should be configured. I have also added the same.

Please help... Thank you in advance..