1.laravel7をインストールします
1.Composerがlaravel7環境をプルします
cd /usr/local/nginx/html/
composer create-project --prefer-dist laravel/laravel blog "7.*"
2. nginxユーザーのアクセス許可をlaravelディレクトリに設定します。sshスクリプトをsvnフックに追加して、nginxユーザーのhtmlディレクトリへのアクセス許可を更新することで、送信されたファイルとコードを更新できます。
setfacl -m u:nginx:rwx -R /usr/local/nginx/html/
setfacl -m d:u:nginx:rwx -R /usr/local/nginx/html/
laravel7をインストールした後の実行の問題を解決します
問題:
Fatal error: require(): Failed opening required '/usr/local/nginx/html/laravel/public/../vendor/autoload.php' (include_path='.:') in /usr/local/nginx/html/laravel/public/index.php on line 24
解決策:
リファレンス:
https ://www.cnblogs.com/sgzn/p/12148396.html
-
参照のルートディレクトリにcdし、最初にcomposer.lockファイルを削除します。
-
ルートディレクトリで「composerinstall」を再実行して、composer.lockファイルを再生成できるようにします。
-
PHPのバージョンが一致しない場合は、「composer install --ignore-platform-reqs」(バージョンの一致を無視)を使用できます。
2. swooletw / laravel-swooleエクステンションをインストールします
cd /usr/local/nginx/html/laravel/
composer require swooletw/laravel-swoole
# 导出配置
php artisan vendor:publish --provider="SwooleTW\Http\LaravelServiceProvider"
#swoole命令
cd /usr/local/nginx/html/laravel/
php artisan swoole:http start #开启
php artisan swoole:http stop #关闭
php artisan swoole:http reload #平滑重启
php artisan swoole:http restart #重启
php artisan swoole:http infos #查看信息
実行中のswooleプロセスを表示します。psaux| grep swooleに
は、メインプロセス、管理プロセス、および2つのワーカープロセスがあります。
[root@VM-0-6-centos ~]# ps aux |grep swoole
root 9423 0.1 1.6 361064 30912 pts/0 Sl+ 00:01 0:00 swoole_http_server: master process for Laravel
root 9427 0.0 1.2 289388 23340 pts/0 S+ 00:01 0:00 swoole_http_server: manager process for Laravel
root 9429 0.0 1.3 291588 25812 pts/0 S+ 00:01 0:00 swoole_http_server: worker process for Laravel
root 9764 0.0 0.0 112816 972 pts/2 S+ 00:03 0:00 grep --color=auto swoole
3. Nginxは、ポート1215を転送するようにproxy_passを構成します
主にproxy_passhttp://127.0.0.1:1215;
user nginx;
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name www.liuyuanshan.top;
root html;
location / {
index index.php index.html index.htm;
#try_files $uri $uri/ /index.php?$query_string;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_index index.php;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/usr/local/php/var/run/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /status {
auth_basic "http://106.52.36.65";
auth_basic_user_file /usr/local/nginx/html/pass.db;
stub_status;
}
}
server {
listen 80;
server_name laravel.liuyuanshan.top;
access_log logs/laravel.access.log main;
root html/laravel/public;
location / {
index index.php index.html index.htm;
proxy_pass http://127.0.0.1:1215;
}
location ~ \.php$ {
fastcgi_pass unix:/usr/local/php/var/run/www.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}