Website

From ElectroDragon
Jump to: navigation, search

Nginx

Steps Details Note
Install apt-get install nginx -
restart service service nginx start -
test Again, like apache2, let's put 127.0.0.1 into the web browser, and see this: Welcome to Nginx.png
Default file root /var/www/html defined at /etc/nginx/sites-enabled/default

Configuration

We're going to start moving about in Linux now. Remember that Linux still has a folder structure - just like any graphical operating system. If you want to learn more about the folder structure of a Linux system - there are some great tutorials and images that can be found through a quick Google search.

Let's move to where nginx stores the sites which it hosts, by using the command:

cd /etc/nginx/sites-enabled 

or try at /etc/nginx/sites-available

And let's edit the file "default", delete everything in it, and copy the following code into it, you can do this with editor like nano or GUI editor:

server { 
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6

root /usr/share/www/example;
index index.php index.html index.htm;

location / {
error_page 404 = 404.html;
}

# Make site accessible from http://localhost/
server_name example.com *.example.com;

location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
}

Build the website

Now, we're actually going to make a little website in the /usr/share/nginx/www/example folder we made earlier.

Let's move to the folder by using the command:

cd /usr/share/nginx/www/example 

We're going to make two files - an index page (homepage), and a 404 page (a page to display if the page a user is trying to access doesn't exist).

Let's first make the index page by using the command:

pico index.html 

If you're familiar with html, at this point type in whatever you want. If you're not, then paste in the following, save and exit (as you did earlier with the nginx configuration file):

<html>
Hello world, this is my first website!
</html> 

Next, do the same for the 404 page by using the command:

pico 404.html 

Paste in the following if unsure:

<html>
Sorry, the page you are looking for doesn't exist!
</html> 

The final step is to make sure that our pages are readable for others by changing the permissions on the files. If we didn't change the permissions, someone accessing your website may be given the 'You are not allowed to view this page' (or equivalent) error generated by nginx.

Use the command:

chmod -R 775 /usr/share/nginx/www/example

Detailed Configuring nginx

The nginx configuration is in /etc/nginx/nginx.conf which we open now:

vi /etc/nginx/nginx.conf

The configuration is easy to understand (you can learn more about it here: http://wiki.nginx.org/NginxFullExample and here: http://wiki.nginx.org/NginxFullExample2)

First (this is optional) adjust the number of worker processes and set the keepalive_timeout to a reasonable value:

[...]
worker_processes  4;
[...]
    keepalive_timeout   2;
[...]

MYSQL

  • enter into shell -> mysql -u root -p
  • Enable log -> set global slow_query_log = 'ON';
  • Set log address -> set global slow_query_log_file ='/var/log/mysql/slow-query.log';

PHP

apt-get install php5-cgi php5-cli php5-mysql

Debug -> vim /etc/php5/fpm/pool.d/www.confMake necessary changes to match following values:

slowlog = /var/log/php5/slow.log
request_slowlog_timeout = 10s

Restart -> service php5-fpm restart

Debug

  • Use wordpress plugin Query Monitor
  • Use WP Debug
/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 */
define('WP_DEBUG', true);
define('SAVEQUERIES', true);

Forum

Type alexa -
flarum 119K -
vanilla 72K -
discourse 35K free - github
phpbb 42K -
nodebb 189K -
smf 69K -
mybb 68K -
fluxbb 661K non-free
IPS Board 44K non-free
xenforo 39K -
woltlab 115K -
vbulletin 67K -

Reference tutorial