Apache config problems for Roots.io/Bedrock + Capistrano - apache

I'm new with Roots.io/Bedrock, so please forgive me if im asking something stupid.
So currently I'm using Bedrock + Capistrano to deploy my wordpress site. The Capistrano part is working fine. My only problem is the Apache config.
How should I define the DocumentRoot to make Bedrock working?
Directory structure:
/var/www/mydomain.com/teszt/current -> /var/www/mydomain.com/teszt/releases/20141028115909
/var/www/mydomain.com/teszt/releases
/var/www/mydomain.com/teszt/repo
/var/www/mydomain.com/teszt/revisions.log
/var/www/mydomain.com/teszt/shared
My current Vhost file:
<VirtualHost *:81>
suPHP_Engine On
suPHP_ConfigPath /etc/php5/vhosts/mydomain.com/
suPHP_UserGroup devsunnywebhu vhostusers
AddHandler x-httpd-php .php .php3 .php4 .php5 .html
suPHP_AddHandler x-httpd-php
ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAdmin support#mydomain.com
AddDefaultCharset UTF-8
DocumentRoot /var/www/mydomain.com/teszt/current/web
<Directory /var/www/mydomain.com/teszt/current/web>
Options -Indexes +FollowSymLinks +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
SetEnvIf Remote_Addr "localhost" loopback
SetEnvIf Remote_Addr "::1" loopback
SetEnvIf Remote_Addr "ip6-localhost" loopback
LogLevel warn
ErrorLog /var/log/apache2/mydomain.com-error.log
CustomLog /var/log/apache2/mydomain.com-access.log combined env=!loopback
ServerSignature Off
</VirtualHost>
And im getting the following error from Apache:
File "/var/www/mydomain.com/teszt/releases/20141028115909/web/index.php" is not in document root of Vhost "/var/www/mydomain.com/teszt/current"

If somebody faces the same problem, its a suPHP caused error.
To solve it you need to disable check_vhost_docroot in the /etc/suphp.conf file.
check_vhost_docroot=false

Related

Custom http.conf for subdomains

I tried all the ways I knew, But...
Let me explain with an example what I want.
I have a blog service, with main domain and many domain pointers and subdomains.
Main domain: blog.com
Subdomains: sub1.blog.com, sub2.blog.com, sub3.blog.com and....
Domain pointers : domain1.com , domain2.com, domain3.com and...
Every domain redirect to a spacial subdomain with Php code
But, what is the problem?
When i add a Subdomain (for exapmle sub2.blog.com) to Sub Domains, in user httpd.conf create VirtualHost settings for All domain pointers (sub2.domain1.com, sub2.domain2.com, sub2.domain3.com and...) ... But i don't want it!!!
And what is the big problem ???
for example if i had 600 domain pointer, with create 500 subdomains, httpd add 3000000 (500x600) VirtualHost settings to user httpd.conf file. and httpd.conf file size will be very large.
What will be the result?
A big time needed to create httpd.conf file
Server load coming to very High
Apache server Crash
And...
I want Subdomain VirtualHost just create for Main Domain (sub2.blog.com) , not for Domain Pointers... I don't need sub2.domain1.com or others...
What can i do for this ? Help me Guys
Can I change rewrite_confs script to do what i want it?
Or any way....???
Here the VirtualHost settings that happened to me:(
<VirtualHost 88.88.88.88:80 >
ServerName www.sub1.domain1.com
ServerAlias www.sub1.domain1.com sub1.domain1.com
ServerAdmin webmaster#blog.com
DocumentRoot /home/blog/domains/blog.com/public_html/sub1
UseCanonicalName OFF
<IfModule !mod_ruid2.c>
SuexecUserGroup blog blog
</IfModule>
CustomLog /var/log/httpd/domains/blog.com.sub1.bytes bytes
CustomLog /var/log/httpd/domains/blog.com.sub1.log combined
ErrorLog /var/log/httpd/domains/blog.com.sub1.error.log
<Directory /home/blog/domains/blog.com/public_html/sub1>
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None
Options -ExecCGI -Includes +IncludesNOEXEC
<FilesMatch "\.(inc|php|phtml|phps|php56)$">
<If "-f %{REQUEST_FILENAME}">
#ProxyErrorOverride on
AddHandler "proxy:unix:/usr/local/php56/sockets/blog.sock|fcgi://localhost" .inc .php .phtml .php56
</If>
</FilesMatch>
</Directory>
</VirtualHost>
<VirtualHost 88.88.88.88:80 >
ServerName www.sub1.domain2.com
ServerAlias www.sub1.domain2.com news.domain2.com
ServerAdmin webmaster#blog.com
DocumentRoot /home/blog/domains/blog.com/public_html/sub1
UseCanonicalName OFF
<IfModule !mod_ruid2.c>
SuexecUserGroup blog blog
</IfModule>
CustomLog /var/log/httpd/domains/blog.com.sub1.bytes bytes
CustomLog /var/log/httpd/domains/blog.com.sub1.log combined
ErrorLog /var/log/httpd/domains/blog.com.sub1.error.log
<Directory /home/blog/domains/blog.com/public_html/sub1>
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None
Options -ExecCGI -Includes +IncludesNOEXEC
<FilesMatch "\.(inc|php|phtml|phps|php56)$">
<If "-f %{REQUEST_FILENAME}">
#ProxyErrorOverride on
AddHandler "proxy:unix:/usr/local/php56/sockets/blog.sock|fcgi://localhost" .inc .php .phtml .php56
</If>
</FilesMatch>
</Directory>
</VirtualHost>
<VirtualHost 88.88.88.88:80 >
ServerName www.sub1.domain3.com
ServerAlias www.sub1.domain3.com sub1.domain3.com
ServerAdmin webmaster#blog.com
DocumentRoot /home/blog/domains/blog.com/public_html/sub1
UseCanonicalName OFF
<IfModule !mod_ruid2.c>
SuexecUserGroup blog blog
</IfModule>
CustomLog /var/log/httpd/domains/blog.com.sub1.bytes bytes
CustomLog /var/log/httpd/domains/blog.com.sub1.log combined
ErrorLog /var/log/httpd/domains/blog.com.sub1.error.log
<Directory /home/blog/domains/blog.com/public_html/sub1>
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None
Options -ExecCGI -Includes +IncludesNOEXEC
<FilesMatch "\.(inc|php|phtml|phps|php56)$">
<If "-f %{REQUEST_FILENAME}">
#ProxyErrorOverride on
AddHandler "proxy:unix:/usr/local/php56/sockets/blog.sock|fcgi://localhost" .inc .php .phtml .php56
</If>
</FilesMatch>
</Directory>
</VirtualHost>

Unable to get Apache docker container to serve virtual host with subdomain

I have a site I currently run that works well, but both to learn and to make it more portable, I've been trying to dockerize it. I'm using the offical apache and php images, and setup my virtual hosts identical to how I have on the running site, just with different domains. Unfortunately, while I can get one to work, the second does not.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName api.gamersplane.local
DocumentRoot /var/www/api
ErrorLog "/var/log/gamersplane.api"
CustomLog "/var/log/gamersplane.api" common
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://api:9000/var/www/$1
ProxyPassReverse ^/(.*\.php(/.*)?)$ fcgi://api:9000/var/www/$1
RewriteEngine On
RewriteBase /
RewriteRule !\.(css|jpg|js|gif|png|ico|eot|woff|ttff|svg|psd)$ dispatch.php
<Directory /var/www/api/>
Options FollowSymLinks
Require all granted
</Directory>
LogLevel notice
</VirtualHost>
<VirtualHost *:80>
ErrorLog "/var/log/gamersplane"
CustomLog "/var/log/gamersplane" common
ProxyPreserveHost On
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://api:9000/var/www/$1
ProxyPassReverse ^/(.*\.php(/.*)?)$ fcgi://api:9000/var/www/$1
ServerName gamersplane.local
ServerAlias *.gamersplane.local
DocumentRoot /var/www
RewriteEngine On
RewriteBase /
RewriteRule !\.(css|jpg|js|gif|png|ico|eot|woff|ttff|svg|psd)$ dispatch.php
<Directory /var/www/>
Options FollowSymLinks
Require all granted
</Directory>
LogLevel notice
</VirtualHost>
Originally, I had the first vhost (api.gamersplane) second, but thought maybe it was the server alias that was the problem. Then I switched positions, and even commented out the base (gamersplane.local), but had no luck. This works on the running site, so I can't figure out what's wrong with it.
Checking the headers returned by Postman, I do see it has the Apache and PHP headers, so it seems to be hitting SOMETHING, I just don't know what.

Using AWStats for multiple VHosts - 404 on perl file

I have a server setup using Centos 7 and the Centos Web Panel, I am using this to host several different domains.
I want to enable AWStats for the domains, I have managed to install AWStats, I've added awstats.[domain].conf files for all the domains and I've setup cron jobs to process the logs.
I am now trying to allow each domain to see only their own data, I tried to add the awstats.pl file to their html folder:
/home/[user]/public_html/stats/awstats.pl
But calling this via http://[domain]/stats/awstats.pl gives me a 404 error.
I've also tried the following locations, all of which give the same 404 error:
/home/[user]/public_html/cgi-bin/awstats.pl
/home/[user]/public_html/stats/cgi-bin/awstats.pl
/home/[user]/public_html/awstats.pl
an example of one of my vhosts files is below:
<VirtualHost [localserverip]:80>
ServerName [domain]
ServerAlias www.[domain]
ServerAdmin webmaster#[domain]
DocumentRoot /home/[user]/public_html
UseCanonicalName Off
ScriptAlias /cgi-bin/ /home/[user]/public_html/cgi-bin/
CustomLog /usr/local/apache/domlogs/[domain].bytes bytes
CustomLog /usr/local/apache/domlogs/[domain].log combined
ErrorLog /usr/local/apache/domlogs/[domain].error.log
# Custom settings are loaded below this line (if any exist)
# IncludeOptional "/usr/local/apache/conf/userdata/[user]/[domain]/*.conf"
<IfModule mod_setenvif.c>
SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
</IfModule>
<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled [user]
</IfModule>
<IfModule mod_suexec.c>
SuexecUserGroup [user] [user]
</IfModule>
<IfModule mod_suphp.c>
suPHP_UserGroup [user] [user]
suPHP_ConfigPath /home/[user]
</IfModule>
<IfModule mod_ruid2.c>
RMode config
RUidGid [user] [user]
</IfModule>
<IfModule itk.c>
AssignUserID [user] [user]
</IfModule>
<Directory "/home/[user]/public_html">
Options -Indexes -FollowSymLinks
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
</VirtualHost>
I'm sure there's a misconfiguration with the cgi-bin somewhere but I'm not really familiar with how this works, can anyone see why I can't load the awstats file?
Just don't use perl at all, you can get ALL of the exact same functionality with Node.js with absolutely NO setbacks at all.
You're welcome.

How to serve static files using apache?

I have configured apache 2.2 webserver with tomcat. I want static files of my web application to be served using apache. I made a virtual host entry in httpd.conf
<VirtualHost *:8080>
Alias webcommon_alias C:/webcommon_bk
JkMountFile D:/xampp/apache/conf/myexample.net.properties
ServerName myexample.net
ErrorLog logs/myexample.net-error_log
CustomLog logs/myexample.net-access_log common
<Directory C:/webcommon_bk>
Order allow,deny
Allow from all
RewriteEngine On
RewriteBase /webcommon/
RewriteRule ((.*)\.(js|css|html|gif|png)$) webcommon_alias/$1
</Directory>
</VirtualHost>
But when i fetch this file in browser http://myexample.net:8080/webcommon/img/aboutBox.png i get Object not found! The requested URL was not found on this server.
Try this instead:
<VirtualHost *:8080>
Alias /webcommon C:/webcommon_bk
JkMountFile D:/xampp/apache/conf/myexample.net.properties
ServerName myexample.net
ErrorLog logs/myexample.net-error_log
CustomLog logs/myexample.net-access_log common
<Directory C:/webcommon_bk>
Order allow,deny
Allow from all
RewriteEngine On
RewriteRule ((.*)\.(js|css|html|gif|png)$) /webcommon/$1.$2
</Directory>
</VirtualHost>

ProxyPassMatch rule for Symfony 2.4

I am running Apache using mod_proxy_fcgi and PHP-FPM and am trying to get it to work Symfony. This is my first project using Symfony and am just getting a feel for it at the moment..
My vhost definition currently looks like:
<VirtualHost *:80>
ServerName symfony.dev
Documentroot "/vagrant/symfony/web"
DirectoryIndex app.php
ProxyTimeout 600
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:5090/vagrant/symfony/web/$1
<Directory "/vagrant/symfony/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
When I go to http://symfony.dev/app_dev.php/, the page loads, but all the links/paths include the full filesystem page. For example, the link for "Run the demo" is http://symblog.dev/vagrant/symfony/web/app_dev.php/demo/.
Is there a different ProxyPassMatch rule that would work, or a Symfony config that can compensate?
I tried ^/(.*\.php)(/.*)?$ which gets app_dev.php/ to load, but then app_dev.php/demo/ seems to load app_dev.php and not the demo, with broken paths to inline resources.
I had the same problems with ProxyPassMatch, but with and SetHandler everything works fine.
<VirtualHost *:80>
ServerName project.dev
ServerAlias www.project.dev
<FilesMatch \.php$>
SetHandler proxy:fcgi://127.0.0.1:9000
</FilesMatch>
#ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/web/$1
## Vhost docroot
DocumentRoot "/var/www/project/web"
## Directories, there should at least be a declaration for /var/www/awesome
<Directory "/var/www/project/web">
AllowOverride All
Order allow,deny
Allow from All
</Directory>
## Load additional static includes
## Logging
ErrorLog "/var/www/project/app/logs/apache2/error.log"
ServerSignature Off
CustomLog "/var/www/project/app/logs/apache2/access.log" combined
## SetEnv/SetEnvIf for environment variables
SetEnv APP_ENV dev
## Custom fragment
</VirtualHost>