symfony 1.4 and Apache access/error logs - apache

Symfony 1.4 is set up as the only virtual host in my Apache config. Should I make use of the Apache access logs and error logs or does symfony take care of both of these for me?

Apache logs are not the same as the logging provided by symfony. Apache logs are useful for other reasons than symfony's. I usually use the following virtual host config for my local development.
<VirtualHost *:80>
ServerName dev.yoursite.com.br
DocumentRoot "/home/you/dev/sfprojects/yoursite/web"
DirectoryIndex index.php
<Directory "/home/you/dev/sfprojects/yoursite/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/you/dev/sfprojects/yoursite/lib/vendor/symfony/data/web/sf
<Directory "/home/you/dev/sfprojects/yoursite/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
ErrorLog "/home/you/dev/sfprojects/yoursite/log/error.log"
CustomLog "/home/you/dev/sfprojects/yoursite/log/web.log" combined
</VirtualHost>
For symfony, I configure the factories.yml like the following
dev:
logger:
class: sfAggregateLogger
param:
level: notice
loggers:
sf_file_err:
class: sfFileLogger
param:
level: err
file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%_error.log
sf_file_notice:
class: sfFileLogger
param:
level: notice
file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%_notice.log

Related

Puppet apache configuration file on ubuntu ec2

I am using puppet to provision an AWS AMI using packer and then launch the AMI.
Puppet does all the configuration and package installations upon baking the AMI which includes installing and configuring apache and wsgi.
By the time I launch the AMI my application (a Flask application) would have already been downloaded and configured by Puppet as well as my apache configuration file at /etc/apache2/sites-available/xxxx.conf . I make use of the Puppet template to configure the apache configuration file and as such it is a Ruby template (xxxx.conf.erb) ,the apache configuration template file looks like this :
<VirtualHost *:<%= #port -%>>
ServerName <%= #servername %>
ServerAdmin admin#example.com WSGIScriptAlias / /var/www/Porfolio/xxxxx.wsgi
<Directory /var/www/Porfolio/> Order allow,deny Allow from all </Directory> Alias /static /var/www/Porfolio/static <Directory /var/www/Porfolio/static/> Order allow,deny Allow from all </Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have set the variable servername = $::hostname (using facter) and port = 80
When i launch the AMI and I access the public IP address of the server of the ec2 instance, it takes me to the default ubuntu webpage instead of my web Flask application.
I will have to ssh into my server and change the apache configuration file at
/etc/apache2/sites-available/xxxx.conf to become :
<VirtualHost *:<%= #port -%>>
ServerName 52.91.143.90
ServerAdmin admin#example.com
WSGIScriptAlias / /var/www/Porfolio/culturely.wsgi
<Directory /var/www/Porfolio/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/Porfolio/static
<Directory /var/www/Porfolio/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
This means i have to manually type in the public IP address of the ec2instance in order to get my Flask web page to display when the public Ip address is accessed on a browser. This ofcourse defeats the level of automation I am trying to achieve.
The public IP address only becomes available after I launch the AMI, is there a way i can re-configure my apache configuration file to make it automatically goto my web application instead of the default ubuntu web page ? without having me to ssh into the server and manually change it after it is launched
There is a fact ec2_public_ipv4, use this to set the address
I have found a solution to my problem. I was creating a new apache configuration file with puppet at packer time, a point at which the public IP address that will be assigned to ec2 instance is unavailable.
So instead of creating a new apache configuration file, I modified the default one at /etc/apache2/sites-available/000-default.conf . I left the variable servername = $::fqdn . Now whenever I launch the AMI and visit the assigned public IP address of the ec2-instance, it navigates to my Flask application and not the default ubuntu web page anymore.

Running Jenkins behind Apache 2.2 issue

I need to configure Jenkins behind Apache. For this purpose I installed Apache 2.2 using httpd-2.2.25-win32-x86-openssl-0.9.8y.msi.
Now I have configured jenkins with -
--httpPort=8084 --prefix=/jenkins (inside jenkins.xml)
The securityRealm for Jenkins is (I am using LDAP authentication):
<securityRealm class="hudson.security.LDAPSecurityRealm" plugin="ldap#1.11">
<server>ldap://ldap.myserver.com:1234</server>
<rootDN>DC=blah-blah,DC=blah</rootDN>
<inhibitInferRootDN>false</inhibitInferRootDN>
<userSearchBase></userSearchBase>
<userSearch>SAMAccountName={0}</userSearch>
<groupSearchFilter></groupSearchFilter>
<groupMembershipStrategy class="jenkins.security.plugins.ldap.FromGroupSearchLDAPGroupMembershipStrategy">
<filter></filter>
</groupMembershipStrategy>
<managerDN>email#mycompany.com</managerDN>
<managerPasswordSecret>XXXX</managerPasswordSecret>
<disableMailAddressResolver>false</disableMailAddressResolver>
<displayNameAttributeName>displayname</displayNameAttributeName>
<mailAddressAttributeName>mail</mailAddressAttributeName>
<userIdStrategy class="jenkins.model.IdStrategy$CaseInsensitive"/>
<groupIdStrategy class="jenkins.model.IdStrategy$CaseInsensitive"/>
</securityRealm>
The name of the server where Apache and Jenkins are hosted is : http://abchost/.
Jenkins is hosted at : http://abchost:8084/jenkins.
Now I need to configure Apache server in such a way that, when I enter http://abchost/jenkins in browser it a Proxy should work in between and it should forward the request to http://abchost:8084/jenkins and again, get the result from jenkins and display the result at : http://abchost/jenkins.
For this I have configured Apache like this:
NameVirtualHost abchost:80
Listen 80
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes On
<VirtualHost *:80>
ServerName abchost.com
ServerAdmin admin#abchost.com
ProxyPass /downloads !
Alias /downloads "d:\myPath1"
<Directory "d:\myPath2">
# Don't allow editing the main repository site.
Options -Indexes
</Directory>
<Directory "d:\myPath3">
# Remove 'Parent Directory' link from the site.
# IndexIgnore ..
#
Options +Indexes
# List file names which will be opened automatically when the folder is opened.
DirectoryIndex index.html toc.html
IndexOptions FancyIndexing HTMLTable FoldersFirst SuppressDescription
</Directory>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# Jenkins via HTTP.
ProxyPass /jenkins/ http:/abchost:8084/jenkins/ nocanon
ProxyPassReverse /jenkins http://abchost:8084/jenkins/
</VirtualHost>
After this configuration, I am able to login in jenkins using http:/abchost:8084/jenkins/, but, not using http:/abchost/jenkins/.
Point to note is:
When I am logging in http:/abchost/jenkins/ using proper user id and pswd, it looks like the page refreshes and blank login page appears again.
When I am logging in http:/abchost/jenkins/ using wrong user id and pswd combination, it shows message that LDAP authentication failed.
Can anyone please enlighten me?
Thanks in advance!

using flask virtualenv on remote host (not locally)

I have a CentOS 7 WSGI enables Apache Httpd server (on a VirtualBox machine) and it serves my developing Flask site at http://www.myflask.com on port 80.
Since I can't debug there (even if I tried everything I could), like I can on a local version set in a virutalenv at http://127.0.0.1:5000, I was trying to do this:
setting up a virtualenv (with flask installed) on the VB server, called myflaskv (/var/www/myflaskv)
putting myflask dir into myflaskv (/var/www/myflaskv/myflask)
I did end with the following httpd.conf virtual host section:
<VirtualHost *:80>
DocumentRoot "/var/www/myflaskv/myflask"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/myflaskv/myflask">
Options Indexes FollowSymLinks MultiViews
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /var/www/myflaskv/myflask/index.wsgi
ServerName www.myflask.com:80
</VirtualHost>
I can load the page http://www.myflask.com (even with virtualenv activated) but I can't load the page http://www.myflask.com:5000 as I would suppose to debug.
So I tried to add a virtualhost on port 5000:
<VirtualHost *:5000>
DocumentRoot "/var/www/myflaskv/myflask"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/myflaskv/myflask">
Options Indexes FollowSymLinks MultiViews
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /var/www/myflaskv/myflask/index.wsgi
ServerName www.myflaskv.com:5000
</VirtualHost>
supposing that this way I could load http://www.myfaskv.com, and instead I can't (ERR_CONNECTION_REFUSED).
By the way I temporarly disactivated ip-tables and se-linux.
So is there a way to load from browser the 127.0.0.1:5000 ip address of a remote host?
Or there is a better way to debug flask in an wsgi apache dev environment?
If you want to access the url from outside the box, you will have to run the server at 0.0.0.0:5000.
The url http://127.0.0.1:5000 cannot be accessed from outside the box you are running it in.
When you use wsgi to access your app, the error messages and stack traces are written to the web server error log, by default at /var/log/apache2/error.log. You don't need to use the virtualenv web server. Just write any debug output you need to a local log file (if you have debugging input you want to print) and look for the stack traces in the apache error log.

Can't configure XAMPPto work with zend

Hi I'm trying to install ZF 1.12 with XAMPP .I read everything and did everything exactly as it was written,also configured the "httpd.conf" file like this:
<VirtualHost *:80>
DocumentRoot "/xampp/htdocs/<Your project folder>/public"
ServerName <Your project folder>
ServerAlias www.<Your project folder>
SetEnv APPLICATION_ENV "development"
<Directory "/xampp/htdocs/new/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
but now when i try to start the server i get the following message:
500 Internal Server Error
The server encountered an internal error or misconfiguration and was >unable to complete your request.
Is there anything else that needs to be done
Your Virtual Host definition is incomplete i.e no closing tag ( this may just have been missed when you copy/pasted.
Lets assume you have created and installed the Framework into /xampp/htdocs/project1/public
Lets also assume you want to run this site from a development domain called project1.dev i.e this is what you want to enter into the browser address bar.
Lets also assume you are using Apache 2.4.x and therefore need to use the Apache 2.4 syntax for access.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/project1/public"
ServerName project1.dev
ServerAlias www.project1.dev
<Directory "C:/xampp/htdocs/new/public">
DirectoryIndex index.php
AllowOverride All
Require local
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
Now you need to edit the C:\windows\system32\srivers\etc\hosts and add these 2 lines.
127.0.0.1 project1.dev
::1 project1.dev
Now run this from a command windows launched using "Run as Administrator"
net stop dbscache
net start dnscache
And then restart Apache. Alternatively, just reboot.

Apache Virtual Host -- subdomain for cgit

I struggle with apache's virtual host configuration. I want to deploy cgit on a subdomain like: http://cgit.mydomain.com
I have used this as a template for my configuration: http://hjemli.net/pipermail/cgit/2011-July/000235.html
Here is my virtual host configuration:
<VirtualHost *>
ServerAdmin admin#mydomain.org
ServerName cgit.mydomain.org
ErrorLog "/var/log/httpd/cgit-error_log"
CustomLog "/var/log/httpd/cgit-access_log" common
DocumentRoot "/usr/share/webapps/cgit/"
<Directory "/usr/share/webapps/cgit/">
AllowOverride None
Options ExecCGI FollowSymlinks
Order allow,deny
Allow from all
</Directory>
Alias /cgit.css "/usr/share/webapps/cgit/cgit.css"
Alias /cgit.png "/usr/share/webapps/cgit/cgit.png"
Alias /favicon.ico "/usr/share/webapps/cgit/favicon.ico"
ScriptAlias / "/usr/share/webapps/cgit/cgit.cgi/"
</VirtualHost>
Here is a part of my cgitrc:
css=/cgit.css
logo=/cgit.png
favicon=/favicon.ico
Everything works fine but the css file and the favicon do not work, so the cgit webpage is broken. When I go to the URL http://cgit.mydomain.com/cgit.css cgit tells me that there is no repo called cgit.css. Usually I shoud see the cgit.css file in my browser.
A possible solution is to use /cgit/ as a script alias but I do not want to have the /cgit/ fragment in my URLs. On http://cgit.osmocom.org it works right.
I am note really shure why but now the setup works! After adding DocumentRoot "/usr/share/webapps/cgit/" to my virtual host I stopped working yesterday.
Today I looked on my cgit website and everything is fine! I think it was something like a cache issue...
The virtual host settings above work.