$ sudo apt-get install apache2 apache2-utils
$ sudo systemctl enable apache2
$ sudo systemctl start apache2
$ sudo apt-get install mysql-client mysql-server
During installation it will ask you a passwd, my recommendation use a passwd generator use 20 bits lenght upper/lower case, special chars and digts.
ubuntu@ubuntu-VirtualBox:~$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
I recommend to skip this first part, we have a good passwd.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: ** y**
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) :
... skipping.
This is the interesting part: Please, delete anonymous users
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Also disallow root remote login.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
Of course remove test db
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Then reload the privilege table.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
At this point it's necessary the modules to connect de db and de webserver
$ sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-cli php7.0-cgi php7.0-gd
It's necessary a little test step
$ sudo vi /var/www/html/info.php
Write and save.
<?php
phpinfo();
?>
Go to your browser and write serverip/info.php
It will show you a page with some info about your server.
PHP Version 7.0.32-0ubuntu0.16.04.1 | PHP logo |
---|---|
System | Linux ubuntu x86_64 |
... |
Delete this file from /var/www/html after check its working.
$ wget -c http://wordpress.org/latest.tar.gz
$ tar zxvf latest.tar.gz
$ sudo rsync -av wordpress/* /var/www/html/
The user www-data needs to be the user that manage this files anybody else.
$ sudo chown -R www-data:www-data /var/www/html/
$ sudo chmod -R 755 /var/www/html/
Be sure to delete another file from /var/www/html/ it can make other desire behaviour.
$ mysql -u root -p
Inside this interpreter write:
mysql> CREATE DATABASE wp_myblog;
mysql> GRANT ALL PRIVILEGES ON wp_myblog.* TO your_username_here@localhost IDENTIFIED BY 'passwd';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
$ cd /var/www/html/
$ sudo mv wp-config-sample.php wp-config.php
$ sudo systemctl restart apache2.service
$ sudo systemctl restart mysql.service
Access to your webbrowser server-ip. It will show you the wp-admin/setup-config.php page, first select the language and the first user to enter to Wordpress. Enjoy :)
It can be usefull to write a little file under /var/www/html/ which main function is try to login to your mysql server
<?php
$link = mysqli_connect('localhost', 'user', 'passwd');
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);
?>
Go to your browser and access to server-ip/.php it will show you the state of the connection.
Founts: https://www.tecmint.com/install-wordpress-on-ubuntu-16-04-with-lamp/#