Disclaimer

This blog is kind of my own personal work Notebook, and the processes below are only guaranteed to work for my specific configurations. So, use this info at your own risk, and please understand I won't be able to provide any help if you break something

Thursday, August 24, 2023

Installing a local WordPress development environment on Manjaro

Installing a local WordPress development environment on Manjaro (or any other Linux distribution) typically involves setting up a LAMP (Linux, Apache, MySQL, PHP) or LEMP (Linux, Nginx, MySQL, PHP) stack and then installing WordPress on top of it. 

How to set up a LAMP stack and WordPress on Manjaro: 

1. Update System:

First, make sure your system is updated:

sudo pacman -Syu

2. Install Apache:

sudo pacman -S apache

Start and enable Apache:

bash
sudo systemctl start httpd sudo systemctl enable httpd

You can check if Apache is working by opening your browser and visiting http://localhost. You should see the Apache test page.

3. Install MariaDB (MySQL):

sudo pacman -S mariadb

After installation, you need to initialize the MariaDB data directory:

css
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Then, start and enable the MariaDB service:

bash
sudo systemctl start mariadb sudo systemctl enable mariadb

Secure your installation:

sudo mysql_secure_installation

You'll be asked a series of questions. For a local development environment, you can often hit enter to choose the default options, but make sure to set a strong root password.

4. Install PHP:

sudo pacman -S php php-apache

Now, you need to modify the Apache configuration to use PHP. Edit /etc/httpd/conf/httpd.conf:

bash
sudo nano /etc/httpd/conf/httpd.conf

Find and uncomment the line that says:

bash
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Then, further down, find and uncomment:

shell
#LoadModule php7_module modules/libphp7.so

and add the following below it:

bash
Include conf/extra/php7_module.conf

Restart Apache to apply the changes:

sudo systemctl restart httpd

5. Install WordPress:

First, navigate to a directory where you want to download WordPress. Typically, this might be inside /srv/http/.

Download the latest WordPress:

bash
cd /srv/http/ sudo wget https://wordpress.org/latest.tar.gz sudo tar -xvf latest.tar.gz

You might want to rename the resulting WordPress directory for convenience.

6. Create a Database for WordPress:

Log in to MariaDB:

css
mysql -u root -p

Then:

sql
CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'your_password'; FLUSH PRIVILEGES; EXIT;

7. Configure WordPress:

Navigate to the WordPress directory and rename wp-config-sample.php to wp-config.php. Then edit the file:

arduino
cd wordpress sudo cp wp-config-sample.php wp-config.php sudo nano wp-config.php

Find the following lines and fill in the details:

sql
define('DB_NAME', 'wordpress'); define('DB_USER', 'wordpressuser'); define('DB_PASSWORD', 'your_password'); define('DB_HOST', 'localhost');

Now, navigate to http://localhost/wordpress (or the directory name you chose) in your web browser and complete the WordPress installation.

That's it! Your LAMP stack is now set up on Manjaro with WordPress!. Adjust configurations as needed based on your specific development requirements.

How to set up a LAMP stack and WordPress on Manjaro: 

Setting up a LEMP (Linux, Nginx, MySQL, PHP) stack on Manjaro and then installing WordPress on top of it involves the following steps:

1. Update System:

Make sure your system is updated:

sudo pacman -Syu

2. Install Nginx:

sudo pacman -S nginx

Start and enable Nginx:

bash
sudo systemctl start nginx sudo systemctl enable nginx

To confirm Nginx is working, open a browser and go to http://localhost. You should see the Nginx welcome page.

3. Install MariaDB (MySQL):

sudo pacman -S mariadb

Initialize the MariaDB data directory:

css
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Start and enable the MariaDB service:

bash
sudo systemctl start mariadb sudo systemctl enable mariadb

Secure the installation:

sudo mysql_secure_installation

Follow the on-screen prompts, setting a root password and making selections appropriate for your environment.

4. Install PHP and PHP-FPM:

sudo pacman -S php php-fpm

Start and enable PHP-FPM:

bash
sudo systemctl start php-fpm sudo systemctl enable php-fpm

5. Configure Nginx for PHP:

Edit the default Nginx server block or create a new configuration file:

arduino
sudo nano /etc/nginx/conf.d/default.conf

Add or modify the location block for PHP:

nginx
location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

Restart Nginx to apply the changes:

sudo systemctl restart nginx

6. Install WordPress:

Navigate to Nginx's default web directory or your chosen directory:

bash
cd /usr/share/nginx/html

Download the latest WordPress:

arduino
sudo wget https://wordpress.org/latest.tar.gz sudo tar -xvf latest.tar.gz

If you'd like, you can move the contents of the wordpress directory to the root of your web directory.

7. Create a Database for WordPress:

Log in to MariaDB:

css
mysql -u root -p

Create the WordPress database and user:

sql
CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'your_password'; FLUSH PRIVILEGES; EXIT;

8. Configure WordPress:

Navigate to the WordPress directory (if you didn't move the files, this would be inside a wordpress subdirectory) and rename wp-config-sample.php to wp-config.php:

arduino
cd wordpress sudo cp wp-config-sample.php wp-config.php sudo nano wp-config.php

Update the database details:

sql
define('DB_NAME', 'wordpress'); define('DB_USER', 'wordpressuser'); define('DB_PASSWORD', 'your_password'); define('DB_HOST', 'localhost');

Finally, navigate to http://localhost/wordpress in your browser and complete the WordPress installation steps.

Your LEMP stack is now set up on Manjaro with WordPress! Adjust configurations as necessary based on your specific requirements.

No comments:

Post a Comment