lyd2004888 发表于 2018-12-14 09:31:46

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 composerhttps://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
  




页: [1]
查看完整版本: PHP的环境搭建(非集成)