溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

centos7中yum如何安裝php

發(fā)布時(shí)間:2020-10-09 16:51:13 來(lái)源:億速云 閱讀:154 作者:小新 欄目:編程語(yǔ)言

這篇文章將為大家詳細(xì)講解有關(guān)centos7中yum如何安裝php,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

centos7 yum安裝php的方法:首先安裝nginx以及MYSQL;然后通過(guò)命令“yum install php71w php71w-fpm php71w-cli php71w-common...”安裝php以及擴(kuò)展即可。

centos7 yum快速安裝php7.1

1. 安裝nginx

yum install nginx
##開(kāi)啟nginx
service nginx start

2.安裝MYSQL

yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum install mysql-community-server
//開(kāi)啟mysql
service mysqld start
//查看mysql的root賬號(hào)的密碼
grep 'temporary password' /var/log/mysqld.log
//登錄mysql
mysql -uroot -p
//修改密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
//修改root用戶(hù)可遠(yuǎn)程登錄
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
//刷新
flush privileges;

3.安裝php

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
//查看
yum search php71w
//安裝php以及擴(kuò)展
yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath
//開(kāi)啟服務(wù)
service php-fpm start
//修改/etc/nginx/nginx.conf 使其支持php 見(jiàn)下
//重啟nginx
service nginx restart
---------------------配置
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
server_name localhost;
root /var/www/;
index index.php;
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
try_files $uri =404;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/?.*)$;
fastcgi_param SCRIPT_FILENAME
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
}
error_page 404 /404.html;
location ~ /\.(ht|svn|git) {
deny all;
}
}

4.安裝redis

yum install redis
//修改配置 
vi /etc/redis.conf
//daemonize yes 后臺(tái)運(yùn)行
//appendonly yes 數(shù)據(jù)持久化
service redis start

5.安裝php-redis擴(kuò)展

//先裝git
yum install git
//git下擴(kuò)展
cd /usr/local/src
git clone https://github.com/phpredis/phpredis.git
//安裝擴(kuò)展
cd phpredis
phpize
//修改php配置
vi /etc/php.ini 添加extension=redis.so
//重啟php
service php-fpm restart

關(guān)于centos7中yum如何安裝php就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI