X-osadminの自留地
  • 博客主页 HomePage
  • 技术小絮 Tech
  • 软件专题 Softs
    • proxmox
    • openwrt
    • chromebook
    • Zerotier
    • 虚拟化
  • 友情链接 Following

xosadmin

BGPlayer / Codes learner / Love Linux
Posts
73
Comments
0

友情链接 – Friendly Links

  • Add your site here…
xosadmin
6 years ago

CentOS 7用yum配置php7.2+mariadb+nginx

  1. 更新Linux源并安装EPEL+Webtatic源

yum -y install epel*

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2. 清理系统,清除原有软件

yum -y remove httpd* mysql* php*

3. 安装PHP 7.2

yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-gd php72w-mbstring php72w-mysqlnd php72w-pdo php72w-xml

安装完成后,需要将php-fpm设置为开机启动,并立即启动它,命令如下:

systemctl enable php-fpm

systemctl start php-fpm

4. 安装Mariadb,这里也采用yum安装

yum -y install mariadb mariadb-server

5. 安装完成后,需要对mariadb进行初始设置,命令如下:

systemctl enable mariadb && systemctl start mariadb

mysql_secure_installation

在执行最后一条命令时,会提示输入初始mariadb root密码。由于我们是全新安装,所以默认密码为空,直接回车即可。其他的设置可以依据个人需要通过接下来的设置向导完成。

6. 安装nginx

yum -y install nginx

安装完成后,设置开机启动,并立即启动nginx:

systemctl enable nginx && systemctl restart nginx

在这条命令完成后,nginx已经被成功地安装在/etc/nginx文件夹下,默认的网站存放位置为/usr/share/nginx/html。

7. 默认的nginx是不支持PHP的,所以需要对Nginx作出一点点配置,使其支持PHP。所以,需要编辑/etc/nginx/nginx.conf,并在server的大括号中加入以下内容:

location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}

为了避免不必要的麻烦,这里将fastcgi的SCRIPT_FILENAME地址直接修改成绝对路径。完成后,重启nginx。

systemctl restart nginx

若想测试Nginx和PHP是否配合运行完美,可以在/usr/share/nginx/html目录下新建一个test.php,并填入以下代码后用浏览器访问:

<?php

phpinfo();

?>

若出现PHP的配置信息,则表示各个配置一切正常。反之,请检查配置。

到这里,所有的安装已经全部完成。若出现Nginx成功启动,但访问IP时无法访问,显示拒绝连接的问题,请检查防火墙设置及Selinux设置。

systemctl stop firewalld && setenforce 0

Enjoy~

  • 技术小絮
等 人表示很赞
1,259
0

📮Comments

No Comment.
xosadmin
xosadmin
2 years ago
推荐 Debian上重装Nginx的方法
1. 卸载现有Nginx以及配套包: apt-get remove nginx -y apt-get autoremove 2. 删除配置目录(在删除前可以备份以备恢复): cp -r /etc/nginx /home/backup-ngi ...
  • 技术小絮
507 0
xosadmin
xosadmin
5 years ago
推荐 apt-get时提示different from other instances的解决方案
近日在升级Ubuntu系统时,apt-get提示”trying to overwrite shared ‘/usr/share/doc/libselinux1/changelog.Debian.gz’, ...
  • 技术小絮
1,174 0
xosadmin
xosadmin
6 years ago
推荐 Windows Server 2008安装.net 4.8时提示证书问题的解决方法
近日在给Windows Server 2008 R2安装.net framework 4.8时,提示一个证书错误,无论如何重启或恢复,均无效。错误如下: A certificate chain could not be built to a ...
  • 技术小絮
6,691 0
xosadmin
xosadmin
8 years ago
推荐 OpenVZ如何给VPS启用ppp
大家好!在上一篇文章(如何在Linux(CentOS)上安装OpenVZ)中,我为大家讲述了如何在CentOS环境下安装OpenVZ虚拟框架。在此,有许多网友阅读并安装后,想给自己的VPS开启ppp功能以备不时之需。在这里,补充一篇文章为 ...
  • 技术小絮
  • 虚拟化
2,851 0
xosadmin
xosadmin
6 years ago
推荐 Proxmox挂载Windows Samba时报错的解决方法
近日在Proxmox的Web界面上挂载由Windows Server 2008共享的CIFS(Samba共享)时,界面报出以下错误: create storage failed: error with cfs lock ‘fil ...
  • proxmox
  • 技术小絮
5,962 0
  • Proxmox强制删除离线集群节点方法
  • PVE Cluster给node更换corosync IP的方法
  • HPE Microserver系列降低噪音的一种办法
  • Debian 13 Trixie安装Proxmox VE
  • Windows FTP服务器通过PASV模式无法获取目录的解决方法
  • Proxmox日志出现大量lxcfs truncated错误的解决方案

文章聚合

  • Proxmox强制删除离线集群节点方法
  • PVE Cluster给node更换corosync IP的方法
  • Debian 13 Trixie安装Proxmox VE
  • Proxmox日志出现大量lxcfs truncated错误的解决方案
  • Proxmox通过CLI向LXC挂载已有虚拟磁盘的方法
  • Proxmox VE通过全盘方式直通硬盘

Multilangual Translator

Copyright © 2016-2026 X-osadminの自留地. All rights reserved. 萌ICP备20258855号
  • 博客主页 HomePage
  • 技术小絮 Tech
  • 软件专题 Softs
    • proxmox
    • openwrt
    • chromebook
    • Zerotier
    • 虚拟化
  • 友情链接 Following
Welcome
Forgot password?
Welcome
Forgot password?
Social Login
Login with WeChat QR Code
Unregistered WeChat IDs will be automatically used to create an account.
Scan and Reply with Keywords「登录」Get Verification Code
Social Login
Free registration
Social Login
Reset password
Back to Login