温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

PHP环境搭建的示例分析

发布时间:2021-09-07 10:41:25 来源:亿速云 阅读:126 作者:小新 栏目:web开发

这篇文章给大家分享的是有关PHP环境搭建的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

Apache

     1. 下载地址:

         http://httpd.apache.org/

     2. 配置更改【所有 '\' 换成 '/'】:

          打开httpd.conf文件,更改apache的安装路径;

          更改项目文件路径;

          开启rewrite扩展;

     3. 添加与PHP的连接:       

LoadModule php5_module "C:/Wamp/php56/php5apache2_4.dll"            
AddHandler application/x-httpd-php .php
PHPIniDir "C:/Wamp/php56"

     4. 安装命令:

          cd到apache根目录,执行httpd.exe -k install -n "服务名"

     5. 卸载命令:

          停止apache服务,执行httpd.exe -k uninstall -n "服务名"

PHP

     1. 下载地址:

     http://php.net/downloads.php

     2. 配置更改:

     打开php.ini文件,在php扩展前添加:extension_dir = ext;

     按照需要打开php的扩展;

     3. 环境变量:

     计算机 > 属性 > 环境变量 > Path > php路径

MySQL

     1. 下载地址:

     https://dev.mysql.com/downloads/mysql/

     2. 配置更改:

     暂无

     3. 环境变量:

     计算机 > 属性 > 环境变量 > Path > MySQL路径

Memcache

     1. 下载地址:

     http://memcached.org/

     2. 配置更改:

     将php_memcache扩展复制到PHP的ext文件夹中

     在php.ini中添加php_memcache扩展

     3. 安装命令:

     cd到memcache的本目录,执行memcache.exe -d install

     4. 卸载命令:

     停止memcache服务,执行memcache.exe -d uninstall

Composer

     1. 下载地址:

     https://getcomposer.org/download/

     2. 配置更改:

     需要开启openssl扩展、PHP环境变量

     将composer.phar文件放到PHP根目录中;

     并先建一个bat文件:@php "%~dp0composer.phar" %*;

     执行composer --version查看当前版本;

     升级composer selfupdate;

     3. 修改当前项目使用国内composer镜像:

composer config repo.packagist composer  https://packagist.phpcomposer.com

     全局有效:   

composer config  -g repo.packagist composer https://packagist.phpcomposer.com

Nginx

     1. Web运行机制:

          用户 > 浏览器 > 域名 > DNS > IP > Nginx > php-fpm > xxx.php > html > 浏览器显示出来

     2. Nginx配置文件

          /usr/local/nginx/conf/nginx.conf

          用户:root

          目录:/home/wwwroot/;

     3. Php-fpm 配置文件

          /usr/local/php/etc/php-fpm.conf

          user = www

          所以要对www用户授权

          chmod -R 777 /home/wwwroot

          setfacl -R -m u:www:rwx runtime

          setfacl -R -m d:u:www:rwx runtime

     3. Nginx配置

# ...
     server{
          # ...
          root /home/wwwroot/project/web/;
          location / {
               index index.html index.php;
               try_files $uri @rewrite;
          }
          location @rewrite {
               rewrite ^/(.*)$ /index.php/$1 last;
          }
          location ~ \.php(/|$) {
               fastcgi_pass 127.0.0.1:9000;
               fastcgi_split_path_info ^(.+\.php)(.*)$;
               fastcgi_param PATH_INFO $fastcgi_path_info;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               include fastcgi_params;
          }
     }

     4. Nginx重新加载配置文件:

          /usr/local/nginx/sbin/nginx -s reload

感谢各位的阅读!关于“PHP环境搭建的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php
AI