nginx和fastcgi的通信方式有兩種,一種是TCP的方式,一種是unix socke方式
- TCP是使用TCP端口連接127.0.0.1:9000
- Socket是使用unix domain socket連接套接字
1、TCP配置方式
- 編輯 /etc/nginx/conf.d/你的站點(diǎn)配置文件。將fastcgi_pass參數(shù)修改為127.0.0.1:9000
- 編輯php-fpm配置文件 /etc/opt/rh/rh-php71/php-fpm.d/www.conf
- 將user和group的值設(shè)為nginx
user = nginx
group = nginx
- listen的值設(shè)置為127.0.0.1:9000,和站點(diǎn)配置文件中fastcgi_pass參數(shù)的值一樣
- 完成后,,我們必須更改 selinux 的資料庫(kù)并加入9000端口為httpd服務(wù)的有效連接。
semanage port -a -t http_port_t -p tcp 9000
2、unix socket配置方式
以文件(一般是.sock)作為socket的唯一標(biāo)識(shí)(描述符),需要通信的兩個(gè)進(jìn)程引用同一個(gè)socket描述符文件就可以建立通道進(jìn)行通信了。
sudo touch /var/run/php7.1-fpm.sock
sudo chown nginx:nginx /var/run/php7.1-fpm.sock
sudo chmod 666 /var/run/php7.1-fpm.sock
- 將user和group的值設(shè)為nginx
user = nginx
group = nginx
- listen的值設(shè)置為/var/run/php7.1-fpm.sock,和站點(diǎn)配置文件中fastcgi_pass參數(shù)的值一樣
- 去掉listen.owner、listen.group,、listen.mode前面的分號(hào),,以使php-fpm使用unix socket,并將listen.owner,、listen.group的值設(shè)置為nginx
listen.owner = nginx
listen.group = nginx
- 修改nginx站點(diǎn)配置文件.編輯 /etc/nginx/conf.d/你的站點(diǎn)配置文件,。將fastcgi_pass參數(shù)修改為/var/run/php7.1-fpm.sock
- 重啟nginx和php-fpm服務(wù)(最好先重啟php-fpm再重啟nginx)
#創(chuàng)建Snipe-IT數(shù)據(jù)庫(kù)
# 登錄數(shù)據(jù)庫(kù)
sudo mysql -u root -p
mysql> create database snipeit;
mysql> grant all on snipeit.* to 'snipe_user'@'192.168.1.%' identified by 'snipeitpass.';
mysql> flush privileges;
#4.安裝Snipe-IT
# 安裝git
[root@ops-01 ~]# cd /data/
[root@ops-01 data]# sudo git clone https://github.com/snipe/snipe-it snipeit
# 從提供的示例文件創(chuàng)建.env文件
cd /data/snipeit
sudo cp .env.example .env
# 編輯.env文件,,根據(jù)提供的說(shuō)明找到以下行并修改
# REQUIRED: BASIC APP SETTINGS
# --------------------------------------------
APP_ENV=production
APP_DEBUG=false # 排錯(cuò)的時(shí)候這個(gè)改為true
APP_URL=192.168.1.XXX
APP_TIMEZONE='Asia/Shanghai'
APP_LOCALe=zh-CN
# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
DB_CONNECTION=mysql
DB_HOST=192.168.1.XXX
DB_DATABASE=snipeit
DB_USERNAME=snipe_user
DB_PASSWORD=snipeitpass.
DB_PREFIX=null
DB_DUMP_PATH='/usr/bin'
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
#權(quán)限設(shè)置
#5.安裝Composer
# 使用以下命令安裝Composer,Composer是PHP的依賴管理器
[root@ops-01 ~]# cd ~
curl -sS https:///installer | php
All settings correct for using Composer
Downloading...
Composer (version 1.6.5) successfully installed to: /root/composer.phar
Use it: php composer.phar
[root@ops-01 ~]# mv /root/composer.phar /usr/bin/composer
composer config -g repo.packagist composer https://packagist. #使用國(guó)內(nèi)鏡像加快composer install 速度
php composer.phar install --no - dev --prefer - source
#APP_KEY
[root@ops-01 snipeit]#composer update --no-scripts #先更新,解決項(xiàng)目的所有依賴
php artisan key:generate
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command? (yes/no) [no]:
> yes
Application key [base64:yRuvb8BjQhuBDo6tYRToAbQ8PwiIKt0xko2TOVk5QqM=] set successfully.
#6.nginx 配置
[root@ops-01 conf.d]#mkdir /var/log/nginx/snipeit
vim snipeit.conf
server {
listen 80;
server_name snipeit.gabjoy.local;
root /data/snipeit/public;
index index.php index.html index.htm;
access_log /var/log/nginx/snipeit/snipeit.aniu.so.access.log main;
error_log /var/log/nginx/snipeit/snipeit.aniu.so.error.log;
location =/.env{
return 404;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
root /data/snipeit/public;
try_files $uri $uri/ =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# 具體優(yōu)化參數(shù)在nginx.conf配置
通過(guò)瀏覽器訪問(wèn):
————————————————
版權(quán)聲明:本文為CSDN博主「shaonbean」的原創(chuàng)文章,,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明,。
原文鏈接:https://blog.csdn.net/wh211212/article/details/80814045