执行命令
cat /etc/centos-release
执行结果
# CentOS Linux release 8.0.1905 (Core)
首先,通过运行以下dnf命令在CentOS 8 Linux上更新存储库和软件包。
sudo dnf update -v
dnf install curl wget epel-release vim git unzip socat bash-completion
dnf install nginx
查看nginx版本
nginx -v
运行结果
nginx version: nginx/1.14.1
sudo systemctl enable nginx
sudo systemctl start nginx
通过执行命令来验证Nginx是否正在运行
sudo systemctl status nginx
启动命令
systemctl reload nginx.service
sudo dnf install https://dl.Fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module list php
输出将包括可用的PHP模块,流和安装配置文件,如下所示。
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository epel is listed more than once in the configuration
Remi's Modular repository for Enterprise Linux 8 - x86_64 53 kB/s | 691 kB 00:13
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 121 kB/s | 1.6 MB 00:13
Last metadata expiration check: 0:00:09 ago on Wed 04 Nov 2020 06:24:35 PM CST.
CentOS-8 - AppStream
Name Stream Profiles Summary
php 7.2 [d] common [d], devel, minimal PHP scripting language
php 7.3 common [d], devel, minimal PHP scripting language
Remi's Modular repository for Enterprise Linux 8 - x86_64
Name Stream Profiles Summary
php remi-7.2 common [d], devel, minimal PHP scripting language
php remi-7.3 common [d], devel, minimal PHP scripting language
php remi-7.4 common [d], devel, minimal PHP scripting language
php remi-8.0 common [d], devel, minimal PHP scripting language
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
sudo dnf module reset php
sudo dnf module enable php:remi-7.4
sudo dnf install php php-opcache php-gd php-curl php-mysqlnd php-cli php-common php-mbstring php-zip php-sqlite3 php-xml php-intl php-mysql
要显示在模块中编译的PHP,您可以运行:
php -m
运行结果
hash
iconv
intl
json
libxml
mbstring
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
SimpleXML
sockets
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
检查PHP版本:
php --version
运行结果
PHP 7.4.12 (cli) (built: Oct 27 2020 15:01:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.12, Copyright (c), by Zend Technologies
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
要检查其状态,请执行命令。
sudo systemctl status php-fpm
另一件事是,默认情况下,PHP-FPM配置为以Apache用户身份运行。 但是由于我们正在运行Nginx Web服务器,因此我们需要将其更改为Nginx用户。
因此,打开文件/etc/php-fpm.d/www.conf。
找到这两行。
user = apache
group = apache
现在将两个值都更改为Nginx。
user = nginx
group = nginx
保存并退出配置文件,然后重新启动Nginx和PHP-FPM,以使更改生效。
sudo systemctl restart nginx
sudo systemctl restart php-fpm
wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm
dnf localinstall mysql80-community-release-el8-1.noarch.rpm
dnf install mysql-server
查看mysql是否安装成功
ps -ef | grep mysql
mysqladmin --version
systemctl start mysqld
systemctl enable mysqld
systemctl daemon-reload
查看mysql 状态,以及启动命令
service mysqld status
service mysqld start
mysql安装完成之后,在/var/log/mysqld.log(/var/log/mysql/mysqld.log)文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
vim /var/log/mysql/mysqld.log
密码是上一步查询出来的。输入后回车。 登录 更改密码
mysql -uroot -p
然后输入命令
flush privileges;
进入mysql数据库
use mysql;
然后修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'TestBicon@123';
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer config -g repo.packagist composer https://packagist.phpcomposer.com
配置文件参考:https://www.yiichina.com/doc/guide/2.0/start-installation
ngigx 配置解析php 502
注意查看nginx和php的连接方式,两种连接方式要保持一致
因为nginx和php有两种链接方式,一种是
fastcgi_pass 127.0.0.1:9000;
另一种是这个 fastcgi_pass unix:/run/php/php7.0-fpm.sock;
这个具体怎么用要去php fpm里面去看他的配置文件 里面的Listen
vim /etc/php-fpm.d/www.conf
如果Listen是端口就写127.0.0.1:9000;
如果是路径,nginx的配置文件也要学路径,unix:/run/php-fpm/www.sock; 修改完重启ngixn,访问即正常 ngigx 配置解析php 502 参考网站:https://www.cnblogs.com/xbxxf/p/9132163.html