{"id":16794,"date":"2025-04-04T19:14:00","date_gmt":"2025-04-04T17:14:00","guid":{"rendered":"https:\/\/tremhost.com\/blog\/?p=16794"},"modified":"2025-04-04T19:14:00","modified_gmt":"2025-04-04T17:14:00","slug":"how-to-install-wordpress-on-a-vps","status":"publish","type":"post","link":"https:\/\/tremhost.com\/blog\/how-to-install-wordpress-on-a-vps\/","title":{"rendered":"How to install WordPress on a VPS"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><h1>How to Install WordPress on a VPS<\/h1>\n<p>Installing WordPress on a Virtual Private Server (VPS) gives you greater control, customization, and scalability compared to shared hosting. This guide will walk you through the process, whether you\u2019re using a Linux-based VPS with a LAMP stack (Linux, Apache, MySQL, PHP) or a similar environment.<\/p>\n<hr \/>\n<h2>1. Set Up Your Server Environment<\/h2>\n<h3>a. Update Your System<\/h3>\n<p>Log in to your VPS via SSH and update your package lists:<\/p>\n<pre><code class=\"language-bash\">sudo apt update &amp;&amp; sudo apt upgrade -y\r\n<\/code><\/pre>\n<h3>b. Install Apache, MySQL, and PHP (LAMP Stack)<\/h3>\n<p>For Ubuntu or Debian-based systems, run:<\/p>\n<pre><code class=\"language-bash\">sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-cli php-curl php-gd php-mbstring php-xml php-xmlrpc -y\r\n<\/code><\/pre>\n<p><em>Tip:<\/em> If you prefer Nginx, install and configure it accordingly.<\/p>\n<h3>c. Secure MySQL<\/h3>\n<p>Run the security script to set a root password and remove insecure defaults:<\/p>\n<pre><code class=\"language-bash\">sudo mysql_secure_installation\r\n<\/code><\/pre>\n<hr \/>\n<h2>2. Create a Database for WordPress<\/h2>\n<h3>a. Log into MySQL<\/h3>\n<pre><code class=\"language-bash\">sudo mysql -u root -p\r\n<\/code><\/pre>\n<h3>b. Create the Database and User<\/h3>\n<p>Inside the MySQL shell, run:<\/p>\n<pre><code class=\"language-sql\">CREATE DATABASE wordpress_db DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;\r\nCREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_strong_password';\r\nGRANT ALL ON wordpress_db.* TO 'wp_user'@'localhost';\r\nFLUSH PRIVILEGES;\r\nEXIT;\r\n<\/code><\/pre>\n<p>Replace <code>your_strong_password<\/code> with a secure password.<\/p>\n<hr \/>\n<h2>3. Download and Configure WordPress<\/h2>\n<h3>a. Download WordPress<\/h3>\n<p>Navigate to the web root directory (commonly <code>\/var\/www\/html<\/code>) and download WordPress:<\/p>\n<pre><code class=\"language-bash\">cd \/var\/www\/html\r\nsudo wget https:\/\/wordpress.org\/latest.tar.gz\r\nsudo tar -xzf latest.tar.gz\r\nsudo rm latest.tar.gz\r\n<\/code><\/pre>\n<p>This extracts WordPress into a folder called <code>wordpress<\/code>.<\/p>\n<h3>b. Configure Permissions<\/h3>\n<p>Set the correct ownership and permissions:<\/p>\n<pre><code class=\"language-bash\">sudo chown -R www-data:www-data \/var\/www\/html\/wordpress\r\nsudo find \/var\/www\/html\/wordpress -type d -exec chmod 755 {} \\;\r\nsudo find \/var\/www\/html\/wordpress -type f -exec chmod 644 {} \\;\r\n<\/code><\/pre>\n<h3>c. Create the WordPress Configuration File<\/h3>\n<p>Copy the sample configuration file:<\/p>\n<pre><code class=\"language-bash\">cd wordpress\r\nsudo cp wp-config-sample.php wp-config.php\r\n<\/code><\/pre>\n<p>Edit <code>wp-config.php<\/code>:<\/p>\n<pre><code class=\"language-bash\">sudo nano wp-config.php\r\n<\/code><\/pre>\n<p>Replace the following lines with your database details:<\/p>\n<pre><code class=\"language-php\">define( 'DB_NAME', 'wordpress_db' );\r\ndefine( 'DB_USER', 'wp_user' );\r\ndefine( 'DB_PASSWORD', 'your_strong_password' );\r\ndefine( 'DB_HOST', 'localhost' );\r\n<\/code><\/pre>\n<p>Save and exit (Ctrl+O, Enter, Ctrl+X).<\/p>\n<hr \/>\n<h2>4. Configure Apache (or Nginx) for WordPress<\/h2>\n<h3>For Apache Users:<\/h3>\n<h4>a. Create a Virtual Host File<\/h4>\n<p>Create a new Apache configuration file:<\/p>\n<pre><code class=\"language-bash\">sudo nano \/etc\/apache2\/sites-available\/wordpress.conf\r\n<\/code><\/pre>\n<p>Insert the following configuration (adjust paths and domain as needed):<\/p>\n<pre><code class=\"language-apache\">&lt;VirtualHost *:80&gt;\r\n    ServerAdmin admin@example.com\r\n    ServerName yourdomain.com\r\n    DocumentRoot \/var\/www\/html\/wordpress\r\n\r\n    &lt;Directory \/var\/www\/html\/wordpress&gt;\r\n        Options FollowSymLinks\r\n        AllowOverride All\r\n        Require all granted\r\n    &lt;\/Directory&gt;\r\n\r\n    ErrorLog ${APACHE_LOG_DIR}\/wordpress_error.log\r\n    CustomLog ${APACHE_LOG_DIR}\/wordpress_access.log combined\r\n&lt;\/VirtualHost&gt;\r\n<\/code><\/pre>\n<p>Save and exit.<\/p>\n<h4>b. Enable the Site and Rewrite Module<\/h4>\n<pre><code class=\"language-bash\">sudo a2ensite wordpress.conf\r\nsudo a2enmod rewrite\r\nsudo systemctl restart apache2\r\n<\/code><\/pre>\n<h3>For Nginx Users:<\/h3>\n<h4>a. Create a Server Block File<\/h4>\n<pre><code class=\"language-bash\">sudo nano \/etc\/nginx\/sites-available\/wordpress\r\n<\/code><\/pre>\n<p>Insert the following configuration:<\/p>\n<pre><code class=\"language-nginx\">server {\r\n    listen 80;\r\n    server_name yourdomain.com;\r\n    root \/var\/www\/html\/wordpress;\r\n    \r\n    index index.php index.html index.htm;\r\n\r\n    location \/ {\r\n        try_files $uri $uri\/ \/index.php?$args;\r\n    }\r\n\r\n    location ~ \\.php$ {\r\n        include snippets\/fastcgi-php.conf;\r\n        fastcgi_pass unix:\/var\/run\/php\/php7.4-fpm.sock; # Adjust PHP version if needed\r\n    }\r\n\r\n    location ~ \/\\.ht {\r\n        deny all;\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>Save and exit.<\/p>\n<h4>b. Enable the Server Block and Restart Nginx<\/h4>\n<pre><code class=\"language-bash\">sudo ln -s \/etc\/nginx\/sites-available\/wordpress \/etc\/nginx\/sites-enabled\/\r\nsudo systemctl restart nginx\r\n<\/code><\/pre>\n<hr \/>\n<h2>5. Complete the WordPress Installation<\/h2>\n<ul>\n<li><strong>Open Your Browser:<\/strong><br \/>\nVisit your domain (e.g., <code>http:\/\/yourdomain.com<\/code>).<\/li>\n<li><strong>Follow the On-Screen Instructions:<\/strong><br \/>\nSelect your language, set up your site title, admin username, password, and email address. Complete the installation by clicking &#8220;Install WordPress.&#8221;<\/li>\n<li><strong>Log In:<\/strong><br \/>\nOnce installed, log into your WordPress dashboard at <code>http:\/\/yourdomain.com\/wp-admin<\/code>.<\/li>\n<\/ul>\n<hr \/>\n<h2>Final Thoughts<\/h2>\n<p>Installing WordPress on a VPS gives you the flexibility and power to manage your website on your own terms. By following these steps, you\u2019ll have a robust, self-hosted WordPress installation ready for customization and growth.<\/p>\n<p>Need further assistance? Many hosting communities and forums can offer additional tips and troubleshooting advice to help you optimize your setup. Enjoy your new WordPress site on your VPS!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Install WordPress on a VPS Installing WordPress on a Virtual Private Server (VPS) gives you greater control, customization, and scalability compared to shared hosting. This guide will walk you through the process, whether you\u2019re using a Linux-based VPS with a LAMP stack (Linux, Apache, MySQL, PHP) or a similar environment. 1. Set Up [&hellip;]<\/p>\n","protected":false},"author":1772,"featured_media":16791,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"tdm_status":"","tdm_grid_status":"","footnotes":""},"categories":[163],"tags":[],"class_list":{"0":"post-16794","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-hosting"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/posts\/16794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/users\/1772"}],"replies":[{"embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/comments?post=16794"}],"version-history":[{"count":2,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/posts\/16794\/revisions"}],"predecessor-version":[{"id":16796,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/posts\/16794\/revisions\/16796"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/media\/16791"}],"wp:attachment":[{"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/media?parent=16794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/categories?post=16794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tremhost.com\/blog\/wp-json\/wp\/v2\/tags?post=16794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}