Tuncay Sahin

ICT Engineer | Docent ICT & Trainer

This document describes the steps to get WordPress running on a Linux Server, for example Cent OS. It assumes that  the Linux Server is already installed and preconfigured (networking, updates etc.)

Installing the LAMP stack LAMP

(Linux, Apache, MySQL and PHP) stack is a group of open source software used to get websites with databases running. The Linux part is not taken in this document.

Login with SSH root privileges to your Linux server and follow the instructions below.

  • Install the LAMP stack

yum groupinstall “Web Server” “PHP Support” “MySQL Database server” “MySQL Database client”

  • Add PHP-MySQL support

yum install php-mysql

  • Start Apache

service httpd start

systemctl start httpd

  • Set Apache to automatically start on boot

chkconfig httpd on

systemctl enable httpd

  • Start MySQL

service mysqld start

systemctl start mysqld

  • Set MySQL to automatically start on boot

chkconfig mysqld on

systemctl enable mysqld

  • To set a password for the MySQL root user.

mysqladmin -u root password ‘new-password’

  • Or run wizard to set a MySQL root password. This will guide you through a wizard. Say Yes to all the options.

/usr/bin/mysql_secure_installation

Creating a database for WordPress

  • Access the MySQL shell

 mysql -uroot -pYourPassword

or

mysql –user=root –password=YourPassword

  • Create a database

create database wordpressdb;

  • Set permissions

grant all privileges on wordpressdb.* to ‘wordpressdb’@’localhost’ identified by ‘YOURNEWPASS’;

  • Activate permissions

flush privileges;

  • Exit the MySQL shell

exit;

Installing WordPress

  • Change directory to /root

cd /root

  • Download WordPress

wget http://wordpress.org/latest.tar.gz

if wget not available, install it by

yum install wget

  • Extract WordPress

tar -xvzf /root/latest.tar.gz -C /target/directory

  • Sync the extracted files to your DocumentRoot

rsync -avz wordpress/ /var/www/

if rsync not available, install it by

yum install rsync

  • Remove the wordpress source files

rm latest.tar.gz
rm -rf wordpress/

  • Create the WordPress config file by copying from the sample file

cp /var/www/wp-config-sample.php /var/www/wp-config.php

  • Set the database credentials in /var/www/wp-config.php

sed -i ‘s/database_name_here/your-db/’ /var/www/wp-config.php

sed -i ‘s/username_here/your-username/’ /var/www/wp-config.php

sed -i ‘s/password_here/your-password/’ /var/www/wp-config.php

sed -i ‘s/localhost/your-dbserver/’ /var/www/wp-config.php

Secure your site by setting the correct permissions

 

  • Set Apache user as the owner for your DocumentRoot

chown -R apache:apache /var/www/html/yoursite

  • Modify permissions

chmod -R 400 /var/www/html/yoursite

chmod -R a+X /var/www/html/yoursite

WordPress requires write access into the /wp-content folder to could install plugings, themes or updates.

Provide write permissions to WordPress

chmod -R 775 /var/www/html/yoursite/wp-content

Meer informatie

Voor meer informatie of voor een persoonlijk adviesgesprek kunt u altijd vrijblijvend contact met mij opnemen.

E-Mail

info@tuncaysahin.nl