宜蘭縣教育支援平台 會員登入 會員註冊 我的i教書

« 上一篇 | 下一篇 »

參考網頁:LEMP server on CentOS 7 with FastCGI

安裝 epel-release 套件
# yum install epel-release

安裝 Mariadb SQL Server
# yum install mariadb-server mariadb

啟動 Mariadb SQL Server
# systemctl enable mariadb
# systemctl start mariadb

第一次使用時的設定
# /usr/bin/mysql_secure_installation

安裝 Nginx Web Server
# yum install nginx

修改設定檔 /etc/nginx/nginx.conf
# vim /etc/nginx/nginx.conf
server 區段中加入
   server {
        listen       80 default_server;
        (略)

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }

        location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

啟動 Nginx Web Server
# systemctl enable nginx
# systemctl start nginx

開啟防火牆設定
# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --permanent --zone=public --add-service=https

安裝 PHP with FastCGI 套件
# yum install php-cli php spawn-fcgi

新增 /usr/bin/php-fastcgi 設定檔
# vim /usr/bin/php-fastcgi
#!/bin/sh
if [ `grep -c "nginx" /etc/passwd` = "1" ]; then
    FASTCGI_USER=nginx
elif [ `grep -c "www-data" /etc/passwd` = "1" ]; then
    FASTCGI_USER=www-data
elif [ `grep -c "http" /etc/passwd` = "1" ]; then
    FASTCGI_USER=http
else
# Set the FASTCGI_USER variable below to the user that
# you want to run the php-fastcgi processes as

FASTCGI_USER=
fi

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 6 -u $FASTCGI_USER -f /usr/bin/php-cgi

更新檔案權限
# chmod +x /usr/bin/php-fastcgi

新增 /etc/systemd/system/php-fastcgi.service 設定檔
# vim /etc/systemd/system/php-fastcgi.service
[Unit]
Description= php-fastcgi systemd service script

[Service]
Type=forking
ExecStart=/usr/bin/php-fastcgi start

[Install]
WantedBy=multi-user.target

啟動相關服務
# systemctl daemon-reload
# systemctl enable php-fastcgi.service
# systemctl start php-fastcgi.service



如果你的網誌不支援引用網址自動搜尋功能,那麼你可以使用下列的直接引用網址來引用本文章:

http://blog.ilc.edu.tw/blog/trackback.php?id=630741