After a whole day working on my site, I finally got it runs.
Here’s some instructions on how you install LAMP and WordPress on your VPS and enabling SSL for your site. And, of course, many problems I’ve faced and the solutions.
I’m using Digital Ocean ubuntu-s-1vcpu-1gb host, and the path and configuration may vary. I would suggest using root user since many of the following commands require sudo permission.
Install LAMP
Update apt and then install Apache.
apt-get update
apt-get install apache2
The Apache configuration file is located at /etc/apache2. And now we can modify the configuration of our site.
nano /etc/apache2/sites-available/000-default.conf
- Set ServerName to your hostname or ip address.
- Set ServerAdmin to your email address.
<VirtualHost *:80>
ServerName yourhostname
ServerAdmin youremailaddress
DocumentRoot /var/www/html
<Directory /var/www/html/wordpress/>
AllowOverride All
</Directory>
Before restart apache you may check the syntax of your configuration file.
apache2ctl configtest
If nothing wrong you should see Syntax OK
.
Trouble shooting
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
It’s OK if you just ignore this but in case you’re an OCD like me, you can run the following command.
echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
Here DON’T replace ServerName with your server name.
Start rewrite and proxy_fcgi module and restart apache.
a2enmod rewrite proxy_fcgi
service apache2 restart
Add access permission to www-data user.
chown -R www-data /var/www/html
/var/www/html is where you gonna put you website files in.
Install MySQL
We use mariadb, an open-source fork of MySQL.
apt-get install mariadb-server
Log in with MySQL root user.
sudo mysql -u root -p
By default, there’s no password for MySQL root user and you definitely wanna change it.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpasswd';
Don’t forget the “;” at the end of every SQL command.
Exit MySQl.
EXIT;
Install PHP
Install php and needed packages.
apt install php-fpm php-mysql php-gd php-curl php-mbstring php-xml php-xmlrpc php-zip
Editing the dir.conf.
nano /etc/apache2/mods-enabled/dir.conf
Move “index.php” to the front so Apache will search for index.php first instead of inex.html.
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Now we can restart Apache.
service apache2 restart
The next post is about WordPress installation