首頁 > 後端開發 > PHP問題 > centos7 yum安裝 php的方法

centos7 yum安裝 php的方法

藏色散人
發布: 2023-03-06 13:06:02
原創
2428 人瀏覽過
centos7 yum安装php的方法:首先安装nginx以及MYSQL;然后通过命令“yum install php71w php71w-fpm php71w-cli php71w-common...”安装php以及扩展即可。

centos7 yum安裝 php的方法

推荐:《php视频教程

centos7 yum快速安装php7.1

1. 安装nginx

yum install nginx
##开启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
//开启mysql
service mysqld start
//查看mysql的root账号的密码
grep 'temporary password' /var/log/mysqld.log
//登录mysql
mysql -uroot -p
//修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
//修改root用户可远程登录
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以及扩展
yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath
//开启服务
service php-fpm start
//修改/etc/nginx/nginx.conf 使其支持php 见下
//重启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 后台运行
//appendonly yes 数据持久化
service redis start
登入後複製

5.安装php-redis扩展

//先装git
yum install git
//git下扩展
cd /usr/local/src
git clone https://github.com/phpredis/phpredis.git
//安装扩展
cd phpredis
phpize
//修改php配置
vi /etc/php.ini 添加extension=redis.so
//重启php
service php-fpm restart
登入後複製

以上是centos7 yum安裝 php的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板