How to Install WordPress with LAMP on CentOS 7
WordPress is an open source and most widely used software for blogging, content management software, websites etc. It’s written in PHP and used MySQL/MariaDB for database.
Done!!! Now follow the further instruction to complete initial setup of WordPress.
This article describes How to Install WordPress with LAMP on CentOS7.
Step 1. LAMP Stack Installation: Follow the article Howto Install the LAMP (Linux, Apache, MySQL/MariaDB and PHP) Stack on CentOS 7. Due to WordPress recommendation php 5.6.x or higher version is required, follow the article Howto Install PHP 7.3 Latest Version on CentOS 7.
# yum install –enablerepo=remi-php73 php Loaded plugins: fastestmirror ……………………. Installed: php.x86_64 0:7.3.15-1.el7.remi Dependency Installed: libargon2.x86_64 0:20161029-3.el7 php-cli.x86_64 0:7.3.15-1.el7.remi php-common.x86_64 0:7.3.15-1.el7.remi php-json.x86_64 0:7.3.15-1.el7.remi Complete! # |
# yum install –enablerepo=remi-php73 php-mysqlnd Loaded plugins: fastestmirror ……………………. Installed: php-mysqlnd.x86_64 0:7.3.15-1.el7.remi Dependency Installed: php-pdo.x86_64 0:7.3.15-1.el7.remi Complete! # |
Step 2. Database Configuration: Create a database and a user for WordPress to access that database:
Run the following commands to create a database:
# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 12 Server version: 5.5.64-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement. MariaDB > create database wordpress; Query OK, 1 row affected (0.00 sec) MariaDB > |
Create a User and grant all privileges on wordpress database:
MariaDB > grant all privileges on wordpress.* to wordpress@localhost identified by ‘w0rdpr$55’; Query OK, 0 rows affected (0.03 sec) MariaDB > flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB > quit Bye # |
Step 3. WordPress Installation: Download the WordPress from the official site and copy it the web server document directory:
Run the following command to install php-gd wordpress prerequisites:
# yum install –enablerepo=remi-php73 php-gd Loaded plugins: fastestmirror ……………………. Installed: php-gd.x86_64 0:7.3.15-1.el7.remi Dependency Installed: dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 fontconfig.x86_64 0:2.13.0-4.3.el7 fontpackages-filesystem.noarch 0:1.44-8.el7 gd-last.x86_64 0:2.2.5-10.el7.remi jbigkit-libs.x86_64 0:2.0-11.el7 libtiff.x86_64 0:4.0.3-32.el7 libwebp7.x86_64 0:1.0.3-1.el7.remi Complete! # |
Download WordPress from it official site:
# cd /tmp # curl -O % Total % Received % Xferd Average Speed<
span style="mso-spacerun: yes;"> Time Time Time Current Dload Upload Total Spent Left Speed 100 11.8M 100 11.8M 0 0 384k 0 0:00:31 0:00:31 –:–:– 591k # ls -ltrh latest.tar.gz -rw-r–r–. 1 root root 12M Feb 27 22:10 latest.tar.gz # |
Unzip the file and copy the contents to the web document root directory:
# tar -xzvf latest.tar.gz ………………………. wordpress/wp-admin/post-new.php wordpress/wp-admin/themes.php wordpress/wp-admin/options-reading.php wordpress/wp-trackback.php wordpress/wp-comments-post.php # cd wordpress/ # cp -r * /var/www/html/ # cd /var/www/html/ # ls index.php readme.html wp-admin wp-comments-post.php wp-content wp-includes wp-load.php wp-mail.php wp-signup.php xmlrpc.php license.txt wp-activate.php wp-blog-header.php wp-config-sample.php wp-cron.php wp-links-opml.php wp-login.php wp-settings.php&nbs p; wp-trackback.php # |
Step 4. WordPress Configuration: Follow the below steps to configure WordPress:
Create a folder on the below path to store uploaded data:
# mkdir -p wp-content/uploads # |
Now set the correct ownership and permission on the WordPress files and directories:
# chown -R apache:apache * # |
Make a copy of WordPress configuration and update the parameters for database configuration as below:
# cp -p wp-config-sample.php wp-config.php # vi wp-config.php <?php ……………………….. /** The name of the database for WordPress */ define( ‘DB_NAME’, ‘wordpress’); /** MySQL database username */ define( ‘DB_USER’, ‘wordpress’ ); /** MySQL database password */ define( ‘DB_PASSWORD’, ‘w0rdpr$55’ ); …&hellip ;…………………. # |
Run the following command to restart the httpd service to reflect all the above changes;
# systemctl restart httpd # |
Step 5. Verify the Installation:Finally, browse the URL http://<Server IP Address/Hostname> to access the WordPress configuration page and further configuration as shown in below screen shot:
Done!!! Now follow the further instruction to complete initial setup of WordPress.