Help us understand the problem. What is going on with this article?

EC2にWordPress構築テストのユーザーデータの個人メモ(nginx + mysql + php7)

More than 1 year has passed since last update.

EC2にWordPress構築テストのユーザーデータの個人メモ

  • nginx(WordPressパーマリンク設定対応)
  • mysql56
  • php7
userdata.sh
#!/bin/bash
sudo yum -y update
sudo yum install -y nginx mysql56-server
sudo yum install -y php70 php70-fpm php70-mbstring php70-mysqlnd

sudo service nginx start
sudo service php-fpm start
sudo service mysqld start

sudo chkconfig nginx on
sudo chkconfig mysqld on
sudo chkconfig php-fpm on

#mysql
mysql -uroot -e "UPDATE mysql.user SET Password = PASSWORD('**********') WHERE User = 'root'"
mysql -uroot -e "DROP USER ''@'localhost'"
mysql -uroot -e "DROP USER ''@'$(hostname)'"
mysql -uroot -e "DROP DATABASE test"

mysql -uroot -e "CREATE DATABASE wordpress"
mysql -uroot -e "GRANT ALL ON wordpress.* to admin@localhost"
mysql -uroot -e "SET PASSWORD FOR admin@localhost=password('**********')"
mysql -uroot -e "FLUSH PRIVILEGES"

#wordpress
cat << EOF > ~/wordpress.conf
server {
  listen 80;
  server_name *.example.com;
  server_name ~^\d+\.\d+\.\d+\.\d+$;
  root        /var/www/html;
  index       index.php;

  charset utf-8;

  location / {
    try_files \$uri \$uri/ @wordpress;
  }

  location ~ \.php$ {
    try_files \$uri @wordpress;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME  /var/www/html\$fastcgi_script_name;
    include fastcgi_params;
  }

  location @wordpress {
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
    fastcgi_param SCRIPT_FILENAME  /var/www/html/index.php;
    include       fastcgi_params;
  }

  error_page 404 /404.html;
    location = /40x.html {
  }

  error_page 500 502 503 504 /50x.html;
    location = /50x.html {
  }
}
EOF

sudo mv ~/wordpress.conf /etc/nginx/conf.d/wordpress.conf

wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz

sudo mv wordpress/* /var/www/html/
sudo chown -R apache:apache /var/www/html/
sudo service nginx restart
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした