How to Host WordPress Site on Linux Server

1. Login via Putty to access the server via SSH: https://clients.activeservers.in/knowledgebase/257/How-to-Connect-to-a-Linux-Server-Using-PuTTY-Step-by-Step-Guide.html

2. Update the Server: 

  • sudo yum update –y 

3. Install a Web Server: 

https://clients.activeservers.in/knowledgebase/283/How-to-Install-Apache-in-Linux-Server.html 

4. Install PHP and Extensions:

  • WordPress requires PHP. Install it with:  

        sudo yum install php php-mysqlnd php-curl php-gd php-mbstring php-xml php-xmlrpc –y 

 

5. Install and Configure MySQL:

https://clients.activeservers.in/knowledgebase/286/How-to-Install-MySQL-Database-on-a-Linux-Server.html 

6. Download and Configure WordPress: 

  • Navigate to the web root: cd /var/www/html 

  • Download and extract WordPress:  

        sudo wget https://wordpress.org/latest.tar.gz 

        sudo tar -xvzf latest.tar.gz (If you encountered tar command not found then install tar package using: sudo yum install tar -y) 

        sudo mv wordpress/* . 

        sudo rm -rf wordpress latest.tar.gz 

 

  • Set correct permissions: 

         sudo chown -R apache /var/www/html 

         sudo chmod -R 755 /var/www/html 

7. Configure WordPress:  

  • Rename the sample configuration file:   

        sudo cp wp-config-sample.php wp-config.php

  • Edit the file:  

        sudo nano wp-config.php

  • Update the database details:  

          You can update these details using the commands CTRL + \ and add the text you want to replace and then press ENTER. 

          After that add the text, you want to put instead of the earlier text and again press ENTER.  

          Save and exit (CTRL+X, Y, Enter).

8. Configure Apache:  

  • For Apache, create a Virtual Host file:  

     sudo nano /etc/httpd/conf.d/wordpress.conf

  • Add: 

      <VirtualHost *:80>  

      ServerAdmin [email protected]  

      DocumentRoot /var/www/html  

      <Directory /var/www/html/>  

       AllowOverride All 

      DirectoryIndex index.php 

      Require all granted 

      </Directory> 

     <Directory /var/www/html/wp-content> 
        Options FollowSymLinks 
        Require all granted 
    </Directory>

    ErrorLog /var/log/httpd/dynamic_error.log  

    CustomLog /var/log/httpd/dynamic_access.log combined 

    </VirtualHost>

Restart Apache: sudo systemctl restart httpd (While restarting the Apache if you are encountering some error then kindly check the syntax using the following command: sudo apachectl configtest) 

Note:  

You need to know that to run Apache we need to allow the port: 80 for it. Here’s how you can do it. 

  • We uncommented the Listen 80 line. Run this command sudo nano /etc/httpd/conf/httpd.conf and uncomment the last line or replace it. 

     Restarted Apache using: sudo systemctl restart httpd 

     Apache started successfully! 

After successfully running all the command and following all the right steps, if WordPress still not working on the browser, then, 

     We ran: httpd -S to check the VirtualHost configuration. 

     Found conflicting entries in multiple config files like: 

     /etc/httpd/conf.d/wordpress.conf 

     /etc/httpd/conf.d/linux.codetowebsite.com.com.conf 

    Two Virtual Host blocks were defined for the same domain/port, which caused Apache to serve the wrong directory. 

So, what we did, we move all WordPress files to the actual active Document Root. What you can do is Delete or rename the conflicting file and restart the apache. 

  • Wordpress, linux
  • 0 用戶發現這個有用
這篇文章有幫助嗎?

相關文章

Backup restoration

Since backups are saved at various nodes to avoid data loss, we manage the backup and...

How To allow SQL Express traffic in windows firewall

Please follow the below steps to allow SQL express communication in the firewall. Open SQL...

How to change SQL authentication in SQL Express

Please follow the below steps Login to SQL Express using SQL management studio. Right-click...

Set Up Sending of Email in Plesk

To Set Up Sending of Email in Plesk, You need to follow the below Points   1. Go to Tools...

How to check Port status of VPS

It may possible that the firewall has blocked a few ports and it is not accessible.  To check...