yum install -y nginx mariadb-server mariadb php php-fpm php-mysqlphp
啓動並檢查 Nginx 和 PHP 的安裝狀況html
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 { } } }
啓動nginx服務器node
檢查php環境搭建,phpinfo();mysql
啓動 PHP-FPM 進程:nginx
service php-fpm start
啓動以後,能夠使用下面的命令查看 PHP-FPM 進程監聽哪一個端口
netstat -nlpt | grep php-fpm
chkconfig php-fpm on
啓動並配置 MySQL
systemctl start mariadb
配置密碼, 這裏默認使用密碼 QcloudLabPASSWORD
mysqladmin -u root password 'QcloudLabPASSWORD'
登陸 MySQL
mysql -u root -pQcloudLabPASSWORD
建立數據庫 CI
create database CI;
退出 MySQL, 回到 Bash shell
下載 CI 框架
Firstrun.php
的 PHP 文件
Firstrun
的 classhello
的方法, 該方法處理對此 URL 地址的請求並做出響應編寫調用代碼sql
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Firstrun extends CI_Controller { public function hello() { echo 'Hello World'; } }
修改nginx配置並重啓shell
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 / { # 這裏使用try_files進行url重寫,不用rewrite了。 try_files $uri $uri/ /index.php?$query_string; } location ~ .php($|/) { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+.php)(.*)$; fastcgi_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 { } } }
重啓 Nginx數據庫
大功告成bash