PHP安装配置(Windows和Linux) 您所在的位置:网站首页 windows7下载好了怎么安装 PHP安装配置(Windows和Linux)

PHP安装配置(Windows和Linux)

2024-03-21 00:28| 来源: 网络整理| 查看: 265

文章目录PHPWindows1.下载2.解压缩3.配置4.php.ini文件5.测试配置(此步可跳过)6.测试PHP代码Linux1.下载和解压2.安装3.php.ini4.配置Apache5.启动服务6.测试PHP

PHP即“超文本预处理器”,是一种通用开源脚本语言。PHP是在服务器端执行的脚本语言,与C语言类似,是常用的网站编程语言。PHP独特的语法混合了C、Java、Perl以及 PHP 自创的语法。利于学习,使用广泛,主要适用于Web开发领域。

原始为Personal Home Page的缩写,已经正式更名为 “PHP: Hypertext Preprocessor”

LAMP/LNMP 系列环境搭建:

学生党白嫖服务器-不会吧不会吧,你还在买学生机吗?

Apache安装配置(Windows和Linux)-有手就行

Linux安装配置MySql-你学废了吗?

PHP安装配置(Windows和Linux)-一篇就够了

Nginx安装配置(Window和Linux)-包教包会

我知道有集成软件和宝塔什么的,但我想一步步来,知其然知其所以然。

你都不知道我被折磨了好久,有些坑不踩一遍就像没来过一样。

Windows1.下载

官网下载地址https://windows.php.net/download

选择最新版下载

更多版本如不同VC和Thread Safe左侧导航有介绍。

2.解压缩

文件名可以改简洁点

3.配置

Apache安装配置可参考这里

#加载PHP LoadModule php7_module 'D:/tools/php7/php7apache2_4.dll' #将PHP配置文件加载到Apache配置文件中,共同生效 PHPIniDir 'D:/tools/php7' #配置Apache分配工作给PHP模块,把PHP代码交给PHP处理 #即.php后缀名的文件 AddType application/x-httpd-php .php4.php.ini文件

上述配置的php.ini文件默认是不存在的,是以development和production格式存在,需要格式化处理。

5.测试配置(此步可跳过)

重启Apache服务,打开cmd,切到 Apache解压目录/bin,输入指令

httpd -M6.测试PHP代码

至此就全部好了(~ ̄▽ ̄)~

Linux1.下载和解压cd /usr/local/src/ #切换目录 wget http://cn2.php.net/distributions/php-7.4.10.tar.bz2 #下载 wget http://xmlsoft.org/downloads.html/ tar jxvf php-7.4.10.tar.bz2 #解压2.安装cd /usr/local/src/php-7.4.10 ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=mysqlnd --with-mysqli --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --enable-fpm

执行configure时会报Error,说XXX not found等,对应安装即可,直到没错

Package ‘libxml-2.0’, required by ‘virtual:world’, not found yum install -y libxml2-develPackage ‘openssl’, required by ‘virtual:world’, not found yum install -y openssl openssl-develPackage ‘sqlite3’, required by ‘virtual:world’, not found yum install sqlite-develconfigure: error: Please reinstall the BZip2 distribution yum install -y bzip2 bzip2-develPackage ‘krb5’, required by ‘virtual:world’, not found yum install krb5-develPackage ‘libcurl’, required by ‘virtual:world’, not found yum install libcurl-develPackage ‘libjpeg’, required by ‘virtual:world’, not found yum install libjpeg-develPackage ‘libzip’, required by ‘virtual:world’, not found yum install libzip-develPackage ‘libxslt’, required by ‘virtual:world’, not found yum install libxslt-develPackage ‘freetype2’, required by ‘virtual:world’, not found yum install freetype-develPackage ‘libpng’, required by ‘virtual:world’, not found yum install libpng-develPackage ‘oniguruma’, required by ‘virtual:world’, not found(这个有点麻烦 )cd /usr/local/src/ wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz tar -zxvf oniguruma-6.9.4.tar.gz yum install autoconf automake libtool #有询问输入y cd oniguruma-6.9.4/ ./autogen.sh && ./configure --prefix=/usr make && make install3.php.ini

拷贝格式化php.ini,同Windows

cp php.ini-development php.ini /usr/local/php7/ #拷贝 cp php.ini /usr/local/php7/ /usr/local/php7/bin/php -m #查看PHP加载模块 /usr/local/apache2.4/bin/apachectl -M #查看httpd加载模块4.配置Apachevim /usr/local/apache2.4/conf/httpd.conf #编辑配置文件 #修改以下四点 #1.ServerName 195行 ServerName www.example.com:80 #2.Directory 204行 AllowOverride none Require all granted #3.DirectoryIndex 253行 DirectoryIndex index.html index.php #4.AddType 391行 AddType application/x-httpd-php .php :wq #保存退出(先按ESC) /usr/local/apache2.4/bin/apachectl -t #测试配置语法 /usr/local/apache2.4/bin/apachectl graceful #重新加载配置文件5.启动服务/usr/local/apache2.4/bin/apachectl start ps -ef|grep httpd #查看httpd进程 netstat -lntp|grep 80 #查看80端口 curl localhost #测试6.测试iptables -I INPUT -p tcp --dport 80 -j ACCEPT #开放80端口或配置服务器安全组 vim /usr/local/apache2.4/htdocs/test.php #编辑测试文件 :wq #保存退出(先按ESC)

按此步骤下来就能成功了。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有