Posts

Showing posts with the label lamp

Sharing Files Using Apache

Apache is pretty useful for sharing files on network particularly on LAN. Here is how to map an external folder to an url on your apache server. Lets assume your user name as bob and the path of the folder that you want to share is /home/bob/downloads . And you want to access contents of this folder at url /downloads . Change directory to /etc/apache2/sites-enabled . And create file named downloads with the following contents. Alias "/downloads" "/home/bob/downloads" <Directory "/home/bob/downloads"> AllowOverride None Options Indexes Order allow,deny Allow from all </Directory> Save the file and close it. Now restart the apache by issuing following command. sudo apache2ctl restart Now test everything is working as expected by going to following url in your browser. http://localhost/downloads

Debugging PHP in Quanta Using xdebug

Image
Quanta is a full featured KDE programming editor. Quanta now has support for DBGp debugging protocol. Install quanta by by issuing following command. sudo apt-get -y install quanta Configuring xdebug Install xdebug using previous blog post on Debugging PHP using xdebug . After installing xdebug add following configuration options to your /etc/php5/apache2/php.ini . xdebug.remote_enable = 1 xdebug.remote_handler = dbgp xdebug.remote_mode = req xdebug.remote_port = 9000 xdebug.remote_host = localhost Now restart your apache using following command. sudo /etc/init.d/apache2 restart Configuring quanta You can debug php scripts only in projects. Create a new project in quanta and add /var/www to it. Open project properties, select DBGp from Debugger combo box and accept remaining default settings. If you followed previous steps and debugging on local machine then you don't have to do anything else. If you have to change debug port and server url then click on Options...

Profiling PHP Using xdebug & kcachegrind

See the blogpost on xdebug installation before continuing. Enable Proiling You need to add following line to /etc/php5/apache2/php.ini to enable profiling of php scripts. xdebug.profiler_enable=1 Now restart the apache server by issuing following command. sudo apache2ctl restart When ever you access a php page through apache, xdebug will create a file something like cachegrind.out.15093 . xdebug by default uses /tmp directory to dump files which contain profiling information. You can change this target directory by using xdebug option xdebug.profiler_output_dir and you can change result file name by using the option xdebug.profiler_output_name . See more xdebug profiling options . Some times you don't want to profile all requests. xdebug provides a selective mechanism to trigger profiling of specific requests. In order to enable this option you have to add following configuration option to php.ini . xdebug.profiler_enable_trigger=On Now you can trigger profilin...

Debugging PHP Using xdebug

Image
xdebug is an open source debugger available for PHP. xdebug can be used to display more information in error traces. It can also be used to collect detailed code coverage & profiling information. Installation You need to install following packages to prepare environment for installation of pecl module xdebug. sudo apt-get -y install php-pear php5-dev build-essential Now we install xdebug using pecl. sudo pecl install xdebug Above command will download, compile & install xdebug on your system. Configuration Open /etc/php5/apache2/php.ini and append following line. zend_extension=/usr/lib/php5/20060613/xdebug.so Be careful about that number part in the path as it could be different for you. Now restart apache by issuing following command. sudo apache2ctl restart Now try to view the output of your phpinfo() function. If you find xdebug word in that then it means you have successfully installed xdebug. Stacktrace xdebug.collect_params accepts values fr...

Installing LAMP Server Stack.

Apache Apache is a free & widely used web server. To install it on your local system execute following command. sudo apt-get -y install apache2 You might get following warning when starting apache web server. apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName Add following line to /etc/apache2/apache2.conf to slience the warning. ServerName localhost To test the installation enter http://localhost in addressbar of your browser and you should see the message It works! . Visit Apache HTTP Server site. PHP PHP is one of the most easiest scripting language available for quickly writing backend code. Install php by executing following command. sudo apt-get -y install php5 libapache2-mod-php5 By default you will not be able to save anything to /var/www. To make /var/www writable execute following command. sudo chmod -R 755 /var/www/ To test php installation enter following snippet into /var/www/he...