Always been imitated
Never surpassed

centos yum 安装nginx mysql php网站环境

#先执行yum更新推荐 yum update
安装php

yum install php php-fpm
service php-fpm start
chkconfig php-fpm on

安装nginx

rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
#yum 默认没有nginx ,需要下载安装包
yum install nginx
service nginx start
chkconfig --add nginx
chkconfig nginx on
ps aux|grep nginx #查看运行文件路径
#/etc/nginx/nginx.conf
cp -a/etc/nginx/conf.d/default.conf /etc/nginx/conf.d/test.conf #创建站点路径
#编辑配置文件
server {
listen 80;
server_name xxx.wang;
rewrite ^(.*) https://xxx.wang$1 permanent;
} #301跳转http到https
server {
listen 443;
ssl on;
server_name xxx.wang;
root /usr/share/nginx/xiao;
ssl_certificate /usr/share/nginx/xiao/xxx.wang.crt;
ssl_certificate_key /usr/share/nginx/xiao/xxx.wang.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL;
index index.html index.php index.htm; #ssl配置
location /
{
try_files $uri $uri/ /index.php?q=$uri&$args; #安装是WordPress程序,添加伪静态规则
}
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;
} #添加php-fpm处理模块php文件
}
#以上站点配置文件可直接复制

以上操作直接执行完成测试访问会有“File not found.报错”排查错误日志发现
cat /var/log/nginx/error.log |more

1.”/xiao/index.php” is forbidden (13: Permission denied) 检查目录权限正常,原因是yum安装完成php-fpm服务运行账号是apache,添加www账号,改成www 运行nginx和php-fpm ,设置对应目录属主www 重启服务后正常

useradd -g www www -s /bin/false
ps -ef | grep php-fpm 查看运行路径
vi /etc/php-fpm.conf 查看配置文件
vi /etc/php-fpm.d/www.conf
user = www
group = www
vi /etc/nginx/nginx.conf
user www www;

2. 前面报错处理完后访问仍是 File not found“,排查日志报错”FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream 各种检查百度搜索配置均正确,怀疑了很久人生,最后,最后就是粗心,是自己把文件名称写错了index.pho ,改成index.php

安装mysql

yum -y install mysql
yum -y install mysql-server mysql-devel
service mysqld restart
chkconfig --add mysqld
chkconfig mysqld on
mysql -uroot -p
use mysql;
update user set password=password("xxx") where user="root";
flush privileges;
编辑mysql配置文件
etc/my.cnf
datadir=/var/lib/mysql #指定数据库保存文件
赞(0)
@请尊重原创,未经允许不得转载:军S小站 » centos yum 安装nginx mysql php网站环境

抢沙发

评论前必须登录!

 

智慧源于勤奋,伟大出自平凡

联系我们

© 2019 军S小站   ©备案号: 蜀ICP备17043886号-2    网站地图   友情链接