gpt4 book ai didi

laravel - 在 Ubuntu 14.04 控制台上运行 Vagrant

转载 作者:行者123 更新时间:2023-12-04 19:01:37 24 4
gpt4 key购买 nike

是否可以在 Ubuntu 14.04 上运行 Vagrant 虚拟机?
我了解此特定 VPS 服务器上的 SSH 上没有 GUI,所以我认为这就是我收到以下错误的原因:

The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.

问题是我以前在带有 VirtualBox 和 Vagrant 的 Windows 机器 VM 上使用 Laravel Homestead;我目前正在寻找将其移至 VPS。
我应该一起忽略虚拟机还是应该以其他方式创建一个盒子? (可能吗)

最佳答案

根据讨论,这些是在 uBuntu 上安装 Laravel 5 的以下步骤。

假设您没有 PHP 5,以下是安装它的步骤:

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get install -y php5.6 php5.6-mcrypt php5.6-gd

如果您没有安装 apache2:
$ apt-get install apache2 libapache2-mod-php5

如果您没有安装 MYSQL:
$ apt-get install mysql-server php5.6-mysql

Laravel composer 是必须安装的,需要互联网连接:
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo chmod +x /usr/local/bin/composer

安装 GIT:
$ apt-get install git

为 Laravel 启用 mbstring 扩展:
https://stackoverflow.com/a/33736248/1589224

安装 Laravel 5:
$ cd /var/www
$ git clone https://github.com/laravel/laravel.git

导航到 Laravel 代码目录并使用 composer 安装 Laravel 框架所需的所有依赖项。
$ cd /var/www/laravel
$ sudo composer install

依赖安装需要一些时间。之后对文件设置适当的权限。
$ chown -R www-data.www-data /var/www/laravel
$ chmod -R 755 /var/www/laravel
$ chmod -R 777 /var/www/laravel/app/storage

现在您必须设置加密 key :

现在设置 Illuminate 加密器服务使用的 32 位长随机数加密 key 。
$ php artisan key:generate

Application key [uOHTNu3Au1Kt7Uloyr2Py9blU0J5XQ75] set successfully.

现在编辑 config/app.php 配置文件并更新上面生成的应用程序 key ,如下所示。还要确保密码设置正确。
'key' => env('APP_KEY', 'uOHTNu3Au1Kt7Uloyr2Py9blU0J5XQ75'),

'cipher' => 'AES-256-CBC',

下一步是创建 Apache VirtualHost

现在在您的 Apache 配置文件中添加一个虚拟主机以从 Web 浏览器访问 Laravel 框架。在 /etc/apache2/sites-available/下创建Apache配置文件目录并添加以下内容。
$ nano /etc/apache2/sites-available/laravel.example.com.conf

您需要成为 root 或 super 用户才能编辑它
    ServerName laravel.example.com
DocumentRoot /var/www/laravel/public

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/laravel>
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined

完成后,按 CTRL+X并输入 Y并按 Enter
最后让我们使用以下命令启用网站并重新加载 Apache 服务。
$ a2ensite laravel.example.com
$ sudo service apache2 reload

最后一步:

访问 laravel
$ sudo echo "127.0.0.1  laravel.example.com" >> /etc/hosts

并访问 http://laravel.example.com在您喜欢的网络浏览器中,如下所示。

在您的情况下,您将网站移至 /var/www/你已经可以查看它了。

您也可以 CHOWN Laravel 目录上的 Vagrant 也是如此。

关于laravel - 在 Ubuntu 14.04 控制台上运行 Vagrant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42380969/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com