wordpress 개발 환경을 로컬로 구축
1. virtualbox + vagrant로 centos7 box 만들기
(1) box 추가
vagrant box add wp-hidanireiko https://atlas.hashicorp.com/chef/boxes/centos-7.0/versions/1.0.0/providers/virtualbox.box
vagrant init wp-hidanireiko
(2) 공유 폴더 설정
vagrant box add wp-hidanireiko https://atlas.hashicorp.com/chef/boxes/centos-7.0/versions/1.0.0/providers/virtualbox.box
vagrant init wp-hidanireiko
Vagrantfile
# plugin vagrant_vbudgest on
config.vbguest.auto_update = true
#syncedfolder設定
config.vm.synced_folder "./wordpress", "/home/vagrant/wordpress", :create =>true, :group => 'vagrant', :user => 'vagrant', :mount_options => ['dmode=777', 'fmode=666']
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.33.31"
config.vm.synced_folder "./wordpress", "/home/vagrant/wordpress", :create =>true, :group => 'vagrant', :user => 'vagrant', :mount_options => ['dmode=777', 'fmode=666']
vagrant ssh
sudo yum -y update kernel
sudo yum -y install kernel-devel kernel-headers dkms gcc gcc-c++
exit
vagrant halt
vagrant up
2.NGINX 설치
sudo yum -y update
sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
sudo yum -y install nginx
sudo service nginx start
sudo chkconfig nginx
3.php 설치
sudo yum -y install php php-mysql php-mbstring php-common php php-cgi php-fpm php-gd
4. mysql 설치
sudo yum -y install mysql
sudo yum -y install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
sudo yum -y install mysql-server
sudo service mysqld start
sudo chkconfig mysqld on
#mysqlのrootユーザのパスワード変更(sukisuki19)
mysql -u root
UPDATE mysql.user SET Password=PASSWORD('sukisuki19') WHERE User='root';
FLUSH PRIVILEGES;
exit
sudo service mysqld restart
#wordpress用データベース作成
mysql -u root -p
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
grant all on wordpress.* to wordpress@localhost identified by "sserpdrow";
flush privileges;
#確認
mysql -u wordpress -p
(password: sserpdrow)
5. PHP-FPM 설정
cd /etc/php-fpm.d
sudo cp www.conf www.conf.org
*user,groupをvagrantに変更 , pm = staticに変更 ,pm.max_childern=3 ,
request_terminate_timeout = 300 を設定
sudo service php-fpm restart
sudo chkconfig php-fpm
6.wordpress 설치
cd ~/
mkdir wk
cd wk
wget http://ja.wordpress.org/latest-ja.tar.gz
tar xzvf latest-ja.tar.gz
cd wordpress
cp -r ./* ../../wordpress
cd ../../
sudo chown vagrant:vagrant wordpress
#シンボリックリンク作成
sudo ln -fs /home/vagrant/wordpress /var/www/wordpress
sudo chmod +x /home/vagrant
7.SWAP 작성
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
sudo swapon /swapfile
sudo service mysqld restart
mysql_secure_installation
현재 루트 암호를 입력합니다. 기본적으로 루트 계정에는 암호가 설정되어 있지 않으므로 Enter 키를 누릅니다.
를 입력하여 암호를 설정하고 안전한 암호를 두 번 입력합니다.
sukisuki19
Y를 입력하여 익명 사용자 계정을 삭제합니다.
Y를 입력하여 루트 로그인을 비활성화합니다.
Y를 입력하여 테스트 데이터베이스를 삭제합니다.
Y를 입력하여 권한 테이블을 다시 로드하고 변경사항을 저장합니다.
8.nginx 설정
/etc/nginx/nginx.conf# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
#worker_cpu_affinity 01 10;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}
/etc/nginx/conf.d/default.confserver
{
listen 80;
server_name localhost;
#ログの場所を指定
access_log /var/log/nginx/localhost/access.log;
error_log /var/log/nginx/localhost/error.log;
# wordpressのフォルダを指定
location / {
root /var/www/wordpress;
index index.php index.html index.htm;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
/etc/nginx/conf.d/virtual.conf#ここから本体の設定
server
{
listen 80;
server_name hidanireiko.dev;
#ログの場所を指定
access_log /var/log/nginx/hidanireiko/access.log;
error_log /var/log/nginx/hidanireiko/error.log;
root /var/www/wordpress;
index index.php;
# wordpressのフォルダ
location / {
root /var/www/wordpress;
index index.php;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
#logフォルダの作成とnginx再起動
sudo mkdir /var/log/nginx/localhost
sudo mkdir /var/log/nginx/hidanireiko
sudo chown -R vagrant:vagrant /var/log/nginx
sudo service nginx restart
9.wordpress 설정
192.168.33.31 hidanireiko.dev를 호스트에 추가
브라우저에서 ht tp // // 주름에 레이코. 에서 v에 연결하고 설정
10. VM측 추가 설정
(1) Xdebug 설치
#epelの登録
sudo yum -y install epel-release
#epelから edebugインストール
sudo yum -y install php-pecl-xdebug --enablerepo=epel
#確認
php -v
#結果以下のようにXdebugのバージョン情報が出力される
PHP 5.5.26 (cli) ・・・
with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
php.ini에 다음을 추가
php.inixdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_host = 192.168.33.1
(2) 환경 변수 설정
export PHP_IDE_CONFIG="serverName=hidanireiko.dev"
(3)이어서 · PHPUnit 설치
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version
(4) 이어서 · 시간대를 JST로
timedatectl list-timezones
sudo timedatectl set-timezone Asia/Tokyo
* 여기까지의 상태에서 box화와 git화
11.PHPStorm 설정
(1) PHPRemoteDebug 설정
①설정
sudo yum -y update
sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
sudo yum -y install nginx
sudo service nginx start
sudo chkconfig nginx
sudo yum -y install php php-mysql php-mbstring php-common php php-cgi php-fpm php-gd
4. mysql 설치
sudo yum -y install mysql
sudo yum -y install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
sudo yum -y install mysql-server
sudo service mysqld start
sudo chkconfig mysqld on
#mysqlのrootユーザのパスワード変更(sukisuki19)
mysql -u root
UPDATE mysql.user SET Password=PASSWORD('sukisuki19') WHERE User='root';
FLUSH PRIVILEGES;
exit
sudo service mysqld restart
#wordpress用データベース作成
mysql -u root -p
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
grant all on wordpress.* to wordpress@localhost identified by "sserpdrow";
flush privileges;
#確認
mysql -u wordpress -p
(password: sserpdrow)
5. PHP-FPM 설정
cd /etc/php-fpm.d
sudo cp www.conf www.conf.org
*user,groupをvagrantに変更 , pm = staticに変更 ,pm.max_childern=3 ,
request_terminate_timeout = 300 を設定
sudo service php-fpm restart
sudo chkconfig php-fpm
6.wordpress 설치
cd ~/
mkdir wk
cd wk
wget http://ja.wordpress.org/latest-ja.tar.gz
tar xzvf latest-ja.tar.gz
cd wordpress
cp -r ./* ../../wordpress
cd ../../
sudo chown vagrant:vagrant wordpress
#シンボリックリンク作成
sudo ln -fs /home/vagrant/wordpress /var/www/wordpress
sudo chmod +x /home/vagrant
7.SWAP 작성
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
sudo swapon /swapfile
sudo service mysqld restart
mysql_secure_installation
현재 루트 암호를 입력합니다. 기본적으로 루트 계정에는 암호가 설정되어 있지 않으므로 Enter 키를 누릅니다.
를 입력하여 암호를 설정하고 안전한 암호를 두 번 입력합니다.
sukisuki19
Y를 입력하여 익명 사용자 계정을 삭제합니다.
Y를 입력하여 루트 로그인을 비활성화합니다.
Y를 입력하여 테스트 데이터베이스를 삭제합니다.
Y를 입력하여 권한 테이블을 다시 로드하고 변경사항을 저장합니다.
8.nginx 설정
/etc/nginx/nginx.conf# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
#worker_cpu_affinity 01 10;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}
/etc/nginx/conf.d/default.confserver
{
listen 80;
server_name localhost;
#ログの場所を指定
access_log /var/log/nginx/localhost/access.log;
error_log /var/log/nginx/localhost/error.log;
# wordpressのフォルダを指定
location / {
root /var/www/wordpress;
index index.php index.html index.htm;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
/etc/nginx/conf.d/virtual.conf#ここから本体の設定
server
{
listen 80;
server_name hidanireiko.dev;
#ログの場所を指定
access_log /var/log/nginx/hidanireiko/access.log;
error_log /var/log/nginx/hidanireiko/error.log;
root /var/www/wordpress;
index index.php;
# wordpressのフォルダ
location / {
root /var/www/wordpress;
index index.php;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
#logフォルダの作成とnginx再起動
sudo mkdir /var/log/nginx/localhost
sudo mkdir /var/log/nginx/hidanireiko
sudo chown -R vagrant:vagrant /var/log/nginx
sudo service nginx restart
9.wordpress 설정
192.168.33.31 hidanireiko.dev를 호스트에 추가
브라우저에서 ht tp // // 주름에 레이코. 에서 v에 연결하고 설정
10. VM측 추가 설정
(1) Xdebug 설치
#epelの登録
sudo yum -y install epel-release
#epelから edebugインストール
sudo yum -y install php-pecl-xdebug --enablerepo=epel
#確認
php -v
#結果以下のようにXdebugのバージョン情報が出力される
PHP 5.5.26 (cli) ・・・
with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
php.ini에 다음을 추가
php.inixdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_host = 192.168.33.1
(2) 환경 변수 설정
export PHP_IDE_CONFIG="serverName=hidanireiko.dev"
(3)이어서 · PHPUnit 설치
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version
(4) 이어서 · 시간대를 JST로
timedatectl list-timezones
sudo timedatectl set-timezone Asia/Tokyo
* 여기까지의 상태에서 box화와 git화
11.PHPStorm 설정
(1) PHPRemoteDebug 설정
①설정
sudo yum -y install mysql
sudo yum -y install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
sudo yum -y install mysql-server
sudo service mysqld start
sudo chkconfig mysqld on
#mysqlのrootユーザのパスワード変更(sukisuki19)
mysql -u root
UPDATE mysql.user SET Password=PASSWORD('sukisuki19') WHERE User='root';
FLUSH PRIVILEGES;
exit
sudo service mysqld restart
#wordpress用データベース作成
mysql -u root -p
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
grant all on wordpress.* to wordpress@localhost identified by "sserpdrow";
flush privileges;
#確認
mysql -u wordpress -p
(password: sserpdrow)
cd /etc/php-fpm.d
sudo cp www.conf www.conf.org
*user,groupをvagrantに変更 , pm = staticに変更 ,pm.max_childern=3 ,
request_terminate_timeout = 300 を設定
sudo service php-fpm restart
sudo chkconfig php-fpm
6.wordpress 설치
cd ~/
mkdir wk
cd wk
wget http://ja.wordpress.org/latest-ja.tar.gz
tar xzvf latest-ja.tar.gz
cd wordpress
cp -r ./* ../../wordpress
cd ../../
sudo chown vagrant:vagrant wordpress
#シンボリックリンク作成
sudo ln -fs /home/vagrant/wordpress /var/www/wordpress
sudo chmod +x /home/vagrant
7.SWAP 작성
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
sudo swapon /swapfile
sudo service mysqld restart
mysql_secure_installation
현재 루트 암호를 입력합니다. 기본적으로 루트 계정에는 암호가 설정되어 있지 않으므로 Enter 키를 누릅니다.
를 입력하여 암호를 설정하고 안전한 암호를 두 번 입력합니다.
sukisuki19
Y를 입력하여 익명 사용자 계정을 삭제합니다.
Y를 입력하여 루트 로그인을 비활성화합니다.
Y를 입력하여 테스트 데이터베이스를 삭제합니다.
Y를 입력하여 권한 테이블을 다시 로드하고 변경사항을 저장합니다.
8.nginx 설정
/etc/nginx/nginx.conf# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
#worker_cpu_affinity 01 10;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}
/etc/nginx/conf.d/default.confserver
{
listen 80;
server_name localhost;
#ログの場所を指定
access_log /var/log/nginx/localhost/access.log;
error_log /var/log/nginx/localhost/error.log;
# wordpressのフォルダを指定
location / {
root /var/www/wordpress;
index index.php index.html index.htm;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
/etc/nginx/conf.d/virtual.conf#ここから本体の設定
server
{
listen 80;
server_name hidanireiko.dev;
#ログの場所を指定
access_log /var/log/nginx/hidanireiko/access.log;
error_log /var/log/nginx/hidanireiko/error.log;
root /var/www/wordpress;
index index.php;
# wordpressのフォルダ
location / {
root /var/www/wordpress;
index index.php;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
#logフォルダの作成とnginx再起動
sudo mkdir /var/log/nginx/localhost
sudo mkdir /var/log/nginx/hidanireiko
sudo chown -R vagrant:vagrant /var/log/nginx
sudo service nginx restart
9.wordpress 설정
192.168.33.31 hidanireiko.dev를 호스트에 추가
브라우저에서 ht tp // // 주름에 레이코. 에서 v에 연결하고 설정
10. VM측 추가 설정
(1) Xdebug 설치
#epelの登録
sudo yum -y install epel-release
#epelから edebugインストール
sudo yum -y install php-pecl-xdebug --enablerepo=epel
#確認
php -v
#結果以下のようにXdebugのバージョン情報が出力される
PHP 5.5.26 (cli) ・・・
with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
php.ini에 다음을 추가
php.inixdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_host = 192.168.33.1
(2) 환경 변수 설정
export PHP_IDE_CONFIG="serverName=hidanireiko.dev"
(3)이어서 · PHPUnit 설치
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version
(4) 이어서 · 시간대를 JST로
timedatectl list-timezones
sudo timedatectl set-timezone Asia/Tokyo
* 여기까지의 상태에서 box화와 git화
11.PHPStorm 설정
(1) PHPRemoteDebug 설정
①설정
cd ~/
mkdir wk
cd wk
wget http://ja.wordpress.org/latest-ja.tar.gz
tar xzvf latest-ja.tar.gz
cd wordpress
cp -r ./* ../../wordpress
cd ../../
sudo chown vagrant:vagrant wordpress
#シンボリックリンク作成
sudo ln -fs /home/vagrant/wordpress /var/www/wordpress
sudo chmod +x /home/vagrant
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
sudo swapon /swapfile
sudo service mysqld restart
mysql_secure_installation
현재 루트 암호를 입력합니다. 기본적으로 루트 계정에는 암호가 설정되어 있지 않으므로 Enter 키를 누릅니다.
를 입력하여 암호를 설정하고 안전한 암호를 두 번 입력합니다.
sukisuki19
Y를 입력하여 익명 사용자 계정을 삭제합니다.
Y를 입력하여 루트 로그인을 비활성화합니다.
Y를 입력하여 테스트 데이터베이스를 삭제합니다.
Y를 입력하여 권한 테이블을 다시 로드하고 변경사항을 저장합니다.
8.nginx 설정
/etc/nginx/nginx.conf# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
#worker_cpu_affinity 01 10;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}
/etc/nginx/conf.d/default.confserver
{
listen 80;
server_name localhost;
#ログの場所を指定
access_log /var/log/nginx/localhost/access.log;
error_log /var/log/nginx/localhost/error.log;
# wordpressのフォルダを指定
location / {
root /var/www/wordpress;
index index.php index.html index.htm;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
/etc/nginx/conf.d/virtual.conf#ここから本体の設定
server
{
listen 80;
server_name hidanireiko.dev;
#ログの場所を指定
access_log /var/log/nginx/hidanireiko/access.log;
error_log /var/log/nginx/hidanireiko/error.log;
root /var/www/wordpress;
index index.php;
# wordpressのフォルダ
location / {
root /var/www/wordpress;
index index.php;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
#logフォルダの作成とnginx再起動
sudo mkdir /var/log/nginx/localhost
sudo mkdir /var/log/nginx/hidanireiko
sudo chown -R vagrant:vagrant /var/log/nginx
sudo service nginx restart
9.wordpress 설정
192.168.33.31 hidanireiko.dev를 호스트에 추가
브라우저에서 ht tp // // 주름에 레이코. 에서 v에 연결하고 설정
10. VM측 추가 설정
(1) Xdebug 설치
#epelの登録
sudo yum -y install epel-release
#epelから edebugインストール
sudo yum -y install php-pecl-xdebug --enablerepo=epel
#確認
php -v
#結果以下のようにXdebugのバージョン情報が出力される
PHP 5.5.26 (cli) ・・・
with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
php.ini에 다음을 추가
php.inixdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_host = 192.168.33.1
(2) 환경 변수 설정
export PHP_IDE_CONFIG="serverName=hidanireiko.dev"
(3)이어서 · PHPUnit 설치
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version
(4) 이어서 · 시간대를 JST로
timedatectl list-timezones
sudo timedatectl set-timezone Asia/Tokyo
* 여기까지의 상태에서 box화와 git화
11.PHPStorm 설정
(1) PHPRemoteDebug 설정
①설정
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
#worker_cpu_affinity 01 10;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}
server
{
listen 80;
server_name localhost;
#ログの場所を指定
access_log /var/log/nginx/localhost/access.log;
error_log /var/log/nginx/localhost/error.log;
# wordpressのフォルダを指定
location / {
root /var/www/wordpress;
index index.php index.html index.htm;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
#ここから本体の設定
server
{
listen 80;
server_name hidanireiko.dev;
#ログの場所を指定
access_log /var/log/nginx/hidanireiko/access.log;
error_log /var/log/nginx/hidanireiko/error.log;
root /var/www/wordpress;
index index.php;
# wordpressのフォルダ
location / {
root /var/www/wordpress;
index index.php;
# パーマリンク用の設定
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
# wp-config.phpへのアクセスをすべて拒否します。
location ~* /wp-config.php {
deny all;
}
#静的file
location ~* ^.+.(jpg|jpeg|gif|png|css|js|flv|swf|ico|xml)$ {
access_log off;
expires 30d;
root /var/www/wordpress;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
}
#logフォルダの作成とnginx再起動
sudo mkdir /var/log/nginx/localhost
sudo mkdir /var/log/nginx/hidanireiko
sudo chown -R vagrant:vagrant /var/log/nginx
sudo service nginx restart
192.168.33.31 hidanireiko.dev를 호스트에 추가
브라우저에서 ht tp // // 주름에 레이코. 에서 v에 연결하고 설정
10. VM측 추가 설정
(1) Xdebug 설치
#epelの登録
sudo yum -y install epel-release
#epelから edebugインストール
sudo yum -y install php-pecl-xdebug --enablerepo=epel
#確認
php -v
#結果以下のようにXdebugのバージョン情報が出力される
PHP 5.5.26 (cli) ・・・
with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
php.ini에 다음을 추가
php.inixdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_host = 192.168.33.1
(2) 환경 변수 설정
export PHP_IDE_CONFIG="serverName=hidanireiko.dev"
(3)이어서 · PHPUnit 설치
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version
(4) 이어서 · 시간대를 JST로
timedatectl list-timezones
sudo timedatectl set-timezone Asia/Tokyo
* 여기까지의 상태에서 box화와 git화
11.PHPStorm 설정
(1) PHPRemoteDebug 설정
①설정
#epelの登録
sudo yum -y install epel-release
#epelから edebugインストール
sudo yum -y install php-pecl-xdebug --enablerepo=epel
#確認
php -v
#結果以下のようにXdebugのバージョン情報が出力される
PHP 5.5.26 (cli) ・・・
with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans
php.ini에 다음을 추가
php.ini
xdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_host = 192.168.33.1
(2) 환경 변수 설정
export PHP_IDE_CONFIG="serverName=hidanireiko.dev"
(3)이어서 · PHPUnit 설치
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version
(4) 이어서 · 시간대를 JST로
timedatectl list-timezones
sudo timedatectl set-timezone Asia/Tokyo
* 여기까지의 상태에서 box화와 git화
11.PHPStorm 설정
(1) PHPRemoteDebug 설정
①설정
Run/Debug Configurations 대화 상자를 엽니 다
②동작 확인
설정 후 상태
→PhpStorm으로 디버그 모드로
vagrant ssh
php XXX.php
→PhpStorm에서 디버그 모드로.
Reference
이 문제에 관하여(wordpress 개발 환경을 로컬로 구축), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/agotoh/items/ee7abee93ea675534537텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)