Install WordPress on your LAMP server - CentOS
Time: 15 minutes
Installing WordPress on a server is more complicated than installing it on a shared hosting account. There are no automatic installers, so you have to do everything manually. However, with this guide you should be able to get WordPress up and running in about 15 minutes.
To use this article, you need to have a LAMP stack installed on your server:
We also recommend setting up an Apache virtual host for the domain name you want to use, which includes pointing your domain name to it:
Create a MySQL database and user
- Log into your MySQL admin account:
sudo mysql -u root -p
- At the prompt, enter the MySQL root password you chose:
Note: If you do not remember your root MySQL password, you can reset your root MySQL password.
- Create a new MySQL database:
CREATE DATABASE your wordpress database;
- Create a new MySQL user and password:
CREATE USER your username@localhost;
- Set the password for this new user. Make sure to use a safe passwword:
SET PASSWORD FOR your username@localhost= PASSWORD("your password");
- Grant all privileges to this new user:
GRANT ALL PRIVILEGES ON your wordpress database.* TO your username@localhost IDENTIFIED BY 'your password';
- Confirm that the changes to this user are properly applied:
SHOW GRANTS FOR 'your username'@'localhost';If the changes worked, you should see an output that looks something like this:GRANT USAGE ON *.* TO 'your username'@'localhost' IDENTIFIED BY PASSWORD '*977FDAC11B3F74324912DA4F9D489A3E6D59B281'If the changes did not apply properly, refresh the MySQL cache and try again:
GRANT ALL PRIVILEGES ON `your wordpress database`.* TO 'your username'@'localhost'FLUSH PRIVILEGES;SHOW GRANTS FOR 'your username'@'localhost';
- Once you confirm that the changes worked, exit MySQL:
You are ready to download and install WordPress.
- Navigate to your virtual host directory for the domain name:
cd your domain's Apache virtual host directory
Note: If you didn't set up a virtual host directory, you can use
- Ensure this directory the correct permissions settings:
sudo chmod -R 755 your domain's Apache virtual host directory
- Download the latest version of WordPress:
sudo wget http://wordpress.org/latest.tar.gz
- Extract the WordPress files:
sudo tar xvzf latest.tar.gz
- Move these files into the current directory:
sudo mv ./wordpress/* .
- Give the Apache user ownership of these files:
sudo chown -R apache:apache your domain's Apache virtual host directory
- Remove the unused
wordpressdirectory and the install package:sudo rmdir wordpresssudo rm latest.tar.gz
Configure and Install WordPress
You are now ready to start setting up your WordPress files for installation. You will start by connecting your WordPress files to the MySQL database you created earlier in this guide. This section of the guide will be done in your web browser.
- Enter your server's domain name or public IP address in your web browser.
http://your domain name or IP
- Choose your language, then click Continue.
- Click Let's go!.
- Fill in the fields for your database information. These are the MySQL credentials you created earlier. For the hostname, use
localhost. For the Table Prefix, you can keep the default of
wp_, but it is often a better security practice to use a short, randomly generated prefix such as wQ2z_.
- Click Submit. This creates your
wp-config.phpfile, which contains your database connection strings.
- Click Run the install to begin installing WordPress.
- Fill out the information for your Site Title, your WordPress administrator username and password, and the email address for that user.
- Click Install WordPress.
You can now log in by clicking Log in, or by navigating to http://your domain name or IP/wp-admin.
You have installed WordPress on your server and you are now ready to start building with WordPress. For additional configuration options, or for information on how to start using WordPress, check out the official WordPress documentation.