Tagged: development RSS Toggle Comment Threads | Keyboard Shortcuts

  • webscriptz 00:06 on 25/03/2011 Permalink | Reply
    Tags: 127.0.0.1, apache, apache2, bind9, , console, development, dns, fedora, hosts, httpd, , local domain name, name-based virtual host, nano, virtual hosts   

    Fedora Core – virtual hosts httpd 

    I’ve reinstalled my pc with Fedora Core recently, because of the extended SELinux and more tools that are at my disposal. A problem I always had with ubuntu was the configuration of Apache virtual hosts. Once they where installed I needed to put them into the host file and each time I reconnected to a network the NetworkManager rewrote the hosts file annoying me and the fact that if one was configured localhost would also begin pointing to it, a rather nasty thing.

    First you need to open the console and login with your root user, type su and fedora will already know what to do.

    You need to shutdown the httpd servic deamon with the command :

    1
    /etc/init.d/httpd stop

    You will have to open /etc/httpd/conf/httpd.conf, once opened you will have to locate the section on virtual hosts and you should see an example that is already commented out., I edited the files with nano in the console.

    1
    ### Section 3: Virtual Hosts

    Instead of telling you which lines to uncomment, I’m going to show you below, the stanzas to add to the Virtual Host section to get companyABC.com and companyDEF.com websites running:

    001
    #
    002
    # Virtual hosts
    003
    #
    004
     
    005
    # Virtual host Default Virtual Host
    006
    <VirtualHost *>
    007
    DocumentRoot /var/www/html/
    008
    ErrorLog logs/error_log
    009
    ServerAdmin root@localhost
    010
     
    011
     
    012
     
    013
    ServerSignature email
    014
    TransferLog logs/access_log
    015
    DirectoryIndex index.php index.html index.htm index.shtml
    016
     
    017
     
    018
    SSLEngine off
    019
    SSLCertificateFile /etc/pki/tls/certs/localhost.crt
    020
    SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
    021
     
    022
    SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
    023
     
    024
    SSLOptions
    025
    LogFormat "None"
    026
    TransferLog logs/access_log
    027
    ErrorLog logs/error_log
    028
    LogLevel debug
    029
    HostNameLookups off
    030
     
    031
     
    032
     
    033
     
    034
    </VirtualHost>
    035
     
    036
    # Virtual host resume.loc
    037
    <VirtualHost 127.0.0.1>
    038
    DocumentRoot /var/www/html/mdw/resume
    039
    ErrorLog logs/error_log
    040
    ServerAdmin root@localhost
    041
    ServerName resume.loc
    042
     
    043
     
    044
    ServerSignature email
    045
    TransferLog logs/access_log
    046
    DirectoryIndex index.html index.php index.shtml
    047
     
    048
    <Directory "/var/www/html/mdw/resume/">
    049
    Options all
    050
     
    051
    AllowOverride all
    052
     
    053
     
    054
     
    055
    </Directory>
    056
     
    057
     
    058
    SSLEngine off
    059
    SSLCertificateFile /etc/pki/tls/certs/localhost.crt
    060
    SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
    061
     
    062
    SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
    063
     
    064
    SSLOptions
    065
    LogFormat "None"
    066
    TransferLog logs/access_log
    067
    ErrorLog logs/error_log
    068
    LogLevel error
    069
    HostNameLookups on
    070
     
    071
     
    072
     
    073
     
    074
    </VirtualHost>
    075
     
    076
    # Virtual host linker
    077
    <VirtualHost 127.0.0.1>
    078
    DocumentRoot /var/www/html/mdw/linkerv2/
    079
    ErrorLog logs/error_log
    080
    ServerAdmin root@localhost
    081
    ServerName linker.loc
    082
     
    083
     
    084
    ServerSignature email
    085
    TransferLog logs/access_log
    086
    DirectoryIndex index.html index.php index.shtml
    087
     
    088
     
    089
    SSLEngine off
    090
    SSLCertificateFile /etc/pki/tls/certs/localhost.crt
    091
    SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
    092
     
    093
    SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
    094
     
    095
    SSLOptions
    096
    LogFormat "None"
    097
    TransferLog logs/access_log
    098
    ErrorLog logs/error_log
    099
    LogLevel error
    100
    HostNameLookups on
    101
     
    102
     
    103
     
    104
     
    105
    </VirtualHost>
    106
     
    107
    # Virtual host Virtual Host 1
    108
    <VirtualHost 127.0.0.1>
    109
    DocumentRoot /var/www/html/mdw/site
    110
    ErrorLog logs/error_log
    111
    ServerAdmin root@localhost
    112
    ServerName mdw.loc
    113
     
    114
     
    115
    ServerSignature email
    116
    TransferLog logs/access_log
    117
    DirectoryIndex index.html index.php index.shtml
    118
     
    119
     
    120
    SSLEngine off
    121
    SSLCertificateFile /etc/pki/tls/certs/localhost.crt
    122
    SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
    123
     
    124
    SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
    125
     
    126
    SSLOptions
    127
     
    128
    TransferLog logs/access_log
    129
    ErrorLog logs/error_log
    130
    LogLevel error
    131
    HostNameLookups on
    132
     
    133
     
    134
     
    135
     
    136
    </VirtualHost>
    137
     
    138
     

    After you have added the host(s), save the file. At this point, you will need to add the appropriate records to your DNS server to make these domains reachable by anyone on the network. If you have no access to a DNS server (BIND9), or you just want to test the configuration, just edit your /etc/hosts file. Here is what my file looks like:

    1
    # Do not remove the following line, or various programs
    2
    # that require network functionality will fail.
    3
    127.0.0.1               localhost.localdomain localhost
    4
    127.0.0.1               host1.loc
    5
    127.0.0.1               host2.loc
    6

    Once hosts is saved you just restart your server and everything should work without a problem

     
    • webscriptz 11:47 on 30/03/2011 Permalink | Reply

      This is if you have a server distribution installed on a laptop like I do for development purposes.

      Note that this works best with a server distribution because,if you take, for instance the Ubuntu desktop edition an make a webserver for development purposes you will have disable NetworkManager
      or each time you connect to a different network rewrite the /etc/hosts to be able to access your websites via the link specified by you.

      Fedora, RHEL and centOS use /etc/resolv.conf for the IP-address currently used by the PC where Ubuntu for instance use /etc/hosts and thus rewrites it as soon as you change from network.

    • webscriptz 23:09 on 30/03/2011 Permalink | Reply

      A friend pointed out that When in production you should patch the server, here’s a good article describing howto: http://mitka.us/articles/mpm-itk/

  • webscriptz 23:47 on 20/12/2009 Permalink | Reply
    Tags: development, , , , , , , ,   

    YII framework configuration 

    I’m toying with the Yii Framework for some time now and even if i cost me a lot of anger and frustration in the beginning I’m starting to like it more and more, alas I do have to say that the documentation isn’t always that clear and for someone who begins or who’ll write some large applications the configuration file can be a hassle so here’s my solution:

    Brake down the configuration file in multiple files, this will give you some speed disadvantage and some will  saying that I’m raping Yii framework purpose for speed but at least to me it seems more clear

    This is the protected.config/main.php

    dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'WEBSITENAME',
    'modules'=>array(
    'users'=>array(
    //sub modules in the module users
    'modules'=>array(
    'messaging',
    'profile',
    'dashboard',
    )
    ),
    'about',
    'forums',
    ),
    // preloading 'log' component active loading
    'preload'=>array('log'),
    
    // autoloading model and component classes lazy loading
    // I make the difference between CformModel and CActiveRecord
    'import'=>array(
    'application.models.*',
    'application.models.forms.*',
    'application.models.database.*',
    ),
    
    // application components
    'components'=>array(
    // enable cookie-based authentication
    'user'=>array('allowAutoLogin'=>true),
    
    // data relinquished to database.php
    // for easy access and usability as also for the future
    // installation procedure, it's less to write to a file
    'db'=>include(dirname(__FILE__).'/database.php'),
    
    // for a better overview we exculded url routes to a seperate file
    'urlManager'=>include(dirname(__FILE__).'/routes.php'),
    
    //authentication component needs data from db for CdbConnection
    'authManager'=>array(
    'class'=>'CDbAuthManager',
    'connectionID'=>'db',
    'defaultRoles'=>array('authenticated', 'guest'),
    ),
    
    //security measures
    'request'=>array(
    'enableCsrfValidation'=>true,
    'enableCookieValidation'=>true,
    ),
    ),
    
    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    // uncomment the following if you want static params in the application
    //'params'=>array(include(dirname(__FILE__).'/params.php'))
    );

    database.php

    'CDbConnection',
    'connectionString'=>'mysql:host=localhost;dbname=mysql',
    //'connectionString'=>'pgsql:host=localhost;port=5432;dbname=mysql',
    'username' => 'root',
    'password' => '',
    );
    ?>
    

    routes.php

    'path', // path or get
    'urlSuffix' => '', //.html .whateverextentionyouwant
    'showScriptName' => true,
    'rules'=>array(
    'users/recovery/perimeterSecurity/'=>'users/recovery/perimeterSecurity',
    ),
    );
    ?>
    

    param.php

    //nothing in it at the moment

     
    • Cherry 10:58 on 30/12/2009 Permalink | Reply

      Hi,I’m trying Yii now.Almost everything could be done with Yii.But all the components,those how I configure ,will run.Something ,like,DB session…
      well,my english is so poor!

    • webscriptz 03:32 on 01/01/2010 Permalink | Reply

      I’m a bit torn between speed and programming luxury and because sometimes Yii is poorly documented, nice example code but not all the options are given actually sometimes very few.

      I’m currently doing models and testing them in Yii and i can’t get my head really around it, Codeigniter was really easy to use in the model logic but now what’s the logic, Model driven or controller driven because of the AR layer and the model sql query which seems implemented in the controllers. I thought controllers were just a gateway between view and model because it’s the model that usually contains all the logic not the controller.

  • webscriptz 00:47 on 30/08/2008 Permalink | Reply
    Tags: development, , freepascal   

    A freepascal clock 

    A basical console clock written in freepascal by me, even if it’s an old language, I have to practice on it for school.

    Here you got the code, I’ve added little comments but it isn’t a lot. hh = hour mm = minutes ss= seconds

    (More …)

     
  • webscriptz 22:04 on 29/08/2008 Permalink | Reply
    Tags: Dev C, development,   

    C & FPC 

    C programming and pascal, that’s what I’m doing for the moment, I have an exam in 5 days, man I hate it.

    Just finished a clock in C: you give the time for tomorrow and he’ll count it down. But it’s basic:

    01
    02
    #include
    03
    #include
    04
     
    05
    int main(int argc, char *argv[])
    06
    {
    07
    long hh, mm,th, tm, ts;
    08
     
    09
    printf("Reveil a quelle heure(24) minutes? \t");
    10
    scanf("%ld", &amp;hh);
    11
    scanf("%ld", &amp;mm);
    12
     
    13
    th= hh+24; //ceci pr une journee
    14
    tm = 60 - mm;
    15
    ts=0;
    16
    while(th&gt;=hh)
    17
    {
    18
    if(ts&gt;0){ts-=1; sleep(1000);}
    19
    else if(tm&gt;0){ts=60; tm--;}
    20
    else if (th&gt;hh){ts=60; tm=60; th--;}
    21
    else if (th=hh){if(ts&gt;0){ts--;}}
    22
    system("cls");
    23
    printf("%ld : %ld : %ld", th, tm, ts);
    24
     
    25
    }
    26
     
    27
    system("PAUSE");
    28
    return 0;
    29
    }
    30
     
    31
    <span style="text-decoration: line-through;">I'm more or less pleased but still the infinite refreshments aren't what I wanted and sorry about the comment but in exercises I don't use them</span> <a href="http://webscriptz.be/2008/08/29/c-fpc/108#more-108&quot; class="more-link">(More ...)</a>

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel