laravel 是一个 php web 应用程序框架,具有富有表现力、优雅的语法。它具有精炼、简单和可读的语法,用于从头开始开发现代、健壮和强大的应用程序。laravel 提供了强大的功能,包括 artisan、mvc 架构、对象关系映射、模板引擎、单元测试和数据库迁移系统。
在 上
第 1 步。首先,让我们首先确保您的系统是最新的。
sudo dnf clean all sudo dnf install epel-release sudo dnf update
步骤 2. 安装 lemp 服务器。
需要 almalinux lemp 服务器。如果您没有安装 lemp,您可以在此处按照我们的指南进行操作。
步骤 3. 安装 composer。
现在我们使用以下命令安装 composer(php 的依赖管理器)来安装所需的 laravel 依赖项:
curl -ss https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer chmod x /usr/local/bin/composer
验证 composer 版本:
composer --version
步骤 4. 在 almalinux 8 上安装 laravel。
默认情况下,laravel 在 almalinux 8 基础存储库中不可用。现在我们运行以下命令来使用 composer 安装 laravel:
cd /var/www/html/ composer create-project --prefer-dist laravel/laravel laravel
我们将需要更改一些文件夹权限:
chown -r nginx:nginx /var/www/html/laravel/ chown -r nginx:nginx /var/www/html/laravel/storage/ chown -r nginx:nginx /var/www/html/laravel/bootstrap/cache/ chmod -r 0777 /var/www/html/laravel/storage/ chmod -r 0775 /var/www/html/laravel/bootstrap/cache/
步骤 5. 配置 nginx。
现在我们为 laravel 创建一个 nginx 配置文件:
nano /etc/nginx/conf.d/laravel.conf
添加以下行:
server { listen 80; server_name laravel.your-domain.com; root /var/www/html/laravel/public; index index.php; charset utf-8; gzip on; gzip_types text/css application/javascript text/javascript application/x-javascript image/svgxml text/plain text/xsd text/xsl text/xml image/x-icon; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php { include fastcgi.conf; fastcgi_split_path_info ^(. \.php)(/. )$; fastcgi_pass unix:/run/php-fpm/www.sock; } location ~ /\.ht { deny all; } }
保存并关闭文件,然后重新启动 apache 服务以使更改生效:
sudo systemctl restart php-fpm sudo systemctl restart nginx
步骤 5. 配置防火墙。
almalinux 默认启用了 firewalld,它会阻止来自其他试图访问我们 laravel 服务的计算机的其他连接。我们必须打开适当的端口,以便其他机器可以访问 laravel 资源:
sudo firewall-cmd --zone=public --permanent --add-service=http sudo firewall-cmd --zone=public --permanent --add-service=https sudo firewall-cmd --reload
步骤 6. 使用 let’s encrypt ssl 免费证书保护 nginx
首先,我们使用以下命令安装 certbot:
sudo dnf install certbot python3-certbot-nginx
然后,为 apache 安装 ssl 证书,如下所示:
sudo certbot --nginx -d laravel.your-domain.com
进入交互式提示并安装证书。如果安装了证书,您将看到以下祝贺消息:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - congratulations! you have successfully enabled https://laravel.your-domain.com you should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=laravel.your-domain.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - important notes: - congratulations! your certificate and chain have been saved at: /etc/letsencrypt/live/laravel.your-domain.com/fullchain.pem your key file has been saved at: /etc/letsencrypt/live/laravel.your-domain.com/privkey.pem your cert will expire on 2022-04-11. to obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. to non-interactively renew *all* of your certificates, run "certbot renew" - your account credentials have been saved in your certbot configuration directory at /etc/letsencrypt. you should make a secure backup of this folder now. this configuration directory will also contain certificates and private keys obtained by certbot so making regular backups of this folder is ideal. - if you like certbot, please consider supporting our work by: donating to isrg / let's encrypt: https://letsencrypt.org/donate donating to eff: https://eff.org/donate-le - we were unable to subscribe you the eff mailing list because your e-mail address appears to be invalid. you can try again later by visiting https://act.eff.org.
步骤 7. 访问 laravel web 界面。
成功安装后,打开您的网络浏览器并使用 url 访问 mediawiki 。您将被重定向到以下页面:https://laravel.your-domain.com
感谢您使用本教程在您的 almalinux 8 系统上安装 laravel php 框架。如需更多帮助或有用信息,我们建议您查看。
原创文章,作者:校长,如若转载,请注明出处:https://www.yundongfang.com/yun224270.html