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.
|
yum groupinstall “Web Server” “PHP Support” “MySQL Database server” “MySQL Database client”
|
|
yum install php-mysql
|
|
service httpd start
systemctl start httpd
|
- Set Apache to automatically start on boot
|
chkconfig httpd on
systemctl enable httpd
|
|
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’
|
|
/usr/bin/mysql_secure_installation
|
Creating a database for WordPress
|
mysql -uroot -pYourPassword
or
mysql –user=root –password=YourPassword
|
|
create database wordpressdb;
|
|
grant all privileges on wordpressdb.* to ‘wordpressdb’@’localhost’ identified by ‘YOURNEWPASS’;
|
|
flush privileges;
|
|
exit;
|
Installing WordPress
- Change directory to /root
|
cd /root
|
|
wget http://wordpress.org/latest.tar.gz
if wget not available, install it by
yum install wget
|
|
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
|
|
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
|