I'm trying to set up a WordPress site in Compute Engine with Nginx and Cloud SQL. I have setup an instance with Ubuntu 18.0 and install the Nginx and WordPress by using the following commands:
- $ sudo apt update
- $ sudo apt install nginx
- sudo apt-get install php-fpm php-mysql
- sudo nano /etc/php/7.2/fpm/php.ini
- and change
cgi.fix_pathinfo=0
inphp.ini
- sudo systemctl restart php7.2-fpm
- sudo nano /etc/nginx/sites-available/default
and setup like this:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name COMPUTE_ENGINE_INSTANCE_STATIC_IP;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
- sudo nginx -t and it returns
success
message. - sudo systemctl reload nginx
- sudo apt-get install php-curl php-gd php-mbstring php-mcrypt php-xml php-xmlrpc
- sudo systemctl restart php7.2-fpm
- cd /tmp
- curl -O https://wordpress.org/latest.tar.gz
- tar xzvf latest.tar.gz
- cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
- mkdir /tmp/wordpress/wp-content/upgrade
- sudo cp -a /tmp/wordpress/. /var/www/html
- sudo adduser root www-data
- sudo chown -R kimseasok:www-data /var/www/html
- sudo chmod -R g+rwX /var/www/html
Now, when I try to access my instance IP it returns this error:
502 Bad Gateway
nginx/1.14.0 (Ubuntu)
What's wrong here?
Help me, please!
Thanks in advance!