Wordpress

Quickly Install WordPress on Ubuntu

Here are the general steps to install WordPress on Ubuntu:

  1. Install LAMP stack: LAMP stands for Linux, Apache, MySQL, and PHP. These are the core components needed to run WordPress. You can install them by running the following command:
sudo apt-get update
sudo apt-get install lamp-server^

2. Configure MySQL: After installing LAMP, you need to configure MySQL to work with WordPress. You can do this by running the following command:

sudo mysql_secure_installation

3. Create a database for WordPress: You will need to create a database for WordPress to store its data. You can do this by running the following command:

sudo mysql -u root -p
CREATE DATABASE wpdb;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON wpdb.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
exit;
  1. Download and extract WordPress: You can download the latest version of WordPress from their official website. After downloading it, extract the files to the Apache web root directory /var/www/html.
  2. Configure WordPress: You will need to configure WordPress to use the database you created earlier. Rename the wp-config-sample.php file to wp-config.php and update the database name, username, and password.
  3. Set permissions: To allow WordPress to create files and directories, you need to set the correct permissions on the Apache web root directory. You can do this by running the following command:
wget https://tw.wordpress.org/latest-zh_TW.tar.gz
sudo tar -xzvf latest-zh_TW.tar.gz
sudo rm -rf html 
sudo mv wordpress html
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

7. Install additional PHP modules: WordPress requires some additional PHP modules to function properly. You can install them by running the following command:

sudo apt-get install php-curl php-gd php-mbstring php-xml php-xmlrpc

  1. Restart Apache: After making changes to Apache or PHP, you need to restart the Apache web server to apply the changes. You can do this by running the following command:
sudo systemctl restart apache2

After following these steps, you should be able to access your WordPress site by going to your server’s IP address or domain name in a web browser.

To install the Apache SSL mod in Ubuntu, you can follow these steps:

Update your Ubuntu package list:

sudo apt update

Install the Apache SSL mod:

sudo apt install apache2 openssl
sudo a2enmod ssl
sudo systemctl restart apache2
  1. Generate a self-signed SSL certificate:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
  1. Configure Apache to use the SSL certificate: Create a new configuration file for the SSL virtual host:
sudo nano /etc/apache2/sites-available/default-ssl.conf

And add the following lines to the file:

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin webmaster@localhost
                ServerName example.com
                DocumentRoot /var/www/html

                SSLEngine on
                SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
                SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
        </VirtualHost>
</IfModule>
  1. Enable the SSL virtual host:
sudo a2ensite default-ssl.conf
sudo systemctl restart apache2

Now you should be able to access your Apache server using HTTPS protocol.

iDempeire ERP Contributor, 經濟部中小企業處財務管理顧問

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *