vagrant로 cake3.5의 로컬 환경 구축
15202 단어 VirtualBoxVagrantcakephp3
Vagrant란 무엇입니까?
vagrant 란 버추얼 박스에서의 환경 구축 간단하게 해주는 래퍼 툴인 것 같습니다
편리합니다.
그래서 사용합니다.
PHP의 경우 빌트인 서버 되는 것도 사용할 수 있습니다만, 이쪽이 버추얼 박스 완결할 수 있으므로 무엇인가 좋기 때문에 채용
vagrant를 설치합니다.
아래에서 다운로드를 실시합니다.
가상 박스의 설치는 아래에서 OS를 선택하여 입수
각각 인스톨러가 동고되고 있으므로, 그것을 사용해 인스톨 실시한다.
vagrant에 대한 디렉토리 작성
mkdir vmdir
cd vmdir
작성한 디렉토리에서 vagrant 파일을 작성하십시오.
아래 실행
vagrant init
아래 로그가 출력됩니다.
Vagrant failed to initialize at a very early stage:
The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:
vagrant plugin repair
If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:
vagrant plugin expunge --reinstall
Or you may want to try updating the installed plugins to their latest
versions:
vagrant plugin update
Error message given during initialization: Unable to resolve dependency: user requested 'vagrant-hostsupdater (> 0)'
제 경우에는 아래에서 해결
vagrant plugin repair
Repairing currently installed plugins. This may take a few minutes...
Fetching: vagrant-hostsupdater-1.0.2.gem (100%)
Fetching: vagrant-share-1.1.9.gem (100%)
Installed plugins successfully repaired!
그래도 문제가 해결되지 않으면 Vagrant 문서를 참조하십시오.
이번에는 centOS 6.9를 설치하고 싶으므로 아래 실행
``
vagrant box add bento/centos-6.9
==> box: Loading metadata for box 'bento/centos-6.9'
상자 : URL : htps: ///ゔぁg란tcぉd. 코 m / 젠토 / 센토 s-6.9
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.
1) parallels
2) virtualbox
3) vmware_desktop
三択、選択しろとのことなので、
私の場合はVirtualboxでやりたいので、
2 <= 選択
Enter your choice: 2
==> box: Adding box 'bento/centos-6.9' (v201708.22.0) for provider: virtualbox
박스: Downloading: htps: ///ゔぁg란tcぉd. 이 m/벤토/보오 s/센토 s-6.9/ゔぇr 시온 s/201708. Box
==> box: Box download is resuming from prior download progress
==> box: Successfully added box 'bento/centos-6.9' (v201708.22.0) for 'virtualbox'!
``
성공했습니다.
목록에 추가되었는지 확인합니다.
아래 실행
vagrant box list
bento/centos-6.9 (virtualbox, 201708.22.0)
miya0001/vccw (virtualbox, 2.19.0)
들어가, 도시락 먹고 싶어,
vagrant up
위의 실행으로 환경 구축 완료
ssh로 들어갑니다.
vagrant ssh
[vagrant@localhost ~]$ ls -a
. .. .bash_logout .bash_profile .bashrc .ssh .vbox_version
넣었습니다.
PHP 설치
sudo yum install -y epel-release
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo yum install --enablerepo=remi --enablerepo=remi-php56 -y php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof
sudo yum install --enablerepo=remi --enablerepo=remi-php56 -y php-intl
php intl이 필요하기 때문에 존재 확인
php -m | grep intl
intl
있었습니다.
php.ini 편집
sudo vim /etc/php.ini
date.timzone = "Asia/Tokyo"
추가,
Apache 설치
sudo yum install -y httpd httpd-devel
sudo service httpd start
sudo chkconfig httpd on
로그아웃
Vagrantfile 왼쪽 편집
vim Vagrantfile
config.vm.network "forwarded_port", guest: 80, host: 8080 左記がコメントアウトになっているので、コメントを外します。
vagrant를 다시로드합니다.
vagrant reload
이제 apache welcome 화면이 표시되는 것 같습니다.
Composer가 PHP의 패키지 관리 시스템이 편리하기 때문에 사용합니다.
composer curl로 설치 아래 실행
curl -s https://getcomposer.org/installer | php
/usr/local/bin
에 배치합니다.
sudo mv composer.phar /usr/local/bin/composer
문서 루트로 이동합니다.
cd /var/www/html
composer create-project --prefer-dist cakephp/app ./
Installing cakephp/app (3.5.0)
- Installing cakephp/app (3.5.0): Downloading (100%)
Created project in ./
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 39 installs, 0 updates, 0 removals
- Installing cakephp/plugin-installer (1.0.0): Downloading (100%)
- Installing aura/intl (3.0.0): Downloading (100%)
- Installing mobiledetect/mobiledetectlib (2.8.26): Downloading (100%)
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing zendframework/zend-diactoros (1.6.0): Downloading (100%)
- Installing psr/log (1.0.2): Downloading (100%)
- Installing cakephp/chronos (1.1.2): Downloading (100%)
- Installing cakephp/cakephp (3.5.2): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.5.0): Downloading (100%)
- Installing symfony/yaml (v3.3.9): Downloading (100%)
- Installing symfony/debug (v3.3.9): Downloading (100%)
- Installing symfony/console (v3.3.9): Downloading (100%)
- Installing symfony/filesystem (v3.3.9): Downloading (100%)
- Installing symfony/config (v3.3.9): Downloading (100%)
- Installing robmorgan/phinx (v0.8.1): Downloading (100%)
- Installing cakephp/migrations (1.7.1): Downloading (100%)
- Installing m1/env (2.1.0): Downloading (100%)
- Installing josegonzalez/dotenv (2.1.0): Downloading (100%)
- Installing jakub-onderka/php-console-color (0.1): Downloading (100%)
- Installing jakub-onderka/php-console-highlighter (v0.3.2): Downloading (100%)
- Installing dnoegel/php-xdg-base-dir (0.1): Downloading (100%)
- Installing nikic/php-parser (v3.1.1): Downloading (100%)
- Installing symfony/var-dumper (v3.3.9): Downloading (100%)
- Installing psy/psysh (v0.8.11): Downloading (100%)
- Installing jdorn/sql-formatter (v1.2.17): Downloading (100%)
- Installing symfony/process (v3.3.9): Downloading (100%)
- Installing symfony/finder (v3.3.9): Downloading (100%)
- Installing seld/phar-utils (1.0.1): Downloading (100%)
- Installing seld/jsonlint (1.6.1): Downloading (100%)
- Installing seld/cli-prompt (1.0.3): Downloading (100%)
- Installing justinrainbow/json-schema (5.2.1): Downloading (100%)
- Installing composer/spdx-licenses (1.1.6): Downloading (100%)
- Installing composer/semver (1.4.2): Downloading (100%)
- Installing composer/ca-bundle (1.0.8): Downloading (100%)
- Installing composer/composer (1.5.2): Downloading (100%)
- Installing cakephp/debug_kit (3.11.1): Downloading (100%)
- Installing cakephp/bake (1.4.2): Downloading (100%)
- Installing squizlabs/php_codesniffer (3.0.2): Downloading (100%)
- Installing cakephp/cakephp-codesniffer (3.0.1): Downloading (100%)
cakephp/app suggests installing markstory/asset_compress (An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.)
cakephp/app suggests installing dereuromark/cakephp-ide-helper (After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.)
cakephp/app suggests installing phpunit/phpunit (Allows automated tests to be run without system-wide install.)
cakephp/cakephp suggests installing lib-ICU (The intl PHP library, to use Text::transliterate() or Text::slug())
symfony/console suggests installing symfony/event-dispatcher ()
m1/env suggests installing m1/vars (For loading of configs)
symfony/var-dumper suggests installing ext-symfony_debug ()
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
cakephp/debug_kit suggests installing ext-sqlite (DebugKit needs to store panel data in a database. SQLite is simple and easy to use.)
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
> App\Console\Installer::postInstall
Created `config/app.php` file
Set Folder Permissions ? (Default to Y) [Y,n]? Y # <- Yを選択
Permissions set on /var/www/html/tmp/cache
Permissions set on /var/www/html/tmp/cache/models
Permissions set on /var/www/html/tmp/cache/persistent
Permissions set on /var/www/html/tmp/cache/views
Permissions set on /var/www/html/tmp/sessions
Permissions set on /var/www/html/tmp/tests
Permissions set on /var/www/html/tmp
Permissions set on /var/www/html/logs
Updated Security.salt value in config/app.php
Apache conf 파일을 편집합니다.
sudo vi /etc/httpd/conf/httpd.conf
# 下記変更
# Options Indexes FollowSymLinks
Options Includes ExecCGI FollowSymLinks
# 下記変更
# AllowOverride None
AllowOverride All
# 下記も変更
<Directory "/var/www/icons">
# Options Indexes MultiViews FollowSymLinks
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# 最後の行へ追加
TraceEnable off
Apache 재부팅
sudo service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
브라우저에서 볼 수 있는지 확인합니다.
mysql을 넣습니다.
vagrant~:$:
->> sudo yum install mysql mysql-server mysql-devel -y
vagrant~:$:
->> sudo service mysqld start
vagrant/:$:
->> sudo chkconfig mysqld on
vagrant~:$:
->> mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed! Not critical, keep moving...
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
mysql 사용자 생성
mysql -u root -p
mysql> grant all privileges on *.* to my_app@localhost identified by 'password';
Query OK, 0 rows affected (0.02 sec)
mysql> exit
Bye
방금 만든 사용자로 로그인합니다.
database를 만듭니다.
vagrant~:$:
->> mysql -u my_app -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database if not exists cakeDB;
Query OK, 1 row affected (0.00 sec)
데이터베이스를 만든 후에는
cakePHP config -> app.php를 편집합니다.
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',
'username' => 'my_app', <- my_app cake php のユーザー名を記述
'password' => 'DBのパスワードを記述',
'database' => '接続したいDatabaseを記述',
'encoding' => 'utf8',
'timezone' => '+09:00',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
이제 튜토리얼 페이지의 database 항목이 녹색이 되면 성공.
Reference
이 문제에 관하여(vagrant로 cake3.5의 로컬 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/keisukeYamagishi/items/8dc1e9fc6865af61fe88
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
mkdir vmdir
cd vmdir
vagrant init
Vagrant failed to initialize at a very early stage:
The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:
vagrant plugin repair
If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:
vagrant plugin expunge --reinstall
Or you may want to try updating the installed plugins to their latest
versions:
vagrant plugin update
Error message given during initialization: Unable to resolve dependency: user requested 'vagrant-hostsupdater (> 0)'
vagrant plugin repair
Repairing currently installed plugins. This may take a few minutes...
Fetching: vagrant-hostsupdater-1.0.2.gem (100%)
Fetching: vagrant-share-1.1.9.gem (100%)
Installed plugins successfully repaired!
三択、選択しろとのことなので、
私の場合はVirtualboxでやりたいので、
2 <= 選択
vagrant box list
bento/centos-6.9 (virtualbox, 201708.22.0)
miya0001/vccw (virtualbox, 2.19.0)
vagrant up
vagrant ssh
[vagrant@localhost ~]$ ls -a
. .. .bash_logout .bash_profile .bashrc .ssh .vbox_version
sudo yum install -y epel-release
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo yum install --enablerepo=remi --enablerepo=remi-php56 -y php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof
sudo yum install --enablerepo=remi --enablerepo=remi-php56 -y php-intl
php intl이 필요하기 때문에 존재 확인
php -m | grep intl
intl
있었습니다.
php.ini 편집
sudo vim /etc/php.ini
date.timzone = "Asia/Tokyo"
추가,
Apache 설치
sudo yum install -y httpd httpd-devel
sudo service httpd start
sudo chkconfig httpd on
로그아웃
Vagrantfile 왼쪽 편집
vim Vagrantfile
config.vm.network "forwarded_port", guest: 80, host: 8080 左記がコメントアウトになっているので、コメントを外します。
vagrant를 다시로드합니다.
vagrant reload
이제 apache welcome 화면이 표시되는 것 같습니다.
Composer가 PHP의 패키지 관리 시스템이 편리하기 때문에 사용합니다.
composer curl로 설치 아래 실행
curl -s https://getcomposer.org/installer | php
/usr/local/bin
에 배치합니다.
sudo mv composer.phar /usr/local/bin/composer
문서 루트로 이동합니다.
cd /var/www/html
composer create-project --prefer-dist cakephp/app ./
Installing cakephp/app (3.5.0)
- Installing cakephp/app (3.5.0): Downloading (100%)
Created project in ./
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 39 installs, 0 updates, 0 removals
- Installing cakephp/plugin-installer (1.0.0): Downloading (100%)
- Installing aura/intl (3.0.0): Downloading (100%)
- Installing mobiledetect/mobiledetectlib (2.8.26): Downloading (100%)
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing zendframework/zend-diactoros (1.6.0): Downloading (100%)
- Installing psr/log (1.0.2): Downloading (100%)
- Installing cakephp/chronos (1.1.2): Downloading (100%)
- Installing cakephp/cakephp (3.5.2): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.5.0): Downloading (100%)
- Installing symfony/yaml (v3.3.9): Downloading (100%)
- Installing symfony/debug (v3.3.9): Downloading (100%)
- Installing symfony/console (v3.3.9): Downloading (100%)
- Installing symfony/filesystem (v3.3.9): Downloading (100%)
- Installing symfony/config (v3.3.9): Downloading (100%)
- Installing robmorgan/phinx (v0.8.1): Downloading (100%)
- Installing cakephp/migrations (1.7.1): Downloading (100%)
- Installing m1/env (2.1.0): Downloading (100%)
- Installing josegonzalez/dotenv (2.1.0): Downloading (100%)
- Installing jakub-onderka/php-console-color (0.1): Downloading (100%)
- Installing jakub-onderka/php-console-highlighter (v0.3.2): Downloading (100%)
- Installing dnoegel/php-xdg-base-dir (0.1): Downloading (100%)
- Installing nikic/php-parser (v3.1.1): Downloading (100%)
- Installing symfony/var-dumper (v3.3.9): Downloading (100%)
- Installing psy/psysh (v0.8.11): Downloading (100%)
- Installing jdorn/sql-formatter (v1.2.17): Downloading (100%)
- Installing symfony/process (v3.3.9): Downloading (100%)
- Installing symfony/finder (v3.3.9): Downloading (100%)
- Installing seld/phar-utils (1.0.1): Downloading (100%)
- Installing seld/jsonlint (1.6.1): Downloading (100%)
- Installing seld/cli-prompt (1.0.3): Downloading (100%)
- Installing justinrainbow/json-schema (5.2.1): Downloading (100%)
- Installing composer/spdx-licenses (1.1.6): Downloading (100%)
- Installing composer/semver (1.4.2): Downloading (100%)
- Installing composer/ca-bundle (1.0.8): Downloading (100%)
- Installing composer/composer (1.5.2): Downloading (100%)
- Installing cakephp/debug_kit (3.11.1): Downloading (100%)
- Installing cakephp/bake (1.4.2): Downloading (100%)
- Installing squizlabs/php_codesniffer (3.0.2): Downloading (100%)
- Installing cakephp/cakephp-codesniffer (3.0.1): Downloading (100%)
cakephp/app suggests installing markstory/asset_compress (An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.)
cakephp/app suggests installing dereuromark/cakephp-ide-helper (After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.)
cakephp/app suggests installing phpunit/phpunit (Allows automated tests to be run without system-wide install.)
cakephp/cakephp suggests installing lib-ICU (The intl PHP library, to use Text::transliterate() or Text::slug())
symfony/console suggests installing symfony/event-dispatcher ()
m1/env suggests installing m1/vars (For loading of configs)
symfony/var-dumper suggests installing ext-symfony_debug ()
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
cakephp/debug_kit suggests installing ext-sqlite (DebugKit needs to store panel data in a database. SQLite is simple and easy to use.)
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
> App\Console\Installer::postInstall
Created `config/app.php` file
Set Folder Permissions ? (Default to Y) [Y,n]? Y # <- Yを選択
Permissions set on /var/www/html/tmp/cache
Permissions set on /var/www/html/tmp/cache/models
Permissions set on /var/www/html/tmp/cache/persistent
Permissions set on /var/www/html/tmp/cache/views
Permissions set on /var/www/html/tmp/sessions
Permissions set on /var/www/html/tmp/tests
Permissions set on /var/www/html/tmp
Permissions set on /var/www/html/logs
Updated Security.salt value in config/app.php
Apache conf 파일을 편집합니다.
sudo vi /etc/httpd/conf/httpd.conf
# 下記変更
# Options Indexes FollowSymLinks
Options Includes ExecCGI FollowSymLinks
# 下記変更
# AllowOverride None
AllowOverride All
# 下記も変更
<Directory "/var/www/icons">
# Options Indexes MultiViews FollowSymLinks
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# 最後の行へ追加
TraceEnable off
Apache 재부팅
sudo service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
브라우저에서 볼 수 있는지 확인합니다.
mysql을 넣습니다.
vagrant~:$:
->> sudo yum install mysql mysql-server mysql-devel -y
vagrant~:$:
->> sudo service mysqld start
vagrant/:$:
->> sudo chkconfig mysqld on
vagrant~:$:
->> mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed! Not critical, keep moving...
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
mysql 사용자 생성
mysql -u root -p
mysql> grant all privileges on *.* to my_app@localhost identified by 'password';
Query OK, 0 rows affected (0.02 sec)
mysql> exit
Bye
방금 만든 사용자로 로그인합니다.
database를 만듭니다.
vagrant~:$:
->> mysql -u my_app -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database if not exists cakeDB;
Query OK, 1 row affected (0.00 sec)
데이터베이스를 만든 후에는
cakePHP config -> app.php를 편집합니다.
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',
'username' => 'my_app', <- my_app cake php のユーザー名を記述
'password' => 'DBのパスワードを記述',
'database' => '接続したいDatabaseを記述',
'encoding' => 'utf8',
'timezone' => '+09:00',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
이제 튜토리얼 페이지의 database 항목이 녹색이 되면 성공.
Reference
이 문제에 관하여(vagrant로 cake3.5의 로컬 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/keisukeYamagishi/items/8dc1e9fc6865af61fe88
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
sudo yum install -y httpd httpd-devel
sudo service httpd start
sudo chkconfig httpd on
vim Vagrantfile
config.vm.network "forwarded_port", guest: 80, host: 8080 左記がコメントアウトになっているので、コメントを外します。
vagrant reload
curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
cd /var/www/html
composer create-project --prefer-dist cakephp/app ./
Installing cakephp/app (3.5.0)
- Installing cakephp/app (3.5.0): Downloading (100%)
Created project in ./
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 39 installs, 0 updates, 0 removals
- Installing cakephp/plugin-installer (1.0.0): Downloading (100%)
- Installing aura/intl (3.0.0): Downloading (100%)
- Installing mobiledetect/mobiledetectlib (2.8.26): Downloading (100%)
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing zendframework/zend-diactoros (1.6.0): Downloading (100%)
- Installing psr/log (1.0.2): Downloading (100%)
- Installing cakephp/chronos (1.1.2): Downloading (100%)
- Installing cakephp/cakephp (3.5.2): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.5.0): Downloading (100%)
- Installing symfony/yaml (v3.3.9): Downloading (100%)
- Installing symfony/debug (v3.3.9): Downloading (100%)
- Installing symfony/console (v3.3.9): Downloading (100%)
- Installing symfony/filesystem (v3.3.9): Downloading (100%)
- Installing symfony/config (v3.3.9): Downloading (100%)
- Installing robmorgan/phinx (v0.8.1): Downloading (100%)
- Installing cakephp/migrations (1.7.1): Downloading (100%)
- Installing m1/env (2.1.0): Downloading (100%)
- Installing josegonzalez/dotenv (2.1.0): Downloading (100%)
- Installing jakub-onderka/php-console-color (0.1): Downloading (100%)
- Installing jakub-onderka/php-console-highlighter (v0.3.2): Downloading (100%)
- Installing dnoegel/php-xdg-base-dir (0.1): Downloading (100%)
- Installing nikic/php-parser (v3.1.1): Downloading (100%)
- Installing symfony/var-dumper (v3.3.9): Downloading (100%)
- Installing psy/psysh (v0.8.11): Downloading (100%)
- Installing jdorn/sql-formatter (v1.2.17): Downloading (100%)
- Installing symfony/process (v3.3.9): Downloading (100%)
- Installing symfony/finder (v3.3.9): Downloading (100%)
- Installing seld/phar-utils (1.0.1): Downloading (100%)
- Installing seld/jsonlint (1.6.1): Downloading (100%)
- Installing seld/cli-prompt (1.0.3): Downloading (100%)
- Installing justinrainbow/json-schema (5.2.1): Downloading (100%)
- Installing composer/spdx-licenses (1.1.6): Downloading (100%)
- Installing composer/semver (1.4.2): Downloading (100%)
- Installing composer/ca-bundle (1.0.8): Downloading (100%)
- Installing composer/composer (1.5.2): Downloading (100%)
- Installing cakephp/debug_kit (3.11.1): Downloading (100%)
- Installing cakephp/bake (1.4.2): Downloading (100%)
- Installing squizlabs/php_codesniffer (3.0.2): Downloading (100%)
- Installing cakephp/cakephp-codesniffer (3.0.1): Downloading (100%)
cakephp/app suggests installing markstory/asset_compress (An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.)
cakephp/app suggests installing dereuromark/cakephp-ide-helper (After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.)
cakephp/app suggests installing phpunit/phpunit (Allows automated tests to be run without system-wide install.)
cakephp/cakephp suggests installing lib-ICU (The intl PHP library, to use Text::transliterate() or Text::slug())
symfony/console suggests installing symfony/event-dispatcher ()
m1/env suggests installing m1/vars (For loading of configs)
symfony/var-dumper suggests installing ext-symfony_debug ()
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
cakephp/debug_kit suggests installing ext-sqlite (DebugKit needs to store panel data in a database. SQLite is simple and easy to use.)
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
> App\Console\Installer::postInstall
Created `config/app.php` file
Set Folder Permissions ? (Default to Y) [Y,n]? Y # <- Yを選択
Permissions set on /var/www/html/tmp/cache
Permissions set on /var/www/html/tmp/cache/models
Permissions set on /var/www/html/tmp/cache/persistent
Permissions set on /var/www/html/tmp/cache/views
Permissions set on /var/www/html/tmp/sessions
Permissions set on /var/www/html/tmp/tests
Permissions set on /var/www/html/tmp
Permissions set on /var/www/html/logs
Updated Security.salt value in config/app.php
sudo vi /etc/httpd/conf/httpd.conf
# 下記変更
# Options Indexes FollowSymLinks
Options Includes ExecCGI FollowSymLinks
# 下記変更
# AllowOverride None
AllowOverride All
# 下記も変更
<Directory "/var/www/icons">
# Options Indexes MultiViews FollowSymLinks
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# 最後の行へ追加
TraceEnable off
Apache 재부팅
sudo service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
브라우저에서 볼 수 있는지 확인합니다.
mysql을 넣습니다.
vagrant~:$:
->> sudo yum install mysql mysql-server mysql-devel -y
vagrant~:$:
->> sudo service mysqld start
vagrant/:$:
->> sudo chkconfig mysqld on
vagrant~:$:
->> mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed! Not critical, keep moving...
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
mysql 사용자 생성
mysql -u root -p
mysql> grant all privileges on *.* to my_app@localhost identified by 'password';
Query OK, 0 rows affected (0.02 sec)
mysql> exit
Bye
방금 만든 사용자로 로그인합니다.
database를 만듭니다.
vagrant~:$:
->> mysql -u my_app -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database if not exists cakeDB;
Query OK, 1 row affected (0.00 sec)
데이터베이스를 만든 후에는
cakePHP config -> app.php를 편집합니다.
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',
'username' => 'my_app', <- my_app cake php のユーザー名を記述
'password' => 'DBのパスワードを記述',
'database' => '接続したいDatabaseを記述',
'encoding' => 'utf8',
'timezone' => '+09:00',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
이제 튜토리얼 페이지의 database 항목이 녹색이 되면 성공.
Reference
이 문제에 관하여(vagrant로 cake3.5의 로컬 환경 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/keisukeYamagishi/items/8dc1e9fc6865af61fe88텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)