https://github.com/ishaqadhel/deploy-codeigniter-nginx
How To Deploy CodeIgniter PHP Framework to Nginx Linux VPS Server
https://github.com/ishaqadhel/deploy-codeigniter-nginx
codeigniter nginx php
Last synced: 2 months ago
JSON representation
How To Deploy CodeIgniter PHP Framework to Nginx Linux VPS Server
- Host: GitHub
- URL: https://github.com/ishaqadhel/deploy-codeigniter-nginx
- Owner: ishaqadhel
- License: mit
- Created: 2020-11-09T19:34:30.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-27T03:46:00.000Z (over 4 years ago)
- Last Synced: 2025-04-03T06:51:10.817Z (9 months ago)
- Topics: codeigniter, nginx, php
- Language: PHP
- Homepage:
- Size: 258 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# Deploy CodeIgniter On NGINX
## Whats is CodeIgniter?
CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications. [official site](http://codeigniter.com).
## Requirements
App :
- Install Nginx or Apache Server
- Install PHP-fpm (FastCGI Process Manager)
- Install Mysql (Optional)
- Install Composer
PHP version 7.2 or higher is required, with the following extensions installed:
- [intl](http://php.net/manual/en/intl.requirements.php)
- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library
Additionally, make sure that the following extensions are enabled in your PHP:
- json (enabled by default - don't turn it off)
- [mbstring](http://php.net/manual/en/mbstring.installation.php)
- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php)
- xml (enabled by default - don't turn it off)
## Step by Step How To Install NGINX , PHP
- Install NGINX Server :
` sudo apt update`
` sudo apt install nginx`
- Adjusting Firewall :
` sudo ufw app list`
` sudo ufw allow 'Nginx HTTP'`
` sudo ufw status`
- Check Server :
` systemctl status nginx`

*if Nginx is already running, the status will appear as shown above
- If Nginx has not started yet :
` sudo systemctl start nginx`
- Install PHP-fpm :
` sudo apt update`
` sudo apt install php-fpm`
` sudo systemctl restart nginx.service`
- Change Access to folder `var/www/` :
` sudo chmod -R 755 /var/www/`
- Change config on file `/etc/nginx/sites-available/default` :
Add this line on Server block : `index index.php index.html index.htm index.nginx-debian.html;`
PUse this Line below on PHP Block :
```php
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
```
- To check whether the PHP is running or not, go to `/var/www/html/` :
Then create info.php file :
```php
```
If PHP is already running, there is an info for your php on your nginx server on `localhost/info.php`
## Step by Step to Deploy / Install CodeIgniter on NGINX
- install composer :
`sudo apt install composer`
`sudo apt install php-curl`
`sudo apt install php-intl`
- Create Config file on `/etc/nginx/sites-available/codeigniter.conf` :
```php
server { listen 8080 default_server; listen [::]:8080 default_server;
root /var/www/codeigniter/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
```
- Create Link to sites-enabled :
`sudo ln -s /etc/nginx/sites-available/codeigniter.conf /etc/nginx/sites-enabled/`
`sudo nginx -t`
`sudo systemctl restart nginx`
- Install CodeIgniter using composer :
Open Directory Root :
`cd /var/www/`
Install CodeIgniter :
`composer create-project codeigniter4/appstarter [your-project-name]`
`composer update`

## Reference
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04
https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04