Tuesday, March 29, 2016
How disable the “Help” Menu in Joomla administrator
Saturday, March 26, 2016
Access an IIS-hosted Site from Another PC (IIS Express + Windows Firewall)
I was working on a Intranet project for one of my client. Earlier It had to be developed with Apache web server. But later they wanted it to be developed with IIS (Internet Information Service) server. So we wanted the site i.e web application to be accessed by other PCs on the local network which's hosted on IIS Server.
Overview
This post shows the steps I used to let other PCs on the local network access a site hosted on IIS / IIS Express running on my development machine. The procedure covers:
- Opening the server port in Windows Firewall
- Updating the IIS/IIS Express binding (applicationhost.config)
- Reserving the URL with
netsh
Follow the steps below and replace the example port (6060) with your site’s port.
1) Confirm the site port
First you should know the port on which your site can be accessed. For example it's 6060 in my case. You can get it through WebMatrix or the IIS Manager. It looks like this in WebMatrix:
2) Open the port in Windows Firewall (Inbound rule)
Open the Control Panel -> Windows Firewall -> Advanced Settings and add a new inbound rule for the port your site is using.
Steps (high level):
- Open Control Panel
- Open Windows Firewall
- Click Advanced Settings
- Select Inbound Rules
- Select New Rule
Choose the Port option for the rule type:
When asked for protocol/port select TCP and enter your port (6060 in my example):
Allow connections and continue:
Select the profiles to which the rule applies (Public, Private, Domain):
Save the rule with a descriptive name (for example: "IIS Site Port 6060"). That's it for opening a port.
3) Update IIS / IIS Express bindings
If you are using IIS Express (or IIS), you need to make the binding accept requests from other machines. Go to the IIS Express installation folder and open the config directory. Open applicationhost.config for edit and find the <bindings> for your site.
Add or update the binding with a line like this (use your port):
<binding protocol="http" bindingInformation=":*6060:*" />
(Or, as shown in my example — same content formatted in the original post):
<binding protocol="http" bindingInformation="*:6060:*" />
</bindings>
Save the file and stop the site in IIS/WebMatrix before restarting.
4) Reserve the URL with netsh (run as Administrator)
Open an elevated command prompt (Right click -> Run as administrator) and run:
netsh http add urlacl url=http://*:6060/ user=Everyone
You can change the port to match yours. Mine is 6060 hence I mentioned 6060.
Security note
Using user=Everyone is convenient for development but broad. That grants any user the right to register and use the reserved URL namespace. For production or shared machines, prefer reserving the URL to a specific user or group. Example alternatives (replace DOMAIN\User or a local account):
netsh http add urlacl url=http://*:6060/ user="DOMAIN\User"
Always evaluate security implications before opening ports and granting broad URL reservations.
5) Restart IIS and test from another PC
Restart the IIS server (or IIS Express instance) and try to access the application from another PC on the LAN using:
http://<IP Address of the Server>:6060
Replace <IP Address of the Server> and 6060 with your server IP and port.
Quick troubleshooting checklist
- Can you ping the server IP from the client machine?
- Is the service listening on the expected port? (Run
netstat -ano | findstr 6060on the server.) - Is the inbound firewall rule enabled and targeting the correct port and profiles?
- Confirm the binding in
applicationhost.configincludes the correct port and wildcard/host as needed.
That's it. Happy Coding.
Friday, March 18, 2016
Export a MySQL database from Windows Command Prompt (mysqldump)
Some how my PhpmyAdmin stopped working And I had to take up a back up of one of my databases. So that time, I thought of using the Mysql Command prompt service.
Why use mysqldump (and where to run it)
To take the back up, we can export the tables and contents of the database using mysqldump. Please note that mysqldump is not a command inside the mysql interactive prompt — it's a separate utility installed with MySQL. If you try to run it from the mysql> prompt you'll get an error like this:
You need to run mysqldump from a regular command prompt (cmd.exe on Windows), not from inside mysql.
Locate mysqldump.exe
On Windows, mysqldump.exe is in MySQL's "bin" directory inside the MySQL installation folder. For example:
You can either:
- open Command Prompt and change directory into that bin folder, e.g.:
cd "C:\Program Files\MySQL\MySQL Server X.Y\bin"
- or add the bin folder to your PATH environment variable so mysqldump can be run from any folder:
setx PATH "%PATH%;C:\Program Files\MySQL\MySQL Server X.Y\bin"
(Replace X.Y with your MySQL version and restart your command prompt after modifying PATH.)
Basic export command (example)
Change to the directory where you want the dump file saved (or use an absolute path in the redirection). Then run:
mysqldump -u root -p mrms >mrms.sql
Here:
- -u root specifies the MySQL user
- -p tells mysqldump to prompt for the password (safer than passing it on the command line)
- mrms is the database name
- >mrms.sql redirects the SQL output into a file named mrms.sql in the current directory
After entering the root password when prompted, mrms.sql is generated in that directory. Example confirmation screenshot:
Additional useful examples
- Export a single table from a database:
mysqldump -u root -p mrms table_name >table_name.sql
- Export all databases:
mysqldump -u root -p --all-databases >alldb.sql
- Export a specific database and include routines/triggers:
mysqldump -u root -p --routines --triggers mrms >mrms_with_routines.sql
- For large InnoDB databases to get a consistent dump without locking tables, use single-transaction (works for InnoDB only):
mysqldump -u root -p --single-transaction mrms >mrms.sql
- Export from a remote host:
mysqldump -h remote_host -u user -p database >database.sql
- Compress the dump on the fly (Windows with gzip available, or use 7-Zip):
mysqldump -u root -p mrms | gzip >mrms.sql.gz
Security notes
- Do not put the password directly in the command line (e.g. --password=secret) on multi-user systems — it may be visible in process lists or command histories. Use -p to be prompted for the password.
- Store dump files securely and limit access (they contain all data and possibly sensitive information).
How to restore a dump
To restore the dump into a database:
mysql -u root -p mrms < mrms.sql
If the database does not exist, create it first or use the --databases option when dumping (which includes CREATE DATABASE statements):
mysqldump -u root -p --databases mrms >mrms_with_create.sql
Troubleshooting
- "'mysqldump' is not recognized": you are not in the MySQL bin directory and it isn't on PATH — cd to bin or add it to PATH.
- Permission denied when creating the .sql file: change to a writable directory or run the command prompt as a user with write permissions for that folder.
- Connection errors: ensure MySQL server is running and the credentials are correct. For remote hosts, ensure network access and firewall rules allow the connection.
- If the dump is incomplete or fails, check the mysqldump output for error messages and ensure you have sufficient disk space.
Summary
That's it. Happy Coding.
Sunday, March 13, 2016
Configure PHP & MySQL on IIS (Windows) — Step‑by‑Step Guide
This blog describes the installation and configuration of PHP, MySQL and IIS (Internet Information Services) server for running web applications on Windows.
Table of contents
- Overview
- Prerequisites
- IIS installation (screenshots)
- MySQL installation
- PHP installation and php.ini changes
- Configuring PHP with IIS (FastCGI)
- Verifying PHP + MySQL (phpinfo)
- Installing Joomla (optional)
- Firewall and external access
- Troubleshooting
Overview
Internet Information Services (IIS) is a web server from Microsoft. Modern IIS can host PHP and MySQL-backed applications, but unlike WAMP you install and configure each component separately. This guide walks through installing IIS, MySQL, and PHP, and configuring them to work together.
Prerequisites
- Administrative access on the Windows machine.
- IIS available on your Windows edition (note: IIS is not supported in Starter, Home Basic, or Home Premium editions). IIS is available in Windows 7 Professional/Ultimate, Windows Server editions, and above.
- Internet access to download installers and runtimes.
IIS Installation
If IIS is already installed, skip this section. Otherwise enable IIS from Windows Features (or use Server Manager on Windows Server).
STEPS TO CHECK WHETHER IIS IS ALREADY INSTALLED ON YOUR COMPUTER:
- Open Control Panel → Programs and Features → Turn Windows features on or off and check Internet Information Services.
To install IIS, follow the Windows feature dialogs. The article screenshots below show the Windows feature dialogs and options during installation.
Note: You can also use the Windows PPI/launcher to install packages: https://sites.google.com/site/karjolblogs/downloads/wpilauncher.zip?attredirects=0&d=1
MySQL Installation
There are a couple of options for installing MySQL on Windows: extract the zip and run manually, or use the MySQL Installer to install as a Windows service. Downloads are available at: http://dev.mysql.com/downloads/mysql/
I chose the MySQL Installer 5.6 for Windows in my setup and used the Custom setup type to install the server, MySQL Workbench and the Notifier. If you install Workbench, you may need the Microsoft Visual C++ 2013 Runtime:
- Microsoft Visual C++ 2013 runtime: http://www.microsoft.com/en-us/download/details.aspx?id=40784
After installation, verify you can connect using MySQL Workbench or the MySQL Command Line Prompt.
You can create the required database using the commands mentioned in the MySQL User Manual.
PHP Installation
Download the Windows PHP build from http://windows.php.net/download. For IIS you should use the non-thread safe (NTS) build and extract it to a folder of your choice (for example C:\php). In this article I used PHP 7.0.
After unzipping, copy and edit the php.ini-production file (rename to php.ini) and place it in C:\Windows (or keep it in your PHP directory and point IIS to it using environment variables — but the simplest approach is to copy to C:\Windows as shown below).
Open php.ini in a text editor and make these minimum changes (uncomment and set values):
cgi.force_redirect = 0
fastcgi.impersonate = 1
; set extension_dir to the ext folder in your PHP install:
extension_dir = "C:\php\ext"
; set timezone
date.timezone = "Your/Timezone"
Set date.timezone to your server timezone (example: America/New_York). See the PHP timezone list at: http://php.net/manual/en/timezones.php
PHP extensions for MySQL
In order for PHP to work with MySQL, enable the appropriate Windows extensions. Note: if you are using PHP 7 or newer, the old php_mysql.dll extension was removed. Use mysqli or PDO instead. Example lines to enable:
extension=php_curl.dll
extension=php_mbstring.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll ; optional, for PDO
The php_curl.dll extension is often required by applications (for example WordPress) to fetch remote updates.
You can also use the wpilauncher.exe mentioned above to help automate installation.
Configuring PHP and MySQL with IIS (FastCGI)
After setting up PHP, configure IIS to run PHP via FastCGI.
- Ensure the CGI feature is installed for IIS (Server Manager → Add Roles/Features → Web Server (IIS) → Application Development → CGI).
- In IIS Manager, add a Handler Mapping for PHP with these values:
- Request path:
*.php - Module:
FastCgiModule - Executable: full path to
php-cgi.exe(for exampleC:\php\php-cgi.exe) - Name:
PHP
- Restart IIS after the handler mapping change.
Verifying PHP + MySQL
Create a file phpinfo.php in your site root (wwwroot) with the following content:
<?php phpinfo(); ?>
Browse to http://localhost/phpinfo.php. The PHP settings page should load; search the page for MySQL / mysqli / PDO sections to confirm that PHP has the MySQL extensions loaded.
Installing Joomla (optional)
The author includes a packaged Joomla.exe for quick setup. If you use it, the steps below summarize how I proceeded:
- Download the package: https://sites.google.com/site/karjolblogs/downloads/Joomla.zip?attredirects=0&d=1
- The package installs Joomla and Microsoft WebMatrix. Open the site from WebMatrix and edit
configuration.phpin the Joomla directory to set the correct DB username/password and other settings.
Find the port assigned to the site in WebMatrix (note it for external access).
Click on the site in WebMatrix to open it (screenshot):
After updating configuration.php with the DB credentials and restarting IIS, the Joomla site should run.
Firewall and external access
To let other hosts access your site you must allow incoming connections on the port used by the site (commonly TCP 80 for HTTP). Example steps for Windows Firewall with Advanced Security:
- Open Windows Firewall with Advanced Security.
- Inbound Rules → Action → New Rule
- Choose Predefined and select: World Wide Web Services (HTTP)
- Allow the connection and finish the wizard.
You can then access the site with:
http://<server-ip>:<port>
Troubleshooting
- If
phpinfo()does not show MySQL sections, confirm theextension_dirpath and that the listed extensions are present inC:\php\ext. - If you get 500 errors, check the Windows Event Viewer (Application) and the IIS log files for FastCGI/PHP errors.
- Permission issues: ensure the IIS user (e.g. IIS_IUSRS) has read access to the PHP folder and to your site files.
- If using PHP 7+, do not enable
php_mysql.dll— usephp_mysqli.dllandphp_pdo_mysql.dll.
Notes and further reading
- WAMP alternative: If you prefer a single installer package, see the author’s WAMP post: http://karjol-gt.blogspot.in/2016/01/installing-wamp-server.html
- PHP Windows downloads: http://windows.php.net/download
- MySQL downloads: http://dev.mysql.com/downloads/mysql/
That's it — Happy Coding.