CentOS7安装nginx+php+mysql/mariadb
原文链接: http://www.kylin-ux.com/2017/04/23/linux-ops-centos7安装nginx-php-mysql-mariadb
本文以安装禅道为例
下载禅道并解压缩
|
|
web根目录为
/opt/zentaopms/www
配置nginx时会用到, 即root /opt/zentaopms/www
minimal版需要安装unzip,sudo yum install unzip
安装nginx
CentOS7系统, 需要安装epel
, 才能使用yum安装nginx
下载epel
安装nginx
安装数据库
安装mariadb
或者, 安装mysql
卸载mariadb-libs
安装mysql
mysql-community-* 请自行下载, 网址https://dev.mysql.com/downloads/mysql/
minimal版需要安装net-tools,sudo yum install net-tools
安装php-fpm
|
|
安装php-mysqlnd
|
|
配置nginx
修改/etc/nginx/nginx.conf
server
节点中root /usr/share/nginx/html;
修改为root /opt/zentaopms/www;
server
节点中root
下一行添加index index.php
server
节点添加如下配置1234567location ~ \.php$ {root /opt/zentaopms/www;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}配置完成后, grep输出
1234567891011121314grep "location ~ \\\.php" /etc/nginx/nginx.conf -A8 -B5error_page 500 502 503 504 /50x.html;location = /50x.html {}location ~ \.php$ {root /opt/zentaopms/www;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}}
php相关配置内容记不住也没关系
grep php /etc/nginx/ -R
值都是从哪儿来的呢?
fastcgi_pass
fastcgi_param/etc/nginx/fastcgi_params.default
文件里找去
提示
xxx的配置信息通常在xxx.d/目录
看一下/etc/php-fpm.conf
中include=xxx
就明白了
启动
|
|
设置开机启动
|
|
其他操作-禅道要求
|
|
SELinux
由于SELinux
引起的问题, 可通过sealert
分析解决
粗暴一点, 直接
常见问题
Q1. 403 Forbidden
/var/log/nginx/error.log
“index.html” is forbidden (13: Permission denied)
index of “/opt/zentaopms/www/“ is forbidden
A1:nginx.conf
中添加index index.php
chmod 755 /opt
Q2. Access denied.
/var/log/nginx/error.log FastCGI sent in stderr: “Unable to open primary script: index.php (Permission denied)” while reading response header from upstream
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:8086 failed (13: Permission denied)
A2:sudo setenforce 0