CentOS7安裝 Nginx + php7 + php-fpm
原文 : https://ivanagyro.medium.com/於centos7安裝-nginx-php7-php-fpm-laravel5-6-df8631681acf
安装nginx
1/ 用yum安裝Nginx
yum install nginx
預設開機開啟Nginx
systemctl enable nginx
啟動Nginx
systemctl start nginx
安装php
2 安装Remi和EPEL数据源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm
3. 启用Remi
vi /etc/yum.repos.d/remi.repo
4.更改[remi]区域的代码块为如下,相同则不用更改
[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
5.启用Remi PHP7.3数据源
vi /etc/yum.repos.d/remi-php73.repo
6.更改[remi-php73]区域的代码块为如下
[remi-php73]
name=Remi's PHP 7.3 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php73/$basearch/
mirrorlist=https://rpms.remirepo.net/enterprise/7/php73/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php73/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
7.升级php到php7.3
yum -y upgrade php*
8.检查php版本
php -v
9.重启php-fpm
service restart php-fpm
安裝與設定php-fpm
- 安裝php-fpm
yum install php-fpm
2. 設定php-fpm,修改 /etc/php-fpm.d/www.conf
修改user和group,為nginx
user = nginx
group = nginx
如果要改為使用socket file(預設使用127.0.0.1:9000),則需開啟並修改listen設定為下方樣子
listen = /path/to/unix/socketlisten.owner = nobody
listen.group = nobody
listen.mode = 0666
3. 如果在debug階段,想要開啟display error,則修改以下設定
php_flag[display_errors] = on
php_flag[display_startup_errors] = on
4. 預設開機開啟php-fpm
systemctl enable php-fpm
5. 啟動php-fpm
systemctl start php-fpm
設定Nginx
- 修改
/etc/nginx/conf.d/default.conf,以連接php-fpm,以下為範例
server {
listen 80;
server_name localhost; #charset koi8-r;
#access_log /var/log/nginx/host.access.log main; root /usr/share/nginx/html;
index index.html index.htm index.php; location / {
# autoindex on; // 如果想要開啟顯示資夾目錄的話加入這條
// 建議只在debug階段開啟
try_files $uri $uri/ /index.php?$query_string;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000
// 若使用file socket則改成下面這行
# fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
2. 重新載入Nginx的設定
nginx -s reload
現在可以試著在Nginx的root directory加入index.php,內容如下。看是否能透過瀏覽器取得php的資訊
CentOS7安裝 Nginx + php7 + php-fpm的更多相关文章
- centos7下搭建nginx+php7.1+mariadb+memcached+redis
一.环境准备 1.首先介绍一下环境,以及我们今天的主角们 我用的环境是最小化安装的centos7,mariadb(江湖传言mysql被oracle收购后,人们担心像java一样毁在oracle手上于是 ...
- CentOS7下搭建Nginx+PHP7的安装配置
一.安装编译工具及库文件: yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel 环境要求 nginx是C ...
- linux下nginx安裝
1.yum安裝 yum安裝 http://nginx.org/packages/centos/7/noarch/RPMS/ 第一步: 安裝命令: yum localinstall http://ng ...
- Ubuntu安裝nginx-1.6.2
1.在執行完./configure 和make install 後出現 test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/ ...
- Centos7 Nginx+PHP7 配置
Centos7 Nginx+PHP7 配置 内容: 源码编译安装Nginx和PHP 配置PHP和Nginx,实现Nginx转发到PHP处理 测试 设置Nginx.PHP开机自启 安装的版本: Ngin ...
- 沈逸老师ubuntu速学笔记(2)-- ubuntu16.04下 apache2.4和php7结合编译安装,并安裝PDOmysql扩展
1.编译安装apache2.4.20 第一步: ./configure --prefix=/usr/local/httpd --enable-so 第二步: make 第三步: sudo make i ...
- 鸟哥之安裝 CentOS7.x
http://linux.vbird.org/linux_basic/0157installcentos7.php since 2002/01/01 新手建議 開始閱讀之前 網站導覽 Linux 基礎 ...
- centos7 系統vps安裝mysql5.6及設置本地遠程連接筆記
用xshell連接上vps 1,下载mysql的repo源 wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm su ...
- Centos7編譯安裝LAMP平臺
什麽是LAMP? 拆開看 L 就是Linux系統 A是Apache的縮寫 M.P則是MySQL和PHP的简写. 其实就是把Apache, MySQL以及PHP安装在Linux系统上,组成一个环境来运行 ...
- Linux Centos7.2 编译安装PHP7.0.2
操作环境: 1.系统:Centos7.2 2.服务:Nginx 1.下载PHP7.0.2的安装包解压,编译,安装: $ cd /usr/src/ $ wget http://cn2.php.net/d ...
随机推荐
- VUE Angular通用动态列表组件-亦可为自动轮播组件-02-根据数据量自动横向滚动,鼠标划入停止滚动
本文为横向轮播,纵向轮播/动态列表组件请戳---- 代码是angular的,稍微改改就可以放入Vue项目里,差别不大哟 以下代码可以根据实际情况自行调整 父组件html <app-scroll- ...
- 笔记本USB接口案例_分析-笔记本USB接口案例_实现
笔记本USB接口案例_分析 笔记本电脑(laptop)通常具备使用USB设备的功能.在生产时,笔记本都预留了可以插入USB设备的USB接口, 但具体是什么USB设备,笔记本厂商并不关心,只要符合USB ...
- 玩转web3第二篇——Web3UI Kit
介绍 开发web2应用的时候,可以很方便找到很多优秀的UI库,比如antd,material ui,element ui等等,但web3应用对应的UI库却不多. 今天给大家介绍一款优秀的WEB3的UI ...
- python3中,//、/ 的区别
//:地板除,返回整数结果 /:浮点数除法,返回浮点结果 例: print(3//2) #输出1 print(3/2) #输出1.5 拓展:判断水仙花数 # 题目:打印出所有的"水仙花数 ...
- EPICS Archiver Appliance的定制部署2
EPICS Archiver Appliance的定制部署1 按上面的步骤Archiver可以跑起来了,试了一下,发现waveform不能archive,看服务状态: 看起来正常,怀疑在profile ...
- 大规模 IoT 边缘容器集群管理的几种架构-1-Rancher+K3s
前文回顾 大规模 IoT 边缘容器集群管理的几种架构-0-边缘容器及架构简介 ️Reference: IoT 边缘计算系列文章 Rancher + K3s 简介 Rancher: Kubernetes ...
- selenium结合tenacity的retry实现验证码失败重试
说在前面 验证码登录的demo后续可以单独讲解,VIP学员对这部分应该都是掌握的,此处不再赘述 本文假设了一个场景 你通过OCR识别的验证码是有一定的错误几率的 本文是通过识别后的验证码去加一个随机字 ...
- Vue急速入门-5
vue-cli创建项目 前端工程化,项目>>>(vue-cli),创建处vue项目,单页面应用(spa) vue-cli创建项目开发,在项目中开发,最后上线,一定要编译 '纯粹的ht ...
- LG P4449 & JZOJ 于神之怒
\(\text{Problem}\) JZOJ上,求 \[\sum_{i=1}^n \sum_{j=1}^m \gcd(i,j)^k \] 对 \(10^9+7\) 取模 \(n,m,k \le 5 ...
- 我用ChatGPT做直播技术选型,卷死了同事
摘要 近两年即时通讯/直播产品炙手可热,市场上针对ToB的产品日益增多,企业该如何去选型呢?本文分享了笔者对于直播产品的思考,将从直播SDK实例功能特性.常见业务场景.注意事项及最佳实践等方面介绍如何 ...