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

xosadmin

BGPlayer / Codes learner / Love Linux
Posts
75
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,249
0

📮Comments

No Comment.
xosadmin
xosadmin
7 years ago
推荐 树莓派如何更换成国内源
随着树莓派的兴起,开始学习并使用树莓派的开发者们越来越多。很多人在学习时选用树莓派官方的Raspbian系统。但此系统由于为外国人开发,所以从中调用的软件源比较慢,对大陆的小伙伴非常不利。今天,讲述一下更换树莓派软件源为国内软件源的办法。 ...
  • 技术小絮
1,838 0
xosadmin
xosadmin
4 years ago
推荐 Debian 11启用rc.local方法
rc.local是一个令大家耳熟详的文件,它在Redhat系列操作系统中可以让用户添加自定义开机脚本并运行。但是在Debian 11操作系统中,这个功能不被默认开启。这篇文章将介绍如何开启rc.local。话不多说,开始~ 先通过以下命令 ...
  • 技术小絮
2,962 0
xosadmin
xosadmin
6 years ago
推荐 apt-get出现”No public key available”的解决方法
近日在维护Debian 8系统时,执行了apt-get update。执行完成后程序报出错误,错误内容如下: W: There is no public key available for the following key IDs: 这个 ...
  • 技术小絮
1,608 0
xosadmin
xosadmin
6 years ago
推荐 gem (Zlib::GzipFile::Error) not in gzip format 的解决方案
近日在使用老版本ruby安装sqlite3时,遇到了这样的一个错误,报错如下: ERROR: While executing gem … (Zlib::GzipFile::Error) not in gzip format ...
  • 技术小絮
1,222 0
xosadmin
xosadmin
4 years ago
推荐 vsftpd提示500 OOPS: vsftpd: refusing to run with writable root inside chroot()解决方法
问题:在安装完vsftpd后,尝试连接时,提示500 OOPS: vsftpd: refusing to run with writable root inside chroot() 解决此问题,只需要执行以下操作: 在/etc/vsft ...
  • 技术小絮
593 0
  • PVE Cluster给node更换corosync IP的方法
  • HPE Microserver系列降低噪音的一种办法
  • Debian 13 Trixie安装Proxmox VE
  • Windows FTP服务器通过PASV模式无法获取目录的解决方法
  • Proxmox日志出现大量lxcfs truncated错误的解决方案
  • Proxmox通过CLI向LXC挂载已有虚拟磁盘的方法

文章聚合

  • PVE Cluster给node更换corosync IP的方法
  • Debian 13 Trixie安装Proxmox VE
  • Proxmox日志出现大量lxcfs truncated错误的解决方案
  • Proxmox通过CLI向LXC挂载已有虚拟磁盘的方法
  • Proxmox VE通过全盘方式直通硬盘
  • Proxmox为KVM VNC启用剪贴板支持

Multilangual Translator

Copyright © 2016-2026 X-osadminの自留地. All rights reserved. 萌ICP备20258855号
  • 博客主页 HomePage
  • 技术小絮 Tech
  • 作品发布 Works
  • 软件专题 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