Virtualboxã®Centos7ã«LAMP(Nginx)ãæ§ç¯ãWordpressã¤ã³ã¹ãã¼ã«
Virtualboxã«Centosã®minimalãã¤ã³ã¹ãã¼ã«ããç¶æ
ãã
LAMP(Nginx使ç¨)
ãæ§ç¯ãWordPressãã¤ã³ã¹ãã¼ã«ãã¾ãã
ãã¡ã¤ã¢ã¦ã©ã¼ã«è¨å®
SSHã¨HTTPãéæ¾ãã¾ãã Centos7ããã¯firewalldãç¨ããããã«ãªã£ã¦ããã¿ããã§ããã minimalã«ã¯ã¤ã³ã¹ãã¼ã«ããã¦ããªãã£ãã®ã§ã¤ã³ã¹ãã¼ã«ã
yum install -y firewalld # HTTP ã®æ°¸ç¶çãªéæ¾ firewall-cmd --permanent --zone=public --add-service=http # å¤æ´ã®åæ firewall-cmd --reload
Nginx ã¤ã³ã¹ãã¼ã«
# ãªãã¸ããªè¿½å vi /etc/yum.repos.d/nginx.repo # ä¸è¨å 容ã§æ°è¦ä½æ [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=0 # Nginx ã¤ã³ã¹ãã¼ã« yum --enablerepo=nginx install nginx #èµ·å systemctl start nginx systemctl enable nginx
ã¦ã§ããã©ã¦ã¶ããhttp://192.168.56.xxxã«ã¢ã¯ã»ã¹ããã¨ä»¥ä¸ã®ãã¼ã¸ã表示ããã¾ãã (192.168.56.xxxã¯ip addressã§ãã)
Nginx è¨å®
cp -a /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.org vi /etc/nginx/conf.d/default.conf # 以ä¸ã®å 容ãè¨è¿° server { root /var/www/html; listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /var/www/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html; } }
PHP ã¤ã³ã¹ãã¼ã«
# EPEL, Remi ãªãã¸ããªè¿½å yum install epel-release rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm yum --enablerepo=remi update remi-release vim /etc/yum.repos.d/epel.repo # [epel ã®enable = 1 ãã0 ã«å¤æ´ # PHP ã¤ã³ã¹ãã¼ã« yum --enablerepo=epel,remi,remi-php70 install php php-gd php-mbstring php-mysqlnd php-opcache
PHP-FPM ã¤ã³ã¹ãã¼ã«
Nginxã§PHPãå®è¡ããããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãã¾ãã
yum --enablerepo=remi,remi-php70 install php-fpm cp -a /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.org vi /etc/php-fpm.d/www.conf # ä¿®æ£ç®æ listen = /var/run/php-fpm/php-fpm.sock user = nginx group = nginx listen.owner = nginx listen.group = nginx listen.mode = 0660 # èµ·å sytemctl start php-fpm.service systemctl enable php-fpm.service
NginxããPHPãåãã
vi /etc/nginx/conf.d/default.conf # 以ä¸è¨è¿° server { root /var/www/html; listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /var/www/html; index index.html index.htm index.php; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # PHP-FPM è¨å® location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
http://192.168.56.xxx/index.phpã«ã¢ã¯ã»ã¹ããã¨ä»¥ä¸ã®ããã«ã表示ããã¾ãã
MariaDB ã¤ã³ã¹ãã¼ã«
yum install mariadb mariadb-server # èµ·åè¨å® systemctl start mariadb.service systemctl enable mariadb.service # ç¢ºèª systemctl status mariadb.service # è¨å® vi /etc/my.cnf.d/server.cnf # 以ä¸è¿½å [client] default-character-set = utf8mb4 vi /etc/my.cnf.d/client.cnf # 以ä¸è¿½å [server] character-set-server = utf8mb4 # è¨å®ã®åæ systemctl restart mariadb.service
MariaDBã«DBä½æ
- ãã¼ã¿ãã¼ã¹ : kirIndb
- ã¦ã¼ã¶ : kirIn
- ãã¹ã¯ã¼ã : kirInpass
mysql -u root -p # ãã¹ã¯ã¼ããæã¤ããã«è¨ããã¾ãããEnter ãã¼ãæ¼ãã¾ãã # ã³ã³ã½ã¼ã«ã«ä»¥ä¸å 容ãè¨è¿° MariaDB [(none)]> GRANT ALL PRIVILEGES ON kirIndb.* TO kirIn@localhost IDENTIFIED BY 'kirInpass'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> CREATE DATABASE kirIndb CHARACTER SET utf8; MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | kirIndb | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.01 sec) MariaDB [(none)]> exit
WordPress ã¤ã³ã¹ãã¼ã«
# nginxè¨å® vi /etc/nginx/conf.d/default.conf # 以ä¸å 容 server { root /var/www/html; listen 80; server_name localhost; index index.html index.htm index.php; #try_files $url $url/ /index.php; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { # WordPress ãã¼ããªã³ã¯è¨å®ãå©ç¨å¯è½ã«ãã if (!-e $request_filename) { rewrite ^.+?(/wp-.*) $1 last; rewrite ^.+?(/.*\.php)$ $1 last; # ããã¥ã¡ã³ãã«ã¼ããã WordPress ã¾ã§ã®ç¸å¯¾ãã¹ # (ããã¥ã¡ã³ãã«ã¼ãã«ã¤ã³ã¹ãã¼ã«ããããç¸å¯¾ãã¹ã¯è¨å ¥ãªã) rewrite ^ /index.php last; } } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # PHP-FPM è¨å® location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # åèªã¿è¾¼ã¿ systemctl restart nginx systemctl restart php-fpm
wp-cli ã¤ã³ã¹ãã¼ã«
cd /root curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar # ã¤ã³ã¹ãã¼ã«ç¢ºèª php wp-cli.phar --info # wp ã³ãã³ãã§ä½¿ç¨å¯è½ã«ãã(å®è¡æ¨©éä»ä¸ã¨ãã¹ãéã) chmod +x wp-cli.phar mv wp-cli.phar /usr/local/bin/wp # wp ã³ãã³ã使ç¨ç¢ºèª wp --info # worepress ãã¦ã³ãã¼ã wp core config --dbname=kirIndb --dbuser=kirIn --dbpass=kirInpass --locale=ja --extra-php <<PHP > define('WP_POST_REVISIONS', 3); > PHP # Wordpress åæè¨å® wp core install --url=http://192.168.56.121/ --title=ex --admin_user=kirIn --admin_password=kirInpass [email protected] # ç¢ºèª wp user list wp option get siteurl wp option get blogname wp option get admin_email
http:192.168.56.xxx/ã«ã¦ã§ããã©ã¦ã¶ã§ã¢ã¯ã»ã¹ããã¨wordpressã§ä½æããããã¼ã ãã¼ã¸ã表示ããã¾ãã