Monthly Archives: May 2017

Adding PHP to Ubuntu 16.04.02

Adding PHP and extensions for WordPress and Magento

This will install PHP and add the extensions needed for WordPress

# apt -y install php libapache2-mod-php php-mcrypt php-mysql php-mbstring

# vi /var/www/html/info.php

Browsing to your server hostname or IP address with /info.php at the end will show your PHP configuration

This script will show PHP extension status, and in particular extensions needed for Magento

# vi /var/www/html/extensions.php

Browsing to your server hostname or IP address with /extensions.php at the end will show your PHP configuration

This will install and activate the extensions needed for Magento

# apt -y install php-bcmath php-curl php-gd php-intl php-soap php-xml php-zip
# systemctl restart apache2

Note: php-xml includes xml, simplexml & xsl

Browsing to your server hostname or IP address with /extensions.php at the end will show your PHP configuration

# vi /etc/php/7.0/apache2/php.ini ## uncomment/change the following lines

# systemctl restart apache2

Thanks!
-Yehuda

Adding MySQL to Ubuntu 16.04.02

Installation of MySQL to a DigitalOcean Ubuntu 16.04.02 Server

# apt install -y mysql-server mysql-client
# mysql_secure_installation

Test root login and MySQL
# mysql -uroot -proot_password

 

WordPress MySQL Configuration

# mysql -uroot -proot_password

Test wordpress login and MySQL
# mysql -uwordpress -pw_password

 

Magento MySQL Configuration

# mysql -uroot -proot_password

Test magento login and MySQL
# mysql -umagento -pm_password

This may need to be set higher than 16MB for larger product numbers

 

Configuring for MySQL WorkBench remote access

# vi /etc/mysql/mysql.conf.d/mysqld.cnf

 

Remote access from any host

Open firewall to any host
# ufw allow proto tcp from any to any port 3306

Remote access from specific host

Open firewall to specific host
# ufw allow proto tcp from 192.168.1.50 to any port 3306

Thanks!
-Yehuda

Adding Apache2 to Ubuntu 16.04.02

Initial installation of Apache2 to a DigitalOcean Ubuntu 16.04.02 Server is fast and easy

# apt install apache2
# apache2ctl configtest
# vi /etc/apache2/apache2.conf

# apache2ctl configtest
# systemctl restart apache2

One last thing before testing, let’s open up the firewall

# ufw allow proto tcp from any to any port 80,443

Browsing to the server hostname or IP address you should see a screen that starts out like this:

Configuring Apache VirtualHosts

I like to make a new directory for the virtual hosts

# cd /; mkdir www

Make the following changes

# vi /etc/apache2/apache2.conf

Move index.php to be first

# vi /etc/apache2/mods-enabled/dir.conf

# systemctl restart apache2

Copy the virtual host file

# cd /etc/apache2/sites-available
# cp -a 000-default.conf name-of-virtual.openuptown.net.conf

Make appropriate changes

# vi name-of-virtual.openuptown.net.conf

Enable the site

# a2ensite name-of-virtual.openuptown.net.conf

Reload Apache and bam!

# systemctl restart apache2

Thanks!
-Yehuda

openUptown changes to Ubuntu 16.04.02

Building Ubuntu servers on DigitalOcean

openUptown’s development and production servers have been changed from CentOS 6.x to Ubuntu 16.04.02 LTS. I have also converted one of my Windows 10 desktops to Ubuntu Gnome 16.04.02. The desktop and the LAMP configuration portion of the servers I will cover in another post.

openUptown servers are virtual machines hosted on DigitalOcean servers in Toronto. Toronto because it’s closest to Chicago and the USA is getting crazier every day. You’ll notice you can pay by the hour which can be very useful.

If you would like to test this out, here’s a signup link that will give you $10 free credit. Note you do have to enter a valid credit card to activate, but you can cancel before the $10 runs out.
https://m.do.co/c/0f84cad763bc

Installing Ubuntu is a very pain free process. Pick the details of the droplet you want. There are 2 points I will make before you click on ‘Create’.

  • It is very easy to scale the droplet up. It is not as easy to scale down. Once your initial droplet is created, you can scale it up and back down without changing the HD size. If you scale up the HD size, you cannot scale it back down and will be stuck at that level.
  • The hostname should be a fully qualified domain name (FQDN) if you would like to address the server by name rather than IP address. This can be changed later too.

With these decisions made, click on ‘Create’. When created select the ‘More’ dropdown on the right side of the droplet list, and then ‘Access console’. Login as root with the password emailed to you, change the password when prompted etc.

To update the system to the newest software for your version, type from a root prompt:
# apt update
# apt -y upgrade

Set the timezone:
# timedatectl set-timezone America/Chicago

Add yourself as a new user:
# adduser yourlogin

Disable root logins:
# vi /etc/ssh/sshd_config

# service ssh restart

When I install new operating systems, the first thing I am concerned with is access. No access or limited access for others, and full for me. There is a lot one can do here, but I am just going to cover the basics.

Enable the Firewall with SSH and check status

# ufw app list
# ufw allow OpenSSH ## OR the next line is better if you have a predictable IP address
# ufw allow proto tcp from 192.168.1.50 to any port 22 ## substitute your IP
# ufw enable
# ufw status numbered

Install the FTP Server

# apt install vsftpd
# vi /etc/vsftpd.conf

# ufw allow 21 ## OR the next line is better if you have a predictable IP address
# ufw allow proto tcp from 192.168.1.50 to any port 21 ## substitute your IP

# systemctl restart vsftpd

Note, there is much more that can be done to add security with the configuration of the Firewall and Secure Shell. The above is basic, but highly effective.

OK, stay tuned for the next installment installing Apache, MySQL and PHP.

Thanks!
-Yehuda