Heim  >  Artikel  >  Backend-Entwicklung  >  CentOs7 erstellt eine PHP-Umgebung

CentOs7 erstellt eine PHP-Umgebung

不言
不言Original
2018-04-14 14:14:1510254Durchsuche

Dieser Artikel stellt hauptsächlich CentOs7 vor, um eine PHP-Umgebung zu erstellen, die einen gewissen Referenzwert hat. Jetzt kann ich ihn mit allen teilen, die ihn brauchen.

Tipp: wget lädt die SSL-Verbindung herunter nicht festgestellt werden kann, fahren Sie fort. Folgen Sie der Anleitung unten


https://blog.csdn.net/xinghun_4/article/details/50500331

reboot 重启虚拟机
  1. Alle Kompilierungstools gcc mit einem Klick installieren

yum groupinstall "Development Tools" "Server Platform Development" -y
  1. Yum Epel-Quelle hinzufügen

wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -ivh epel-release-latest-7.noarch.rpmyum repolist      ##检查是否已添加至源列表
  1. Nginx installieren

yum -y install nginx   使用yum安装nginx
systemctl start nginx  启动nginx,浏览器输入ip就可以看到nginx的欢迎页

3.1 Nginx-Konfigurationsdatei ändern, um PHP-Parsing zu unterstützen

nginx配置文件默认放在/etc/nginx/nginx.confvi /etc/nginx/nginx.conf在server区间里加入以下内容
注释掉本来的这两行 
        # location / { 
        #  } 
 location / { 
        root   /usr/share/nginx/html; 
        index  index.php index.html index.htm; 
    } 
  location ~ \.php$ { 
         root           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; 
     } 
systemctl restart nginx 重启nginx
  1. PHP installieren

检查当前安装的PHP包
    yum list installed | grep php
如果有安装的PHP包,先删除他们
(这条命令看情况执行看清楚你安装的包用yum remove删除)
 yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_643

4.1 PHP-Yum-Quelle hinzufügen

Centos 5.Xrpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpmCentOs 6.x
  rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm

  CentOs 7.Xrpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm或者使用wget
wget https://mirror.webtatic.com/yum/el7/epel-release.rpmrpm -ivh epel-release.rpm

Wenn Sie das oben installierte Yum-Quellpaket löschen möchten, installieren Sie es neu

rpm -qa | grep webstatic
rpm -e  上面搜索到的包即可

4.2 Wählen Sie selbst aus, welche PHP-Version Sie installieren möchten

php5.6yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64

php5.5yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64

php7
    yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64

4.2 Installieren Sie PHP-FPM

5.5yum install php55w-fpm 
5.6yum install php56w-fpm 
7.0yum install php70w-fpm

Starten Sie php-fpm

systemctl start php-fpm

Konfigurieren Sie php.ini

vi /etc/php.ini 按下esc进入命令模式,输入:/cgi.fix_pathinfo,按n
进行下一个查找,找到指定cgi.fix_pathinfo, 修改为=0;
  1. Installieren Sie MySQL. Ich setze Mariadb nicht direkt auf MySQL

yum –y install mysql
yum –y install mysql-devel

添加官方mysql-server的yum源
 wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

Installationsquelle

 rpm -ivh mysql-community-release-el7-5.noarch.rpm 
安装mysql-server
 yum install mysql-community-server

MySQL starten

systemctl restart mysqld

Wenn eine Firewall vorhanden ist, öffnen Sie die Ports 80 und 3306

centos7用的是firewallfirewall-cmd --zone=public --add-port=80/tcp --permanentfirewall-cmd --zone=public --add-port=3306/tcp --permanent

Firewall neu laden

firewall-cmd --reload

Verwandt Empfehlungen:

Ubuntu-Methoden zum Aufbau einer PHP-Laufumgebung unter server_Linux

Sublime Text3 zum Aufbau einer PHP-Entwicklungsumgebung

Standardversion von Eclipse zum Aufbau einer PHP-Umgebung

Das obige ist der detaillierte Inhalt vonCentOs7 erstellt eine PHP-Umgebung. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:PHP-FPM-NeustartNächster Artikel:PHP-FPM-Neustart