Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":2632,"date":"2019-12-06T19:08:36","date_gmt":"2019-12-06T19:08:36","guid":{"rendered":"https:\/\/support.aklwebhost.com\/?post_type=manual_kb&p=2632"},"modified":"2019-12-06T19:08:36","modified_gmt":"2019-12-06T19:08:36","slug":"how-to-install-wordpress-on-a-lemp-configuration","status":"publish","type":"manual_kb","link":"https:\/\/support.aklwebhost.com\/knowledgebase\/how-to-install-wordpress-on-a-lemp-configuration\/","title":{"rendered":"How To Install WordPress on a LEMP Configuration"},"content":{"rendered":"

Introduction<\/h3>\n

In this tutorial, you’ll learn how to install WordPress on a freshly created instance. I’ll demonstrate the installation on an Ubuntu 14.04 server. These instructions may also work on older versions of Ubuntu and Debian.<\/p>\n

So, let’s start.<\/p>\n

Step One: Update existing packages<\/h3>\n
apt-get update && apt-get upgrade\r\n<\/code><\/pre>\n

Step Two: Install Nginx<\/h3>\n

Nginx is a high performance lightweight web server designed with the purpose of delivering large amounts of static content with efficient use of system resources. In contrast to Apache, Nginx uses an asynchronous event-driven model which provides more predictable performance under load.<\/p>\n

Let’s add a third-party repository to install the latest version of Nginx (1.6.1).<\/p>\n

sudo apt-get install python-software-properties\r\nadd-apt-repository -y ppa:rtcamp\/nginx\r\nsudo apt-get update \r\nsudo apt-get install nginx\r\nservice nginx start\r\n<\/code><\/pre>\n

Now, let’s test if the server is up and running.<\/p>\n

http:\/\/YOUR-VPS-IP\r\n<\/code><\/pre>\n

It should take you to Nginx’s default landing page.<\/p>\n

Step Three: Install PHP 5.5<\/h3>\n

PHP is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.<\/p>\n

Let’s install the latest version of PHP on our server.<\/p>\n

sudo add-apt-repository ppa:ondrej\/php5\r\nsudo apt-get update\r\nsudo apt-get install php5-common php5-mysqlnd php5-xmlrpc php5-curl php5-gd php5-cli php5-fpm php-pear php5-dev php5-imap php5-mcrypt\r\n<\/code><\/pre>\n

If you want to check your PHP version, run the following command:<\/p>\n

php -v\r\n<\/code><\/pre>\n

You will see something like this.<\/p>\n

PHP 5.5.16-1+deb.sury.org~trusty+1 (cli) (built: Aug 25 2014 10:24:59)\r\nCopyright (c) 1997-2014 The PHP Group\r\nZend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies\r\nwithZendOPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies\r\n<\/code><\/pre>\n

Now, we’ll make a slight configuration change to make our setup more secure. Open the main php5-fpm configuration file with root privileges:<\/p>\n

sudo nano \/etc\/php5\/fpm\/php.ini\r\n<\/code><\/pre>\n

Press\u00a0Ctrl+W<\/strong>\u00a0and search for\u00a0cgi.fix_pathinfo=<\/code>. Uncomment it (delete \ud83d\ude09 and change 1 to 0. After changes, the line should look like this:<\/p>\n

cgi.fix_pathinfo=0\r\n<\/code><\/pre>\n

Save (Ctrl+O<\/strong>) and close the file (Ctrl+X<\/strong>).<\/p>\n

Now, we just need to restart our PHP processor by typing:<\/p>\n

sudo service php5-fpm restart\r\n<\/code><\/pre>\n

Step Four: Install MySQL<\/h3>\n

To store and manage databases, we need to install MySQL. You can easily install it by typing the following in the console:<\/p>\n

sudo apt-get install mysql-server\r\n<\/code><\/pre>\n

During the installation process, you will be asked to set a root password for MySQL. Once you have set the root password, we will have to tell MySQL to generate the directory structure where it will store databases.<\/p>\n

sudo mysql_install_db\r\n<\/code><\/pre>\n

Let’s finish it up by running a security script that will modify some default insecurities.<\/p>\n

sudo mysql_secure_installation\r\n<\/code><\/pre>\n

Just type the MySQL root password and type\u00a0n<\/code>\u00a0if you don\u2019t want to change it. After that, type\u00a0y<\/code>\u00a0to every question.<\/p>\n


\n

Set Timezone (conditional)<\/h3>\n

By default, the timezone of your server is UTC. If you’re living in a different timezone, you can change it by typing in the following command:<\/p>\n

sudo dpkg-reconfigure tzdata\r\n<\/code><\/pre>\n
\n

At this point, your LEMP server is up and running.<\/p>\n

Step Five: Configuring Nginx to serve WordPress<\/h3>\n

Let’s start our WordPress installation by creating an Nginx server block for our site.<\/p>\n

sudo nano \/etc\/nginx\/sites-available\/wordpress\r\n<\/code><\/pre>\n

Paste the following code there:<\/p>\n

server {\r\n        listen 80;\r\n\r\n        root \/var\/www\/wordpress;\r\n        index index.php index.html index.htm;\r\n\r\n        server_name domain.com;\r\n\r\n        error_page 404 \/404.html;\r\n\r\n        error_page 500 502 503 504 \/50x.html;\r\n        location = \/50x.html {\r\n                root \/usr\/share\/nginx\/html;\r\n        } \r\nlocation \/ {\r\n                # try_files $uri $uri\/ =404;\r\n                try_files $uri $uri\/ \/index.php?q=$uri&$args;\r\n        }\r\n\r\n\r\n        location ~ \\.php$ {\r\n                try_files $uri =404;\r\n                fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n                fastcgi_pass unix:\/var\/run\/php5-fpm.sock;\r\n                fastcgi_index index.php;\r\n                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n                include fastcgi_params;\r\n        }\r\n\r\nlocation = \/favicon.ico {\r\n        access_log off;\r\n        log_not_found off;\r\n        expires max;\r\n}\r\nlocation = \/robots.txt {\r\n        access_log off;\r\n        log_not_found off;\r\n}\r\n\r\n# Cache Static Files For As Long As Possible\r\nlocation ~*\r\n\\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$\r\n{\r\n        access_log off;\r\n        log_not_found off;\r\n        expires max;\r\n}\r\n# Security Settings For Better Privacy Deny Hidden Files\r\nlocation ~ \/\\. {\r\n        deny all;\r\n        access_log off;\r\n        log_not_found off;\r\n}\r\n# Return 403 Forbidden For readme.(txt|html) or license.(txt|html)\r\nif ($request_uri ~* \"^.+(readme|license)\\.(txt|html)$\") {\r\n    return 403;\r\n}\r\n# Disallow PHP In Upload Folder\r\nlocation \/wp-content\/uploads\/ {\r\n        location ~ \\.php$ {\r\n                deny all;\r\n        }\r\n}\r\n}\r\n<\/code><\/pre>\n

This is a well tuned WordPress configuration file with permalinks support. Save (Ctrl+O<\/strong>) and close the file (Ctrl+X<\/strong>). Let’s enable the server block by symlinking:<\/p>\n

sudo ln -s \/etc\/nginx\/sites-available\/wordpress \/etc\/nginx\/sites-enabled\/wordpress\r\n<\/code><\/pre>\n

Next, we’ll delete the Nginx default server block.<\/p>\n

sudo rm \/etc\/nginx\/sites-enabled\/default\r\n<\/code><\/pre>\n

Now, we’ll tune the main Nginx configuration file:<\/p>\n

sudo nano \/etc\/nginx\/nginx.conf\r\n<\/code><\/pre>\n

Make sure that the number of worker processes is equal to the number of cores in your instance.<\/p>\n

user www-data;\r\nworker_processes 1;\r\npid \/run\/nginx.pid;\r\n<\/code><\/pre>\n

Add\u00a0use epoll;<\/strong>\u00a0to the events block.<\/p>\n

events {\r\nworker_connections 4096;\r\nmulti_accept on;\r\nuse epoll;\r\n}\r\n<\/code><\/pre>\n

Add\u00a0client_max_body_size<\/strong>\u00a0and\u00a0server_tokens<\/strong>\u00a0off directive. Set\u00a0keepalive_timeout<\/strong>\u00a0to 30 seconds.<\/p>\n

        ##\r\n        # Basic Settings\r\n        ##\r\n\r\nsendfile on;\r\ntcp_nopush on;\r\ntcp_nodelay on;\r\nkeepalive_timeout 30;\r\ntypes_hash_max_size 2048;\r\nserver_tokens off;\r\nclient_max_body_size  100m;\r\n\r\n\r\n        # server_names_hash_bucket_size 64;\r\n        # server_name_in_redirect off;\r\n\r\ninclude \/etc\/nginx\/mime.types;\r\ndefault_type application\/octet-stream;\r\n<\/code><\/pre>\n

Make sure that the whole Gzip settings block looks like this:<\/p>\n

        ##\r\n        # Gzip Settings\r\n        ##\r\n\r\ngzip on;\r\ngzip_disable \"msie6\";\r\n\r\ngzip_vary on;\r\ngzip_proxied any;\r\ngzip_comp_level 6;\r\ngzip_buffers 16 8k;\r\ngzip_http_version 1.1;\r\ngzip_types text\/plain text\/css application\/json application\/x-javascript text\/xml application\/xml application\/xml+rss text\/javascript;\r\n<\/code><\/pre>\n

Save (Ctrl+O<\/strong>) and close the file (Ctrl+X<\/strong>). Then restart the server:<\/p>\n

sudo service nginx restart\r\n<\/code><\/pre>\n

Step Six: Configure PHP<\/h3>\n

If you want to upload files more than 2mb to your WordPress site, you have to increase PHP upload size variables in\u00a0php.ini<\/strong>.<\/p>\n

sudo nano \/etc\/php5\/fpm\/php.ini\r\n<\/code><\/pre>\n

Now, press\u00a0Ctrl+W<\/strong>\u00a0and search for “upload_max_filesize<\/strong>” and set it to\u00a0100m<\/strong>.<\/p>\n

upload_max_filesize=100M\r\n<\/code><\/pre>\n

Do the same with\u00a0post_max_size<\/strong>.\u00a0post_max_size<\/strong>\u00a0needs to be the same size or larger than\u00a0upload_max_filesize<\/strong>.<\/p>\n

post_max_size=100M\r\n<\/code><\/pre>\n

Restart PHP.<\/p>\n

sudo service php5-fpm restart\r\n<\/code><\/pre>\n

Step Seven: Setting up the MySQL database<\/h3>\n

In this step, we’ll create the database user and tables. Go ahead and log into the MySQL shell:<\/p>\n

mysql -u root -p\r\n<\/code><\/pre>\n

Log in using your MySQL root password. We will need to create a WordPress database, along with a user in the database. First, let’s make the database (feel free to give it whatever name you like):<\/p>\n

CREATE DATABASE wordpress;\r\nQuery OK, 1 row affected (0.00 sec)\r\n<\/code><\/pre>\n

After that, we need to create a new user. Please replace the database, name, and password with whatever you prefer:<\/p>\n

CREATE USER wordpressuser@localhost;\r\nQuery OK, 0 rows affected (0.00 sec)\r\n<\/code><\/pre>\n

Set a password for your new user:<\/p>\n

SET PASSWORD FOR wordpressuser@localhost= PASSWORD(\"password\");\r\nQuery OK, 0 rows affected (0.00 sec)\r\n<\/code><\/pre>\n

Finish up by granting all privileges to the new user. Without this command, the WordPress installer will not be able to start up:<\/p>\n

GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';\r\nQuery OK, 0 rows affected (0.00 sec)\r\n<\/code><\/pre>\n

Then refresh MySQL:<\/p>\n

FLUSH PRIVILEGES;\r\nQuery OK, 0 rows affected (0.00 sec)\r\n<\/code><\/pre>\n

Exit the MySQL shell:<\/p>\n

exit\r\n<\/code><\/pre>\n

Step Eight: Installing the WordPress files<\/h3>\n

We’re almost done. Let’s proceed to installing WordPress.<\/p>\n

First navigate to the site root directory:<\/p>\n

mkdir \/var\/www\/\r\ncd \/var\/www\/\r\n<\/code><\/pre>\n

Now, download the latest version of WordPress:<\/p>\n

wget http:\/\/wordpress.org\/latest.tar.gz\r\n<\/code><\/pre>\n

Extract it from the archive:<\/p>\n

tar -xzvf latest.tar.gz\r\n<\/code><\/pre>\n

Give the permissions of\u00a0\/var\/www\/wordpress<\/code>\u00a0to\u00a0www-data<\/code>\u00a0user. It will allow future automatic updating of WordPress plugins and file editing with SFTP.<\/p>\n

sudo chown -R www-data:www-data wordpress\/\r\nsudo usermod -a -G www-data www-data\r\n<\/code><\/pre>\n

You\u2019re done! Your new WordPress site is now ready. Just navigate to your website and finish the installation.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[109,110,242,247],"manual_kb_tag":[377],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2632"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2632"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2632\/revisions"}],"predecessor-version":[{"id":2633,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2632\/revisions\/2633"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2632"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2632"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}