centos7 nginx+php7yum安装
centos7 nginx+php7yum安装。
一.安装nginx
1.安装yum源
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.安装nginx
yum install -y nginx
3.启动nginx并设置开机自动运行
- systemctl start nginx #启动,restart-重启,stop-停止
- systemctl enable nginx #开机启动
4.查看版本及运行状态
- nginx -v #查看版本
- ps -ef | grep nginx #查看运行状态
二.安装php7
1.安装yum源
- rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
2.查看php7 yum组件,示例安装php7.2
- yum search php72w
3.选择自己需要的组件安装,php72w.x86_64 和 php72w-fpm.x86_64 为核心程序必装
yum install php72w.x86_64 php72w-fpm.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-gd.x86_64 php72w-ldap.x86_64 php72w-mbstring.x86_64 php72w-mcrypt.x86_64 php72w-mysql.x86_64 php72w-pdo.x86_64 php72w-pecl-redis.x86_64
4.启动php并设为开机启动
- systemctl start php-fpm #启动,restart-重启,stop-停止
- systemctl enable php-fpm #开机启动
5.查看版本及运行状态
- php-fpm -v #查看版本
- ps -ef | grep php-fpm #查看运行状态
进行完以上步骤之后,读者自行在nginx中配置web目录,已经可以正常运行了,但是此时nginx和php是以root身份运行,以最高权限运行web文件会给系统带来安全隐患,以下为权限配置示例
三.修改nginx配置
vi /etc/nginx/conf.d/default.conf
- 找到第一个location中的这一行
index index.html index.htm;
修改为:
index index.php index.html index.htm; #添加index.php
2.
把FastCGI server这行下面的location的注释去掉,并修改成下面这样子
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;
}
service nginx restart #重启nginx
service php-fpm start #开启php-fpm
3.
在网站根目录新建index.php文件
vim /usr/share/nginx/html/index.php
4.
输入内容:
<?php
phpinfo();
5.
在浏览器中输入虚拟机ip,已经可以看到phpinfo的信息了
在windows上修改hosts文件,添加一行
192.168.6.114 www.test1.com #配置虚拟机ip对应域名
6.
现在就可以在windows上用www.test1.com访问虚拟机配置的服务器了
centos7 nginx+php7yum安装的更多相关文章
- Centos7:nginx的安装,配置及使用
安装依赖 yum install gcc-c++//gcc环境 yum install -y pcre pcre-devel//PCRE:nginx的http模块使用pcre来解析正则表达式 yum ...
- centos7 - nginx配置安装phpmyadmin
原文 https://www.linuxidc.com/Linux/2017-10/147556.htm 使用Nginx搭建phpMyAdmin Nginx有什么用? Nginx可读作Engin ...
- Linux centos7 nginx 的安装
2021-08-18 1. 环境 # 操作系统[root@test007 /]# uname -aLinux test007 3.10.0-862.el7.x86_64 #1 SMP Fri Apr ...
- Linux centos7环境下安装Nginx
Linux centos7环境下安装Nginx的步骤详解 1. 首先到Nginx官网下载Nginx安装包 http://nginx.org/download/nginx-1.5.9.tar.gz ...
- (转)Centos7 Nginx安装
场景:工作中使用的suse,因为系统可可查资料太少,且系统中一些功能的确实,导致很多集群中功能无法顺利测试通过,在Centos上面进行测试,能够更快的熟悉项目的架构过程! 1 安装准备 首先由于ngi ...
- centos7通过yum安装nginx
centos7通过yum安装nginx nginx不支持centos7通过yum直接安装~~~ 1.查看操作系统位数[root@-jenkins ~]# rpm -aq|grep centos-rel ...
- linux(centos7) nginx php mysql安装
环境: linux:centos7 php:7.0 基础命令 // yum install -y lrzsz // centos7 默认已安装yum install epel-release ngin ...
- centos7 下 yum 安装Nginx
centos7 下 yum 安装和配置 Nginx 添加yum源 Nginx不在默认的yum源中,可以使用epel或者官网的yum源,这里使用官网的yum源 rpm -ivh http://nginx ...
- CentOS7离线安装Nginx(详细安装过程)
CentOS7离线安装Nginx(详细安装过程) 1.安装gcc.g++ 下载好所需的文件后上传至服务器(下载地址:https://download.csdn.net/download/a729360 ...
- CentOS7 nginx安装与卸载
简明清晰,易操作,参照: CentOS7 nginx安装与卸载
随机推荐
- Mysql函数10-IF
IF函数用于判断条件是否成立,成立则执行命令1,不成立则执行命令2. 1.sql查询出一列create_time select create_time from goods where id=65 2 ...
- SourceGenerator 生成db to class代码优化结果记录 二
优化 在上一篇留下的 Dapper AOT 还有什么特别优化点的问题 在仔细阅读生成代码和源码之后,终于得到了答案 个人之前一直以为 Dapper AOT 只用了迭代器去实现,所以理应差不多实现代码却 ...
- 【节选 转载】人形机器人Optimus擎天柱技术解析
参考原文: https://www.sohu.com/a/589454391_383324?scm=9010.8000.0.0.1265 可以利用动作捕捉"学习"人类动作,依靠视觉 ...
- 如何计算两个正太分布的KL散度 —— 正太分布的KL散度 (Kullback-Leibler divergence) 计算
参考: https://blog.csdn.net/int_main_Roland/article/details/124650909 给出实现代码: def get_kl(): mean0, log ...
- 为什么是Google创造了AlphaGo,而不是其他公司?
相关: Artificial Intelligence | 60 Minutes Full Episodes 答案: Google一直在进行AI方向的探索: Google有足够的算力.
- 在docker容器中创建用户组和用户,并且多用户共用一个anaconda环境
背景: 实验室可以使用一个浪潮的AI计算平台,该平台运行的都是docker容器,并且不能联网,因此谁要是想要安装什么软件的话就需要自己单独打包镜像到平台上,大致步骤为: 1. 在平台的镜像管理中找 ...
- 【转载】 NeuroEvolution with MarI/O —— 使用人工智能来通关超级玛丽
原文地址: http://glenn-roberts.com/posts/tech/2015/07/08/neuroevolution-with-mario.html 参考: https://v.q ...
- ubuntu22.04系统环境下使用vs code安装pylint检查python的代码错误
紧跟前文: ubuntu18.04系统环境下使用vs code安装pylint检查python的代码错误 pylint官网: https://pylint.pycqa.org/ =========== ...
- java关于数组的复制,反转、查找
一.数组的赋值: arr2=arr1;对于该赋值而言,地址值一样,所以arr1会随着arr2的变化而变化.这不能称作数组的复制,因为只是把地址赋过去了.地址一样,指向的是堆空间中唯一的数组实体(数值) ...
- 将整个工程的GBK转为utf-8格式
eclipse将整个工程转为utf-8时原先中文注释会变为乱码,13年时写了个脚本将整个文件的java以及配置文件转为utf-8格式,下面是代码 package com.code.pd; import ...