phpstorm使用*

1、win10环境搭建

a.配置composer命令行环境

下载php和composer、配置环境变量,方便使用composer环境:
编写composer.bat

@php "%~dp0composer.phar" config -g repo.packagist composer https://mirrors.aliyun.com/composer/

b.vagrant安装环境

初始化homestead环境

迅雷下载
https://vagrantcloud.com/laravel/boxes/homestead/versions/10.0.0/providers/virtualbox.box

vagrant box add --name homestead/10.0 homestead_virtualbox.box

进入安装目录:D:WorkPlacewwwroot
创建 Vagrantfile 文件:

vagrant box list #检查

Vagrant.configure("2") do |config|
  config.vm.box = "homestead/10.0"
  config.vm.hostname = "homestead"
  config.vm.network "forwarded_port", guest: 80, host: 80, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1"
  config.ssh.password = "123456"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "2048"
    vb.cpus = 4
  end
end

切换根目录到为当前根目录,使用PHPstorm启动虚拟机

vagrant up

c.nginx和网络工具

#添加配置文件
sudo vim /etc/nginx/conf.d/nginx.conf
#限速
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=100r/s;
server {
        listen       80;
        server_name  local.com;

        location / {
            root   /vagrant;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            limit_req zone=mylimit burst=1000 nodelay;
            root            /vagrant;
            fastcgi_index   index.php;
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_param   SCRIPT_FILENAME  /$document_root$fastcgi_script_name;
            # --php-fpm 的工作目录
            #fastcgi_param   SCRIPT_FILENAME   /vagrant$fstcgi_script_name;
            include         fastcgi_params;
        }
}

安装net-tools

sudo apt-get install net-tools util-linux -y
sudo nginx -s reload
netstat -lunpt

测试访问 http://127.0.0.1:8080/ ,可以看到Nginx页面。

2、框架部署

a.在命令行启动laravel

使用文档

mkdir /vagrant/framework && cd /vagrant/framework
composer create-project --prefer-dist laravel/laravel && cd laravel

修改初始密码:

DB_USERNAME=homestead
DB_PASSWORD=secret

启动测试

#注意启动host是0.0.0.0,监听所有
php artisan serve --host=0.0.0.0 --port=8080 &
sudo netstat -lunpt|grep 8080
#kill -9 4085 

测试访问 http://127.0.0.1:8080/ ,OK。

b.使用fpm访问静态PHP文件

#查看 vim /etc/php/7.4/fpm/pool.d/www.conf 转发监听情况
fastcgi_pass    127.0.0.1:9000;
==> fastcgi_pass    unix:/run/php/php7.4-fpm.sock;
ps -ef|grep php #sudo kill -9
sudo /usr/sbin/php-fpm7.4

测试访问 http://127.0.0.1:8080/index.php ,OK。

c.hyperf安装

vagrant ssh
cd vagrant #[默认映射目录]
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
composer create-project hyperf/hyperf-skeleton -v
按照提示
 sudo pecl channel-update pecl.php.net

swoole以及openssl扩展的安装

cd /opt
sudo wget https://www.php.net/distributions/php-7.4.8.tar.xz
sudo tar -Jxf php-7.4.8.tar.xz

cd php-7.4.8/ext/openssl
==> sudo cp config0.m4 config.m4
sudo ./configure --with-openssl --with-php-config=/usr/bin/php-config
==> sudo apt-get install pkg-config
sudo make && make install

sudo pecl install swoole
sudo vim /etc/php/7.4/cli/php.ini
启用openssl,swoole扩展,swoole.use_shortname=0

你可能感兴趣的:(composer)