LNMP + CodeIgniter = LNMP + CodeIgniter = LNMP + CodeIgniter = LNMP + CodeIgniter = LNMP + CodeIgniter = LNMP + CodeIgniter yum install -y nginx mariadb-server mariadb php php-fpm php-mysql

/etc/nginx/nginx.conf: /etc/nginx/nginx.conf:

Example code: /etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events { 
worker_connections 1024;
}
http { 
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; 
access_log /var/log/nginx/access.log main; 
sendfile on; 
tcp_nopush on; 
tcp_nodelay on; 
keepalive_timeout 65; 
types_hash_max_size 2048; 
include /etc/nginx/mime.types; 
default_type application/octet-stream; 
server { 
listen 80 default_server; 
#listen [::]:80 default_server; 
server_name _; 
root /var/www/html; 
# Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; Location / {} location ~.php${fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name; 
include fastcgi_params;
 } 
error_page 404 /404.html; 
location = /40x.html { } error_page 500 502 503 504 /50x.html; 
location = /50x.html { } 
}
}
Copy the code

Start the Nginx Nginx

*/var/ WWW/HTML * create a new info.php file to check whether PHP is installed successfully.

Example code: /var/www/html/info.php <? php phpinfo(); ? >Copy the code

To start the php-fpm process: service php-fpm start

Start, use the following command to check the PHP – FPM process monitoring which port netstat NLPT | grep PHP – FPM

Chkconfig php-fpm on = chkconfig php-fpm on

At this point, Visit http://< your CVM IP address >/info.php to browse to the info.php page we just created, MySQL systemctl start Mariadb MySQL systemctl start Mariadb

Configure the password. The default password is QcloudLabPASSWORD

mysqladmin -u root password 'QcloudLabPASSWORD'

MySQL -u root -pqCloudlabpassword

Create database CI;

Exit MySQL and return to Bash shell exit

At this point, the LAMP environment is set up download and install the CI framework and execute the following command, Download the CI framework to the home directory wget https://mc.qcloudimg.com/static/archive/282f387cae30259401a8800e8d17e60b/CodeIgniter-3.1.4.zip – O ~/CodeIgniter.zip

Zip unzip ~/ codeignite. zip && mv ~/ codeignite-3.1.4 /* /var/ WWW/HTML

At this point, visit http://< your CVM IP address >/index.php and you can see that the CI welcome page is returned to practice the CI framework

Knowledge to prepare Here will show you how to through the CI framework, making the visit http:// < your CVM IP address > / index. The PHP/firstrun/hello back to “hello, World” in the routing rules of CI, routing matching rules: User access URL for http:// < your CVM IP address > / index. The PHP/firstrun/hello CI will find application/controller directory called firstrun. PHP PHP file [?]

This PHP file has a class called Firstrun and that class has a method called Hello that handles the request for that URL and responds to it

CI will automatically convert the case here

Write the calling code in the/var/WWW/HTML/application/controllers directory. Create a new call Firstrun PHP file, the code is as follows: The sample code: / var/WWW/HTML/application/controllers/Firstrun.

Modify the nginx configuration and restart the /etc/nginx-nginx. conf file.

Example code: /etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; }http { log_format main'$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; 
access_log /var/log/nginx/access.log main; 
sendfile on; 
tcp_nopush on; 
tcp_nodelay on; 
keepalive_timeout 65; 
types_hash_max_size 2048; 
include /etc/nginx/mime.types; 
default_type application/octet-stream; 
server { listen 80 default_server; #listen [::]:80 default_server; 
server_name _; 
root /var/www/html; 
# Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / {
 Rewrite (try_files); try_files $uri $uri/ /index.php? $query_string;} the location ~. PHP ($| /) {f astcgi_pass 127.0.0.1:9000; f astcgi_index index.php; fastcgi_split_path_info ^(.+.php)(.*)$; f astcgi_param PATH_INFO$fastcgi_path_info; 
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
include fastcgi_params; 
} error_page 404 /404.html; 
location = /40x.html { } error_page 500 502 503 504 /50x.html; 
location = /50x.html { } }}
Copy the code

Restart Nginx Nginx -s reload

Http://firstrun /hello = http://firstrun /hello = http://firstrun /hello = http://firstrun /hello = http://firstrun /hello = http://firstrun /hello = http://firstrun /hello