Showing posts with label httpd. Show all posts
Showing posts with label httpd. Show all posts

Tuesday, August 12, 2014

Download a password protected webpage with Objective C for iOS/iPhone/iPad

1) Go to http://allseeing-i.com/ASIHTTPRequest and download the latest version (the .tar tarball file)

2) In Xcode, in your project, click on the file folder icon, which is the top left button, so that you can see all the .h and .m files in your project.
3) Open the .tar file in Finder, and drag-and-drop the Classes/ASI* files to Xcode, on the left hand side, in the same directory that the rest of your .h and .m files are.  NOTE: Don't copy the files manually through the command line (Terminal) nor outside of Xcode.
4) If you are creating an iPhone app, drag-and-drop the External/Reachability/Reachability* files to Xcode, on the left hand side, in that same directory.
5) Go to http://allseeing-i.com/ASIHTTPRequest/Setup-instructions and follow the step 2 directions, which is setting up the Build Phases.
6) If you are using ARC, then you need to disable ARC for the ASI* and Reachability* files.  Click on your main project on the left hand side, then choose "Build Phases", and expand the "Compile Sources" section.  For all of the ASI* and Reachability.m files, add in the following flag for "Compiler Flags": -fno-objc-arc (Also see http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project)
7) At the top of your .m file where you want to download the webpage, paste the following line:
#import "ASIHTTPRequest.h"

8) In that same .m file, download the file by doing this:


    NSString* url = @"http://www.google.com";
    NSURL *nsurl = [NSURL URLWithString:url];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:nsurl];
    [request setUsername:@"enterUsernameHere"];
    [request setPassword:@"enterPasswordHere"];
    
    [request startSynchronous];
    NSError *error = [request error];
    if (!error) {
        NSString *response = [request responseString];
        NSLog(response);
    }

That's it!

Wednesday, April 30, 2014

What to do if restarting apache httpd fails when trying build an OSM tile server

If you are using Fedora to create an Open Street Map tile server, when you restart apache, you might be getting this error:

Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' for details.

When running systemctl status httpd.service, if the error looks like this:

Apr 29 23:23:22 hostname.com systemd[1]: Starting The Apache HTTP Server...
Apr 29 23:23:22 hostname.com httpd[6326]: AH00526: Syntax error on line 88 of /etc/httpd/conf/httpd.conf:
Apr 29 23:23:22 hostname.com httpd[6326]: Invalid command 'LoadTileConfigFile', perhaps misspelled or defined by a module not included i...guration

Make the following changes:
  1. Rename the /etc/httpd/conf.d/mod_tile file to /etc/httpd/conf.d/mod_tile.conf
  2. Change the contents of that file to the following:
    LoadModule tile_module /usr/lib/httpd/modules/mod_tile.so

Wednesday, July 3, 2013

How to get viewvc working with Apache httpd and Fedora and subversion (svn)


  1. Get subversion working with httpd first. (See http://muddyazian.blogspot.com/2013/05/how-to-start-subversion-repository-over.html)
  2. yum install viewvc viewvc-httpd
  3. Edit /etc/viewvc/viewvc.conf and modify the svn_roots and root_parents options.
  4. Edit /etc/httpd/conf/httpd.conf and add in the following:

    <Directory /usr/lib/python2.7/site-packages/viewvc/bin/mod_python>
      Order allow,deny
      Allow from all
      AuthType Basic
      AuthName "Subversion repositories"
      AuthUserFile /etc/svn-auth-users
      Require valid-user
    </Directory>

    <Directory /usr/share/viewvc/templates/docroot>
      Order allow,deny
      Allow from all
    </Directory>

    ...

    Alias /viewvc-static "/usr/share/viewvc/templates/docroot/images"

    ...

    ScriptAlias /viewvc /usr/lib/python2.7/site-packages/viewvc/bin/cgi/viewvc.cgi
    ScriptAlias /query /usr/lib/python2.7/site-packages/viewvc/bin/cgi/query.cgi

  5. Restart the web server: /sbin/service httpd restart
  6. Go to http://localhost/viewvc
  7. If you haven't already done so, create the /etc/svn-auth-users file:

    htpasswd -cm /etc/svn-auth-users firstUsername
    New password:
    Re-type new password:
    Adding password for user firstUsername
You can test things out (sanity check) like this:

/usr/lib/python2.7/site-packages/viewvc/bin/standalone.py -r /path/to/svn/repository/location

Then in firefox, go to http://localhost:49152/viewvc

Tuesday, April 3, 2012

Profiling PHP Code

Time Profiling PHP Code: this is how to get your PHP code profiled with xdebug, Fedora and httpd.  Concepts might stretch to other platforms.

1) Install xdebug

sudo yum install php-pecl-xdebug

2) Under /etc/php.ini Options, add in the following line:

zend_extension = /usr/lib64/php/modules/xdebug.so

3) In /etc/httpd/conf/httpd.conf, change the following:

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

to this

<Directory />
    Options FollowSymLinks
#    AllowOverride None
    AllowOverride All
</Directory>


4) Also put in the AllowOverride All command in the following place:

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">

    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
#    AllowOverride None
    AllowOverride All


5) Perform the following permissions change:

sudo chmod -R 777 /var/lib/php/session

6) In the PHP code directory that you want to profile, create a .htaccess file and add in the following:

php_value xdebug.profiler_enable 1
php_value xdebug.profiler_output_dir /tmp

7) Restart httpd

sudo /sbin/service/httpd restart

8) You'll need kcachegrind to visualize the profiling output.  Download and compile it. 

8a) Get the source from here: http://kcachegrind.sourceforge.net/html/Download.html

8b) tar -zxvf kcachegrind-0.7.1.tgz

8c) sudo yum install kdebase-devel

8d) cd kcachegrind-0.7.1

8e) mkdir build

8f) cd build

8g) ccmake ..

8h) All the defaults are fine, but you can change the CMAKE_BUILD_TYPE to Debug

8i) make -j12

8j) sudo make install

9) Now, run your PHP script.  The results are either in /tmp or /tmp/systemd-private-*/tmp and you can visualize them with the /usr/local/bin/kcachegrind cachegrind.out.1234.

If you run into problems, you might find hints in/var/log/httpd/error_log.  Or, you can try to run your php script on the command line, e.g.:

$ php index.php