Windows Environment
- Install XAMPP or WAMP
- Download and Unzip the package from Codeigniter.com
- Extract all the documents in the server space (htdocs or www directory)
Linux Environment
- Download and Unzip the package from Codeigniter.com
- Place the extracted folder in /var/www (in WAMP) or xampp/htdocs (XAMPP)
Base URL
- Go to application/config/config.php
- Define base URL as $config['base_url'] = 'http://localhost/path/to/folder';
How to remove index.php from URL?RewriteEngine on RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA]
- go to root
- create htaccess file
- Add below code inside it
Note: .htaccess code varies depending on the hosting server. Some hosting servers (e.g.: Godaddy) need to use an extra? in the last line of the above code. The following line will be replaced with the last line in applicable case:RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Nginx Configuration
server { server_name domain.tld; root /path-to-codeigniter-folder; //you codeigniter path index index.html index.php; # set expiration of assets to MAX for caching location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ { expires max; log_not_found off; } location / { # Check if a file or directory index file exists, else route it to index.php. try_files $uri $uri/ /index.php; } location ~* \.php$ { fastcgi_pass 127.0.0.1:9000; include fastcgi.conf; } }
- Open nginx config file (by default: /etc/nginx/sites-available/default)
- Add below code inside it.
Database Configuration
- Go to application/config/database.php
- Set the following configuration variables.
- Host
- Username
- Password
- Database Name
- Port
Set Default Controller
- Go to application/config/routes.php
- set the following configuration variable value with your controller name. (default_controller)
AutoLoad Library And Helper
- Go to application/config/autoload.php
- set Auto load value like $autoload['libraries'] = array('database', 'session');
- set Helper value like $autoload['helper'] = array('url', 'file', 'form', 'html', 'text');
Comments
Post a Comment