php如何安装?

如何安装PHP环境?

LAMP/LNMP环境搭建

1.检查系统环境

1检查CentOS版本

[root@localhost~]#cat/etc/redhat-release

2已安装

rpm-qa|grephttpd

或:

apachectl-v

或:

httpd-v

3.确保Mysql服务已安装mysqldstart

如果无法识别则不安装

如果已安装或安装失败则清理系统

4个Mysql路径

yumremovemysql

rm-f/etc/my.cnf

5卸载Apache包

rpm-qa|grephttpd

注意:如果是新的系统或者您尝试安装如果您不知道上述内容您可以跳过步骤

2。
安装Apache、PHP、Mysql

停止防火墙服务

[root@localhost~]#systemctlstopfirewalld.service

禁用防火墙启动服务

[root@localhost~]#systemctldisablefirewalld.service

1.安装Apache

[root@localhost~]#yum-yinstallhttpd

2.root@localhost~#yum-yinstallphp

3安装php-fpm

[root@localhost~]#yum-yinstallphp-fpm

4.安装Mysqlyinstallmysql

5.安装mysql-server

[root@localhost~]#yuminstallmariadb-server

CentOS7+版本从默认程序列表中删除了MySQL数据库软件,大部分entos7安装教程安装mariadb因为CentOS7是默认的。
将Mariad视为mysql。

因为原作者担心MySQL被Oracle收购后MySQL会被关闭,所以这个数据库可以作为MySQL的一个分支。
如果你想安装mariadb,只需使用yum即可。

1.安装Apache扩展包

yum-yinstallhttpd-manualmod_sslmod_perlmod_auth_mysql

2.安装PHP扩展包

yum-yinstallphp-gdphp-xmlphp-mbstringphp-ldapphp-pearphp-xmlrpcphp-devel

3安装Mysql扩展包

yum-yinstallmysql-connector-odbcmysql-devellibdbi-dbd-mysql

4.配置Apache和mysql启动

systemctlstarthttpd.service#startapache

systemctlstophttpd.service#停止apache

systemctlrestarthttpd.service#重新启动apache

systemctlenablehttpd.service#启动apache设置为启动于

重新启动数据库

#StartMariaDB

[root@localhost~]#systemctlstartmariadb。
服务

#stopmariadb

[root@localhost~]#systemctlstopmariadb.service

#restartmariadb

[root@localhost~#systemctlrestartmariadb.service

#setboot

[root@localhost~]#systemctlenablemariadb.service

5.配置Mysql

第一次安装mysql时,没有密码,mysql默认账户为root

方法一:MySQL数据库root账户:

[root@localhost~]#mysql_secure_instalation

出现以下提示时直接按Enter:

输入root的当前密码

出现提示时再次按Enter:

启动密码?[Y/n]

会出现以下提示。
在此输入您需要设置的密码。
再确认四项:

删除匿名用户?[Y/n]

远程登录sallowroot?[Y/n]

删除数据库和访问权限?

方法二:输入mysqlmysql-r

更改mysql密码:setpasswordfor'root'@'localhost'=password('root');

mysql授权远程连接(navicat等):Grantallon*.*torootidentifiedby'root';

6.检查环境

我们在浏览器地址栏输入,会正常出现,这就说明我们的光照环境已经搭建成功了

7.安装nginx

yuminstallyum-priorities-y

wget

rpm-ivhnginx-release-centos-7-0.el7.ngx.noarch.rpm

yuminstallnginx

Nginx版本号可能会更改

8.配置nginx

1启动、停止和重新启动nginx

systemctlstartnginx.service#startnginx

systemctlstopnginx.service#stop

systemctlrestartnginx。
service#restart

systemctlenablenginx.service#setstart

更改nginx端口号(根据您的需要)

cd/etc/nginx/conf.d/

vimdefault.conf

保存列表开关en80到listen81

3登录后可以看到nginx主页

安装完成后,应该启动php-fpm,会出现下载文件,重启命令如下

systemctlstartphp-fpm.service#start。
启用php-fpm

systemctlenablephp-fpm.service#setstart

4php

vi/etc/nginx/conf修改nginx配置文件指定d/default.conf,替换前面的#只需将其删除并简单替换

location~.php${

roothtml;

fastcgi_pass127.0.0.1:9000;

fastcgi_indexindex.php;

fastcgi_paramSCRIPT_FILENAME/usr/share/nginx/html/$fastcgi_script_name;

fastcgi_paramsopens;

}

方法2.安装nginx

yuminstallnginx

启动nginx并配置开机启动

systemctlstartnginx

systemctlenablenginx

vim/etc/nginx/conf.d/default.conf

5.在/usr/share/nginx/html中新建test.php

登录后即可看到PHP页面。

编辑配置后记得启动apache和php-fpm!九。
安装配置

top{

server172.16.170.138;

server172.16.170.139;

}

服务器{

listen80;

server_namelocalhost;

#charsetkoi8-r;

>

#access_log/var/log/nginx/log/host.access.logmain;

位置/{

root/usr/share/nginx/html;

indexindex.htmlindex.htm;

proxy_pass;

apa默认目录/var/www/html

nginx默认目录/usr/share/nginx/html

更新PHP版本

centos7中默认安装的php是5.4

要安装的PHP版本查看版本列表yum

yumprovidesphp

开始升级PHP更新源:

rpm-Uvh

rpm-Uvh

yumremovephp-common-y#删除系统自带的php-common

php72版本

yuminstall-yphp72wphp72w-opcachephp72w-xmlphp72w-mcryptphp72w-gdphp72w-develphp72w-mysqlphp72w-intlphp72w-mbstring

php56版本

检查php版本

php-v

phpfpm安装:

yuminstallphp72w-fpm

yumprovidesphp-fpm#在设置时构建lnmp,所以安装php-fpm,仅选择5.6,许多安装源都安装。

yuminstallphp56w-fpm-5.6.31-1.w7.x86_64-y

systemctlstartphp-fpm.service【启动】

systemctlenablephp-fpm.service【自动启动】

CentOSyum有时解决方案出现“Couldnottretrievemirrorlist”-配置resolv.conf

原因:resolv.conf未配置

解决方案:

要配置resolv.conf,请转到/etc目录并添加nameserverIP,例如:

nameserver8。
8.8.8

nameserver8.8.4.4

searchlocaldomain

保存上面的命令并再次运行。

nginx目录:/usr/share/nginx/html

/etc/nginx/conf.d/default.confnginx配置目录

apache目录:/var/www/html

/etc/httpd/conf/httpd.confapache配置文件

nginx配置域名

cd/etc/nginx

cpdefault.confimooc.conf

更改server_nameimooc.test.com和项目目录

虚拟域名配置Windows访问需要在主机中添加linuxip。

服务器名称

DocumentRoot"/var/www/html/learnlaravel/public"

选项索引符号链接跟随

全部允许覆盖

所有必需的

禁用防火墙

setenforce0

服务器上的php如编程如何安装

您好,如果您的服务器是Windows系统,那么您需要远程到您的服务器启动IIS(asp环境)如果您想要PHP环境,您可以从xp.cn(小皮)或bt.cn(宝塔)。
/p>

如果你的服务器是Linux,建议使用宝塔。
输入:yuminstall-ywgetwget-Oinstall.shshinstall.sh

Ubuntu/Deepin安装脚本

终端输入:wget-Oinstall.shsudobashinstall.sh

Debian安装脚本

终端输入:wget-Oinstall.shbashinstall.sh

Fedora安装程序脚本

终端输入wget-Oinstall.shbashinstall.sh

输入即可安装

如何安装PHP模块

如何安装PHP模块

1

首先安装安装php之前需要安装的程序,例如ftp、mhash、mcrypt...安装完成后,解压php安装包并./configure

--with-ftp

--with-mhash

--with-mcrypt等等。
以下特殊参数由它们可以在./configure

--help中找到。
编译完成后,执行

mek

install

即可。

2像PEAR这样的东西,如果不想重新加载php,可以使用phpize来动态加载需要加载的模块。

具体实现方法如下(这里以忘记安装pdo_mysql模块为例)

cd

/root/source/php-5.3.10/ext/pdo_mysql

/usr/local/php/bin/phpize

/root/source/mysql-5.5.21安装mysql后运行phpize不输入目录,而是输入扩展模块的文件目录添加到php源文件中——即/root/source/php-5.3.10/ext/pdo_mysql目录将运行phpize。
如果不这样做,会提示如下错误:

Couldnot

find

config.m4.

Do

当然

运行

'/usr/local/php/bin/phpize'

顶层

级别

目录

模块

网上一些自以为是的人认为我应该鄙视上面的错误,因为源代码很混乱,具有误导性。
它从不遵循PHP官方文档。

目录/root/source/php-5.3.10/ext/pdo_mysql

运行phpize命令之前没有配置文件,只有config.m4文件。
运行phpize将生成一个可执行的配置文件。
此时可以编译如下:

./configure

--with-php-config=/usr/bin/php-config

(也可以通过./configure

--hel通过pView添加一些其他参数)

Install

编译完成后会提示你安装Extension。
生成模块/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626目录。

更改php.ini文件

vi

/usr/local/php/etc/php.ini

最后其文件添加以下内容:-

extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"

extension=pdo_mysql.so

安装完成后,重启php-fpm和web服务器。
(我使用的是php-fpm和tenengine,所以如果我使用的是apache,我将重新启动相关程序并重新安装)

php下载安装教程(php安装包下载)

在linuxyum上安装php7.3

先安装上一个教程,再安装下面一个

参考教程1:

参考教程2:

安装PHP

1.安装PHP73

1.1。
卸载旧版本的PHP

yumremovephp*

1.2。
安装EPEL:

sudoyuminstallepel-release

1.3。
安装remi(选择一项):

sudorpm-Uvh

rpm-Uvh

1.4。
检查当前可用的PHP版本(可以忽略)

sudoyumlistphp*

1.5。
列出所有PHP相关的rpm包(可以忽略)

rpm-qa|grepphp

1.6.删除PHP相关rpm包(一次只能删除一个)(可忽略)

rpm-ephp72w-mysqlnd-7.2.17-1.w7.x86_64

1.7,列出了remi仓库中所有PHP7.3可用的模块。
(可忽略)

yum--enablerepo=remi-php73searchphp|grepphp73

1.8,安装PHP7.3

yum--enablerepo=remi-php73installphp

1.安装PHP7.3:

(解决yum安装apache无法关联PHP的问题,使用如下命令安装)

yum--enablerepo=remi-php73installphp

安装模块

yum--enablerepo=remi-php73installphp73-php-fpmphp73-php-cliphp73-php-bcmathphp73-php-gdphp73-php-jsonphp73-php-mbstringphp73-php-mcryptphp73-php-mysqlndphp73-php-opcachephp73-php-pdophp73-php-pecl-cryptophp73-php-pecl-mcryptphp73-php-pecl-geoipphp73-php-recodephp73-php-snmpphp73-php-soapphp73-php-xml

2.设置启动并运行服务:

systemctlenablephp73-php-fpm

systemctlstartphp73-php-fpm

3.查找php.ini的位置:

find/etc/opt/remi/php73-namephp.ini

/etc/opt/remi/php73/php.ini

找到apache配置文件:httpd.conf

sudofind/-namehttpd.conf

位置如下:

/etc/httpd/conf/httpd.conf

5.PHP日常操作

systemctlrestartphp73-php-fpm#重启

systemctlstartphp73-php-fpm#开始

systemctlstopphp73-php-fpm#关闭

systemctlstatusphp73-php-fpm#查看状态

php-m#查看PHP已安装扩展module

php-v#查看PHP版本

Mysql下载安装和PHP下载安装问题。
这几天一直在网上寻找有关MYSQL的教程。
但无论我怎么看,都不起作用。
希望专家能远程教我。

我已经配置过很次了。
一般来说按照这个顺序配置是没有问题的。
不用担心。
只要小心一点,您就可以在15分钟内完成配置。
如果您有任何疑问,请给我留言。

第一:Apache安装配置(版本:apache_2.2.6-win32-x86-no_ssl)

默认直接安装。
安装过程中,请关闭浏览器并下载软件,否则安装完成后,服务器无法启动,并报无法绑定80端口的错误。
启动后,在地址栏中输入“”或“”。
如果看到“ItWorks”,则说明安装成功。

如果需要更改默认路径,打开“C:\ProgramFiles\ApacheSoftwareFoundation\Apache2.2\conf”目录下的httpd.conf文件,搜索“DocumentRoot(有两处是这里一定要改,一个不从这个开始),将path改为需要设置的访问路径,这里改为“D:/masterphp”(注意斜线的方向,与路径不同)方向)

第二:PHP安装配置(版本:php-5.2.5-Win32)

下载后直接解压即可,这里我们解压到“C:\ProgramFiles\php-5.2”下。
.5-Win32”目录。
接下来连接PHP和Apache服务:

(1)修改“C:\ProgramFiles\php-5.2.5-Win32”目录,将“php.ini-recommened”文件名改为“php.ini”

(2)将“php.ini”文件复制到Apache目录下,即“C:\ProgramFiles\ApacheSoftware\Foundation\Apache2.2”目录

(3)打开php.ini文件并修改以下关键字

查询extension_dir="./"并修改为

extensionion_dir="C:\ProgramFiles\php-5.2.5-Win32\ext"

如果显示中文时出现乱码,可以查询;default_charset="iso-8859-1"改为default_charset="gbk",注意去掉前面的“;”

很多时候,需要使用session对象来存储数据,比如session认证、购物车设计等,所以必须找到另外一个属性,也就是说

;session.s改为ave_path="/tmp"到

session.save_path="C:/ProgramFiles/php-5.2.5-Win32/session"

(session文件夹需要手动创建,确定创建其他目录)

查找display_errors和cgi.force_redirect,原来的设置是

display_errors=off

;cgi.force_redirect=1

修改为

display_errors=ON

cgi.force_redirect=0

(display_errors属性表示出现错误时是否显示错误信息而cgi.force_redirect为0则表示强制不以CGI模式运行)

重复复制下的php5ts.dll文件将“C:/ProgramFiles/php-5.2.5-Win32”复制到系统的windows/system32(Windows:\ProgramFiles\ApacheSoftwareFoundation\Apache2.2\modules)中,然后在末尾插入以下代码httpd.conf文件

LoadModulephp5_modulemodules/php5apache2_2.dll

AddTypeapplication/x-httpd-php.php

如果你还想让Apache执行其他后缀名,可以添加其他类型,如下

AddTypeapplication/x-httpd-php.php4

AddTypeapplication/x-httpd-php.php3

AddTypeapplication/x-httpd-php.phtml

AddTypeapplication/x-httpd-php-souce.phps

默认Apache的连接文件名为“index.html”,即在地址栏输入“”和“”,结果是一样的。
要添加其他默认连接文件名,请在httpd.conf中查找“DirectoryIndex”。
原来的设置如下:

DirectoryIndexindex.htmlindex.html.var

如果要支持default.php,改成如下格式:

DirectoryIndexdefault.phpindex.htmlindex.html.var

为了测试PHP配置是否成功,打开记事本,输入以下代码:

?php

phpinfo()

将代码保存为version.php,复制到“d:\master.php”目录下,在地址栏输入“”,如果一切正常配置正常,可以看到PHP的各种信息

第三:MySQL安装配置(版本:mysql-5.0.45-win32)

选择完整安装,点击下一步,有要设置的密码。

启动后如果出现mysql标志则表示安装成功。

MySQL安装成功后,仍然需要连接PHP,所以需要进一步配置。

打开“C:\ProgramFiles\ApacheSoftware\Foundation\Apache2.2”目录下的php.ini文件,搜索“MySQL”,修改以下属性

原始设置为:

mysql.default_port=

mysql.default_host=

mysql.defailure_user=

mysql.default_password=

修改为:

mysql.default_port=3306(网络端口,安装时默认设置为3306)

mysql.default_host=localhost(default_host为服务期名称,localhost代表本机)

mysql.default_user=root(default_user代表用户名,root为默认用户name)

mysql.default_password=123456(即安装MySQL时输入的密码)

修改上述属性后,还需要启动MySQL的PHP​​支持模块并在php.ini文件中搜索“extension=ph”。
p_mysql.dll”

原设置为:

;extension=php_mysql.dll

修改为

extension=php_mysql。
dll(即去掉分号)

复制php_mysql.dll(php)和libmysql.dll(php)文件到c:\winnt\system32。

最后测试MySQL是否安装成功。
测试代码如下:

?php

$link=mysql_connect('localhost','root','123456');

if(!$link)echo"失败!";

elseecho"成功!";

mysql_close();

?

在地址栏输入“”,如果连接成功成功了,“成功!”

最后将phpmyadmin解压到网站中,直接回车即可进入。

如何安装PHP环境?

LAMP/LNMP环境搭建

1.检查系统环境

1.确认centos版本

[root@localhost~]#cat/etc/redhat-release

2.检查apache是​​否已安装

rpm-qa|grephttpd

或者:

apachectl-v

或者:

httpd-v

3.检查Mysql是否已经安装

servicemysqldstart

如果不能识别,说明没有安装

如果系统已经安装,或者安装失败,清洁系统

4.清理Mysql痕迹

yumremovemysql

rm-f/etc/my.cnf

5.卸载Apache包

rpm-qa|grephttpd

注意:如果是新系统或者从未尝试安装过,以上步骤可省略

2。
安装Apache、PHP、Mysql

停止防火墙服务

[root@localhost~]#systemctlstopfirewalld.service

禁用防火墙启动服务

[root@localhost~]#systemctldisablefirewalld.service

1.安装apache

[root@localhost~]#yum-yinstallhttpd

2.安装php

[root@localhost~]#yum-yinstallphp

3.安装安装php-fpm

[root@localhost~]#yum-yinstallphp-fpm

4.安装Mysql

[root@localhost~]#yum-yinstallmysql

5.安装mysql-server

[root@localhost~]#yuminstallmariadb-server

CentOS7+版本将MySQL数据库软件从默认程序列表中删除,替换为mariadb。
在entos7的配置教程中,大部分都是安装mariadb,因为centos7默认就是它。
将mariadb视为mysql。

因为MySQL被Oracle收购后,原作者担心MySQL会闭源,所以又写了一个mariadb。
这个数据库可以理解为MySQL的一个分支。
如果需要安装mariadb,使用yum即可。

6.安装php-mysql

[root@localhost~]#yum-yinstallphp-mysql

3.安装基本常用扩展包

1.安装Apache扩展包

yum-yinstallhttpd-manualmod_sslmod_perlmod_auth_mysql

2.安装PHP扩展包

yum-yinstallphp-gdphp-xmlphp-mbstringphp-ldapphp-pearphp-xmlrpcphp-devel

3.安装Mysql扩展包

yum-yinstallmysql-connector-odbcmysql-devellibdbi-dbd-mysql

4.配置Apache和mysql启动

重启Apache和mysql服务(注意这个和centos6不同,Cenots7+不能使用6方法)

systemctlstarthttpd.service#启动apache

systemctlstophttpd.service#停止apache

systemctlrestarthttpd.service#重启apache

systemctlenablehttpd.service#设置apache开机启动

重启数据库

#启动MariaDB

[root@localhost~]#systemctlstartmariadb。
服务

#停止MariaDB

[root@localhost~]#systemctlstopmariadb.service

#重新启动MariaDB

[root@localhost~]#systemctlrestartmariadb.service

#设置开机启动

[root@localhost~]#systemctlenablemariadb.service

5.配置Mysql

第一次安装mysql时没有密码。
我们需要设置一个密码。
mysql默认账户为root

方法一:设置MySQL数据根账户密码:

[root@localhost~]#mysql_secure_installation

出现以下提示时直接按回车:

Entercurrentpasswordforroot

出现以下提示时再次按回车:

Setrootpassword?[Y/n]

出现以下提示。
输入您需要设置的密码。
这里输入root。
您输入的密码将不会显示。
按Enter并再次输入确认:

新密码:

还会有四个确认,它们是:

删除匿名用户?[Y/n]

迪远程登录?[Y/n]

删除测试数据库并访问它?[Y/n]

现在重新加载权限?[Y/n]

只需按Enter键。

方法二:输入mysqlmysql-r

修改mysql密码:setpasswordfor'root'@'localhost'=password('root');

mysql授权远程连接(navicat等):grantallon*.*torootidentifiedby'root';

6.测试环境

我们在浏览器地址栏输入,正常显示,说明我们的lamp环境搭建成功

7.安装nginx

yuminstallyum-priorities-y

wget

rpm-ivhnginx-release-centos-7-0.el7.ngx.noarch.rpm

yuminstallnginx

Nginx版本号可以更改

8.配置nginx

1.nginx启动、停止、重

systemctlstartnginx.service#启动nginx

systemctlstopnginx.service#Stop

systemctlrestartnginx.service#restart

systemctlenablenginx.service#setstartup

更改nginx端口号(根据自己的需要)

cd/etc/nginx/conf.d/

vimdefault.conf

将listen80改为listen81

3.访问就会看到nginx主页

安装完成后,需要启动php-fpm才能访问。
如果不重新启动访问,就会出现下载文件。
重启命令如下

systemctlstartphp-fpm.service#启动php-fpm

systemctlenablephp-fpm.service#设置启动

4.更改nginx配置文件识别php

vi/etc/nginx/conf.d/default.conf,并给出前面的#去掉即可轻松更改

位置~.php${

roothtml;

fastcgi_pass127.0.0.1:9000;

fastcgi_indexindex.php;

fastcgi_paramSCRIPT_FILENAME/usr/share/nginx/html/$fastcgi_script_name;

includefastcgi_params;

}

方法2安装nginx

yuminstallnginx

启动nginx并设置启动为开机

systemctlstartnginx

systemctlenablenginx

vim/etc/nginx/conf.d/default.conf

5.在/usr/share/nginx/html中新建test.php

访问就会看到php页面

修改配置后记得启动apache和php-fpm!九。
加载配置

上游站点{

server172.16.170.138;

server172.16.170.139;

}

服务器{

listen80;

服务器名称本地主机;

#charsetkoi8-r;

#access_log/var/log/nginx/log/host.access.logmain;

位置/{

root/usr/share/nginx/html;

indexindex.htmlindex.htm;

proxy_pass;

}

阿帕奇默认目录/var/www/html

nginx默认目录/usr/share/nginx/html

升级pHP版本

centos7中默认安装PHP是5.4

查看yum可安装的PHP版本列表

yumprovidesphp

开始升级PHP更新源码:

rpm-Uvh

rpm-Uvh

yumremovephp-common-y#删除系统自带的php-common

php72版本

yuminstall-yphp72wphp72w-opcachephp72w-xmlphp72w-mcryptphp72w-gdphp72w-develphp72w-mysqlphp72w-intlphp72w-mbstring

php56version

yuminstall-yphp56wphp56w-opcachephp56w-xmlphp56w-mcryptphp56w-gdphp56w-develphp56w-mysqlphp56w-intlphp56w-mbstring#安装依赖包

查看php版本

php-v

安装phpfpm:

yuminstallphp72w-fpm

yumprovidesphp-fpm#因为我准备搭建lnmp,所以在安装php-fpm时,这里会提示多个安装源。
选择5.6版本安装即可

yuminstallphp56w-fpm-5.6.31-1.w7.x86_64-y

systemctlstartphp-fpm.service【启动】

系统