LoginSignup
0
1

More than 5 years have passed since last update.

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

Posted at

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
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1