Hey there,
We have already setup a server and is now ready with the wordpress. First we must know what actually wordpress, So wordpress is a CMS i.e. Content Management Software. It is built in php and supports a large number of plugins for doing almost every thing. It has plugin from google analytics to privacy policy page.
You do not have to write a single line of code to get your website started. It is as simple as that. You can read about it more here on wordpress. So lets get started with the wordpress installation.
- SSH into your AWS server by running.
ssh -i keyfile.pem ubuntu@your_server_ip - Go to directory you want to install wordpress it will be generally /var/www/wesite_name and run
wget http:
//wordpress.org/latest.tar.gz
tar xfz latest.tar.gz - You have downloaded the latest version and extracted it.
- Now you want a mysql server running.
sudo apt-get install mysql-server - If you are facing error with mysql installation try this digital ocean article.
- Now we need to create a database for wordpress to connect with.
mysql -u username -p - Then enter your passoword and create schema by using the below commands
create schema database_name; - Check, you are still in that directory where you installed wordpress. Now run
mv wordpress/* ./ - It will move the file from extracted folder to your root folder.
- Now the extracted directory and .tar file that was downloaded.
- Open wp-config.php in edit mode and change the database name host and other credentials in that file.
vi wp-config.php - Now try opening your public URL given. What it did not open ? Yes because we have not told nginx where to find the files to serve.
- We have Nginx installed but we do not have php to process .php files. We need to install those.
sudo apt-get install php5-fpm php5-mysql - Now we have php installed just restart the server by using
sudo service nginx restart - Again if you open in browser it will show the same error its because of that only. We need to tell nginx to serve file from.
- Open nginx config settings.
sudo vi /etc/nginx/sites-available/default - We are editing the default file which is already linked to the sites-enabled directory.
- Now add these line to tell the server you directory.
server { listen 80; root /usr/share/nginx/www; index index.php index.html index.htm; server_name example.com; location / { try_files $uri $uri/ /index.html; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on the php-fpm socket location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
- Now for permission run these commands and these will fix all the permissions.
chown -R www-data:www-data your-wordpress-directory
sudo find /var/www/wordpress/ -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \; - Now restart the nginx server and open public ip in your browser you will see the wordpress settings page.
- Enter the setting and your wordpress site is up.
If you have any problem anywhere setting up or any error is coming try searching on google or stackoverflow cause this is where i learn everything.
2 COMMENTS
[…] Next step of the tutorial is live. Start reading it. […]
[…] Setting up WordPress Blog with aws and nginx: part 2 […]