Top Left Text cha

Website Development Services

This is for Ubuntu 16.04/17.10, Nginx, MySQL & PHP (LEMP)

Restart Nginx
sudo systemctl restart nginx
sudo systemctl reload nginx (only reload config file)

Restart PHP
sudo systemctl restart php7.0-fpm

Nginx config file
sudo nano /etc/nginx/nginx.conf

PHP config file
sudo nano /etc/php/7.0/fpm/php.ini

PHP Hosts file (sites-available/default)
sudo nano /etc/nginx/sites-available/default

Check syntax
sudo nginx -t

Firewall Status
sudo ufw status

Extract .tar.gz
sudo tar -xvzf file.tar.gz
optionally add -C destination/
Comment (0) Hits: 29

Install phpMyAdmin
sudo apt-get update
sudo apt-get install phpmyadmin
You'll get asked which system you want to install phpMyAdmin on. Nginx is not an option, so hit tab & enter to skip this.
Next you'll be asked if you want dbconfig-common to configure a database.  

Create a password for phpMyAdmin & it's database.

Create a symbolic link from the phpMyAdmin application to the public folder.
sudo ln -s /usr/share/phpmyadmin /var/www/html

Enable the mcrypt PHP module.
sudo phpenmod mcrypt

Restart PHP
sudo systemctl restart php7.0-fpm

phpMyAdmin is now set up at your domain or IP (ex: example.com/phpmyadmin)

ToADD: create symbolic link for security (obsure /phpmyadmin from public)
Comment (0) Hits: 39
These instructions are specifically for Nginx.  Unlike Apache, Nginx doesn't contain a native PHP processor so PHP-FPM (PHP fastCGI processing manager), so it will need to be installed manually.

Install php-fpm, php-mysql, and other modules that may be needed.  Some of these can be left off if they won't be used.  But if not sure, it won't hurt to install all of them as so...
sudo apt-get install php-fpm php-mysql php-curl php-gd php-pear php-imagick php-imap php-mcrypt php-recode php-tidy php-xmlrpc

Php-fpm will need to be configured.  Open the configuration file and edit with nano.
sudo nano /etc/php/7.0/fpm/php.ini

Find cgi.fix_pathinfo.  It will be commented out with a semicolon like:
;cgi.fix_pathinfo=1

Uncomment it and change the value to 0.  This is required for the security of your PHP files.  It should look like this after:
cgi.fix_pathinfo=0
Save and close the file.

Restart the PHP processor.
sudo systemctl restart php7.0-fpm

Configure Nginx to use the new PHP processor (php-fpm)

Open the Nginx default server configuration file with nano.
sudo nano /etc/nginx/sites-available/default
Below is an example of the most recent block regarding php-fpm in the file.  Don't forget to add index.php to the index...
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name [your ip should be here];

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}


# pass the PHP scripts to FastCGI server listening on ...
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;

# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
Comment (0) Hits: 25
Code samples for installing MySQL on Ubuntu Server via SSH

Install MySQL
sudo apt-get install mysql-server

You'll be asked for a root password that you want to use for the MySQL system.

Secure the installation.
mysql_secure_installation

You'll need to enter the password you supplied for the MySQL system. Then you'll be asked if you want to VALIDATE PASSWORD PLUGIN.  This is optional, but if don't set it up, you should make sure to use secure passwords.  If you do set it up, be sure you don't have anything like software that tries to create DB credentials with non-secure/simple passwords or it will produce errors.  I personally don't set this up, but I make sure that future credentials use secure passwords.

Next you'll be asked if you want to remove anonymous users, the test database, and disable remote logins.  You can usually answer yes to these questions.  Then also enter 'yes' to enable these rules and MySQL will be setup.
Comment (0) Hits: 32
These are the basic commands needed when SSHing into the server to install and configure Nginx.

Update the package manager unless it's already been done.
sudo apt-get update

Install the Nginx package.
sudo apt-get install nginx

If you have UFW(uncomplicated firewall) firewall installed, you'll need to allow connections to Nginx.
sudo ufw allow 'Nginx HTTP'

Verify that it worked.
sudo ufw status
You should see Nginx in the list.

You can test that it worked also by pointing a web browser to the IP or domain (and you should see 'Welcome to nginx!'.

Comment (0) Hits: 32
X