You are on page 1of 25

PART3 :INSTALLATION OF A DYNAMIC WEBSITE

Deploying a dynamic website through WordPress on Google Cloud Platform


involves setting up a robust online presence. After initiating the creation of a
virtual machine instance on Google Cloud, the deployment and configuration
process is managed through various tools and services provided by the
platform. Utilizing SSH for secure communication, administrators gain
comprehensive control over the Ubuntu virtual machine, facilitating seamless
management and optimization of the WordPress-powered dynamic website.
This integration of Google Cloud's infrastructure allows for a scalable and
efficient hosting solution for dynamic web content.

The commands used :

sudo apt-get update

This command initiates the update of the package index on a Debian-based Linux system. By
executing "sudo apt-get update," the system administrator ensures that the package manager
retrieves the latest information about available software packages from the configured
repositories. This process is a crucial prerequisite for any subsequent software installations or
system upgrades, as it guarantees that the package manager is aware of the most recent
versions and dependencies, facilitating a secure and up-to-date environment.
sudo apt-get upgrade

This command facilitates the upgrading of installed packages on a Debian-based Linux system.
By executing "sudo apt-get upgrade," administrators ensure that their system is equipped with
the latest versions of installed software, incorporating bug fixes, feature enhancements, and
security updates. This proactive approach to package management contributes to the overall
stability and security of the system, aligning it with the latest improvements provided by the
software repositories.
sudo apt install php libapache2-mod-php php-mysql

Executing this command installs PHP and its essential components on a Debian-based Linux
system. The "sudo apt install php libapache2-mod-php php-mysql" command includes the core
PHP package, the Apache module for PHP (libapache2-mod-php), and the PHP extension for
MySQL (php-mysql). Together, these components enable the system to interpret and execute
PHP code, facilitating dynamic content generation for web applications. Additionally, the
integration of the MySQL extension ensures seamless connectivity between PHP and MySQL,
supporting the development of robust and database-driven web applications.

sudo apt install mysql-server -y

This command automates the installation of the MySQL server on a Debian-based Linux system,
bypassing any interactive prompts by including the "-y" flag. By running "sudo apt install mysql-
server -y," administrators streamline the installation process, and MySQL, a powerful relational
database management system, is set up on the system. This lays the groundwork for storing and
managing data, providing a foundation for various web applications and services that rely on a
relational database backend.

sudo mysql_secure_installation

Executing this command initiates the MySQL secure installation process on a Debian-based Linux
system. The "sudo mysql_secure_installation" command guides administrators through a series of
security-related configurations for the MySQL server. It typically includes steps such as setting a
root password, removing anonymous user accounts, disallowing remote root login, and
removing test databases. By running this command, administrators enhance the security posture
of their MySQL installation, mitigating potential vulnerabilities and ensuring that the database
server is configured in a more robust and secure manner.
sudo systemctl enable mysql

This command enables the MySQL service to start automatically on boot on a Debian-based
Linux system. By executing "sudo systemctl enable mysql," administrators ensure that MySQL is
set to initiate during the system's startup process. This contributes to the system's reliability, as it
guarantees that the MySQL service is available without manual intervention, making it easier to
maintain continuous and uninterrupted database operations.
sudo systemctl status mysql

This command retrieves the current status of the MySQL service on a Debian-based Linux
system. By executing "sudo systemctl status mysql," administrators can access information about
whether the MySQL service is active, its uptime, and any relevant status messages. This
command is valuable for real-time monitoring and troubleshooting, providing insights into the
operational health of the MySQL service and aiding administrators in identifying and resolving
potential issues.

sudo mysql -u root -p

CREATE USER 'groupe10'@'%' IDENTIFIED BY '1234';

GRANT ALL ON *.* TO 'groupe10'@'%';

FLUSH PRIVILEGES;

exit;

This sequence of commands initiates a MySQL session using the "sudo mysql" command,
granting administrative access to the MySQL command-line interface. Within this MySQL session,
the "CREATE USER 'groupe10'@'%' IDENTIFIED BY '1234';" command creates a new MySQL user
named 'groupe10' with the password '1234' and allows connections from any host ('%').
Subsequently, "GRANT ALL ON *.* TO 'groupe10'@'%';" provides this user with full privileges on
all databases and tables. The "FLUSH PRIVILEGES;" command ensures that the changes take
effect immediately, and the "exit;" command concludes the MySQL session. This sequence is
commonly used to create a MySQL user with specific privileges, enhancing security and access
control for database operations.
sudo mysql

This command starts the MySQL command-line client with elevated privileges, typically as the
root user. You'll be prompted to enter the MySQL user's password to access the MySQL shell.

UNINSTALL COMPONENT "file://component_validate_password";

This SQL statement is used to uninstall the validate_password component from MySQL. The
validate_password component is responsible for enforcing password strength policies, and this
command effectively removes it. Note that this is optional and depends on your specific
requirements for password policy enforcement.

exit;
sudo apt install phpmyadmin

This command installs phpMyAdmin, a web-based administration tool for managing MySQL
databases, on a Debian-based Linux system. By executing "sudo apt install phpmyadmin,"
administrators simplify the process of interacting with MySQL databases through a user-friendly
web interface. Once installed, phpMyAdmin can be accessed through a web browser, allowing
users to perform various database management tasks, such as executing queries, managing
tables, and importing/exporting data. This tool facilitates database administration and is
particularly useful for users who prefer a graphical interface over the command line for
interacting with MySQL databases.
sudo mysql

UNINSTALL COMPONENT "file://component_validate_password";

exit;

sudo phpenmod mbstring

This command enables the "mbstring" module for PHP on a Debian-based Linux system. By
executing "sudo phpenmod mbstring," administrators activate the Multibyte String extension,
which provides enhanced support for handling multibyte character encodings. This module is
crucial for applications that need to work with languages and character sets beyond the basic
ASCII range. Enabling the "mbstring" module ensures that PHP is configured to handle multibyte
strings, which is essential for the proper functioning of many web applications, particularly those
with internationalization requirements.

sudo systemctl reload apache2.service

This command reloads the Apache HTTP Server configuration on a Debian-based Linux system.
By executing "sudo systemctl reload apache2.service," administrators apply any changes made to
the Apache configuration files without interrupting the server's active connections. Reloading the
configuration is a more graceful process compared to restarting the entire Apache service, as it
avoids downtime and ensures a smoother transition when implementing changes to the web
server settings.
sudo systemctl restart apache2

This command restarts the Apache HTTP Server on a Debian-based Linux system. By executing
"sudo systemctl restart apache2," administrators initiate a complete stop and start of the Apache
service. This action applies any recent configuration changes or updates made to the server
settings. While restarting the Apache service briefly interrupts web server operations, it is
necessary for certain changes to take effect and ensures a fresh start with the updated
configurations.

sudo ufw status

This command, "sudo ufw status," is used to check the current status of the Uncomplicated
Firewall (UFW) on a Linux system with administrative privileges. When executed, it provides
information about whether the firewall is active or inactive and displays a list of configured rules.
The Uncomplicated Firewall is a user-friendly interface for managing iptables, the default firewall
management tool in many Linux distributions. By checking the status, administrators can quickly
assess the current state of firewall protection and review any configured rules for network
security.

sudo ufw enable

This command, "sudo ufw enable," is used to activate and enable the Uncomplicated Firewall
(UFW) on a Linux system with administrative privileges. When executed, it turns on the firewall,
applying any configured rules to regulate incoming and outgoing network traffic. Enabling UFW
helps enhance the security of the system by providing a barrier against unauthorized access and
potential threats. Administrators commonly use this command after configuring the firewall rules
to ensure that the defined policies are enforced, thereby safeguarding the system from
unwanted network traffic.
sudo ufw allow 'Apache Full'

This command, "sudo ufw allow 'Apache Full'," adds a rule to the Uncomplicated Firewall (UFW)
to allow incoming traffic on the ports associated with the 'Apache Full' profile. The 'Apache Full'
profile typically opens ports 80 (HTTP) and 443 (HTTPS), enabling web traffic to reach the Apache
web server. By using this command, administrators grant permission for Apache to receive
external connections on both HTTP and HTTPS ports, facilitating the hosting of web content. This
is a common step in configuring the firewall to ensure that the web server is accessible to users
while maintaining a level of security by only allowing specified types of traffic.

sudo ufw allow OpenSSH

This command, "sudo ufw allow OpenSSH," adds a rule to the Uncomplicated Firewall (UFW) to
allow incoming traffic on the default port used by OpenSSH. OpenSSH is a widely used protocol
for secure remote access to servers, and its default port is 22. By executing this command,
administrators permit incoming connections to the OpenSSH server, enabling users to establish
secure shell connections to the system. This is a fundamental step in configuring the firewall to
ensure that SSH access is allowed, facilitating remote administration and secure communication
with the server.

sudo ufw status


cd /tmp

This command, "cd /tmp," changes the current working directory to the "/tmp" directory. The
"/tmp" directory is commonly used for temporary storage of files on Unix-like operating systems.
It allows users and applications to create and manipulate files in a location where temporary data
can be stored and accessed easily. Changing to this directory is often a preliminary step before
performing operations such as downloading or extracting files during various system tasks.

curl -0 https://wordpress.org/latest.tar.gzc tar xzvf latest.tar.gz

This command performs a two-step operation to download and extract the latest version of
WordPress on a Unix-like system. Here's an explanation:

1. **Download WordPress Archive:**

- `curl -O https://wordpress.org/latest.tar.gz`: The `curl` command is used to download the


latest version of WordPress from the specified URL (`https://wordpress.org/latest.tar.gz`). The `-O`
option tells `curl` to save the file with the same name as the remote file.

2. **Extract the Tarball:**

- `tar xzvf latest.tar.gz`: The `tar` command is then used to extract the contents of the
downloaded tarball. The options `xzvf` are used to decompress (`x`), extract (`v` for verbosity), and
specify the compression format (`z` for gzip) of the tarball. The file being extracted is
"latest.tar.gz."

In summary, this command efficiently fetches the latest WordPress archive and extracts its
contents in the current working directory. It is a common sequence of commands for setting up a
WordPress installation on a server.
sudo cp -R wordpress /var/www/html/work

t The command you've provided is a Linux/Unix command using the `sudo` (superuser do)
command to copy the contents of the "wordpress" directory to "/var/www/html/work"
recursively. Here's a breakdown of the command:

- `sudo`: This command is used to execute another command with elevated privileges. It stands
for "superuser do." You may be prompted to enter your password when using `sudo` unless your
user has been configured to run certain commands without a password prompt.

- `cp`: This is the copy command in Unix/Linux. It is used to copy files or directories.

- `-R`: This flag stands for "recursive," and it is used to copy directories and their contents
recursively. Without this flag, the `cp` command would only copy the specified directory, not its
contents.

- `wordpress`: This is the source directory you want to copy.

- `/var/www/html/work`: This is the destination directory where you want to copy the contents of
the "wordpress" directory.

So, in summary, this command is copying the contents of the "wordpress" directory to the
"/var/www/html/work" directory with elevated privileges. Make sure to double-check the paths
and permissions to ensure a successful copy.

sudo chown -R www.data:www.data /var/www/html/work


It looks like there is a syntax issue in the command you provided. The correct syntax for the
`chown` command is as follows:
```bash

sudo chown -R www.data:www.data /var/www/html/work

```

Here's a breakdown of the command:

- `sudo`: Execute the command with superuser privileges.

- `chown`: Change ownership of files and directories.

- `-R`: Recursively change ownership for all files and subdirectories.

- `www.data:www.data`: Set the user and group ownership to "www.data" for the specified path.

- `/var/www/html/work`: The path to the directory whose ownership you want to change.

After running this command, the ownership of all files and directories under
"/var/www/html/work" will be set to the user "www.data" and the group "www.data." Make sure
the user and group "www.data" exist on your system before using this command. If they don't
exist, you may need to create them first.

sudo chmod -R 775 /var/www/html/work

. The command you provided is:

```bash

sudo chmod -R 775 /var/www/html/work

```

Here's a breakdown of the command:


- `sudo`: Execute the command with superuser privileges.

- `chmod`: Change file permissions.

- `-R`: Recursively change permissions for all files and subdirectories.

- `775`: The permission mode you're setting. In octal notation, it corresponds to read (4), write (2),
and execute (1) permissions for the owner (7), read and execute permissions for the group (5),
and read and execute permissions for others (5).

This command sets the permissions of all files and directories under "/var/www/html/work" to
775. The owner has read, write, and execute permissions, the group has read and execute
permissions, and others have read and execute permissions.

Make sure this permission setting aligns with the security requirements of your system and the
specific needs of your web server and application. The 775 permissions are relatively permissive,
so use them cautiously to avoid security risks.

cd

The "cd" command, when used without any arguments, takes the user back to their home
directory. This is a quick way to navigate to the default directory associated with the user
account. Upon executing "cd," the system will automatically switch the current working directory
to the home directory, providing a clean and familiar starting point for various command-line
operations.

cd /var/www/html/

The command `cd /var/www/html/` is used to change the current working directory to
"/var/www/html/". This directory is a common location for serving web content on many Linux
systems, and it's often the default root directory for web servers like Apache.
By changing to this directory, you can navigate to the location where web server files are
typically hosted. This is often the directory where you would place the files of a website or web
application, such as the WordPress files you may have moved there in the previous steps.

sudo mv wp-config-sample.php wp-config.php

This command will effectively rename the file "wp-config-sample.php" to "wp-config.php" in the
specified directory. Make sure to check permissions and ownership after the operation to ensure
everything is configured correctly.

sudo vim wp-config.php

. The command `sudo vim wp-config.php` opens the file "wp-config.php" for editing using the
Vim text editor with superuser (root) privileges.

Here's what each part of the command does:

- `sudo`: Execute the command with superuser privileges.

- `vim`: Launch the Vim text editor.

- `wp-config.php`: The file you want to open for editing.

Vim is a powerful text editor with a steep learning curve if you're not familiar with it. If you're new
to Vim, here are some basic commands to navigate and edit the file:

- To start editing, press `i` to enter insert mode.

- To save changes and exit, press `Esc` to exit insert mode, then type `:wq` and press `Enter`.

- If you want to exit without saving changes, press `Esc`, then type `:q!` and press `Enter`.
Remember, Vim has various commands and modes, so it might take some time to get used to if
you're not familiar with it. If you're uncomfortable using Vim, you can use a different text editor
by replacing `vim` with your preferred editor, such as `nano` or `gedit`.

sudo vim /etc/apache2/sites-available/work.conf

`.The command `sudo vim /etc/apache2/sites-available/work.conf` opens the file "work.conf" for
editing using the Vim text editor with superuser (root) privileges. This assumes that the Apache
configuration file "work.conf" is located in the "/etc/apache2/sites-available/" directory.

As with the previous example, when you use Vim:

- Press `i` to enter insert mode, allowing you to make changes to the file.

- Once you've made your changes, press `Esc` to exit insert mode.

- To save changes and exit, type `:wq` and press `Enter`.

- To exit without saving changes, type `:q!` and press `Enter`.

If you're not comfortable with Vim, you can use other text editors. For example, to edit the file
using the nano editor, you can use:

```bash

sudo nano /etc/apache2/sites-available/work.conf

```

In nano, you can use the arrow keys to navigate, make changes, and then press `Ctrl + X` to exit,
`Y` to confirm changes, and `Enter` to save.

Then we modify the existed code and type our identity rachacha1234!
And use this <VirtualHost *:80>

ServerName work

ServerAdmin racha@localhost

DocumentRoot /var/www/html/work

Errorlog ${APACHE_LOG_DIR}/error.log

Customlog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

sudo vim /etc/apache2/apache2.conf

The command sudo vim /etc/apache2/apache2.conf opens the main configuration file for the
Apache web server, typically found at "/etc/apache2/apache2.conf," using the Vim text
editor with superuser (root) privileges.

As before:

 Press i to enter insert mode and make changes.


 Press Esc to exit insert mode.
 To save changes and exit, type :wq and press Enter.
 To exit without saving changes, type :q! and press Enter.

This file contains global configuration settings for the Apache web server. Be cautious
when making changes to this file, as they can have a significant impact on your web
server's behavior.

Then we modify the end of text and write this

# Add ServerName

ServerName localhost
apachectl -t

"The command `apachectl -t` is used to check the syntax of your Apache configuration files.
Specifically:

- `apachectl`: This is the Apache control command. It is used to control and configure Apache
HTTP server.

- `-t`: This option is used to test the configuration file syntax without restarting the Apache
server.

When you run `apachectl -t`, it will check the syntax of your Apache configuration files and report
whether there are any syntax errors. This is useful to validate your configuration changes before
attempting to restart the Apache server, as syntax errors could prevent it from starting.
If the syntax is correct, you will typically see a message like "Syntax OK." If there are errors, it will
provide information about the errors, allowing you to fix them before restarting the server.

Example:

```bash

sudo apachectl -t

```

Remember to use `sudo` if you need superuser privileges to read the Apache configuration files.
sudo a2ensite work.conf

. The command `sudo a2ensite work.conf` is used to enable an Apache site configuration file.
Specifically:

- `sudo`: Execute the command with superuser privileges.

- `a2ensite`: A command provided by Apache on Debian-based systems (like Ubuntu) to enable a


site configuration.

- `work.conf`: The name of the site configuration file you want to enable.

This command creates a symbolic link from the site configuration file in the `/etc/apache2/sites-
available/` directory to the `/etc/apache2/sites-enabled/` directory. The `sites-enabled` directory
contains the active site configurations that Apache will use.

After running this command, you usually need to reload or restart the Apache server for the
changes to take effect. You can do this with the following command:

```bash

sudo systemctl reload apache2

```

Replace `apache2` with the actual name of the Apache service if it differs on your system.

sudo systemctl reload apache2

. The command `sudo systemctl reload apache2` is used to reload the configuration of the
Apache web server without stopping and restarting the service. When you make changes to the
Apache configuration files or enable/disable virtual hosts, you often need to reload the
configuration for the changes to take effect.

Here's a breakdown of the command:

- `sudo`: Execute the command with superuser privileges.

- `systemctl`: A command-line utility used to control the systemd system and service manager.

- `reload`: Tells systemd to reload the configuration of the specified service (`apache2` in this
case).

After running this command, Apache will attempt to reload its configuration, applying any recent
changes. If there are syntax errors in your configuration files, Apache will report an error, and you
might need to fix the configuration before successfully reloading.

Note: If the command doesn't work or you encounter issues, make sure that your system is using
systemd as the init system, and the Apache service is named `apache2`. If your system uses a
different init system or the Apache service has a different name, adjust the command
accordingly.

sudo service apache2 restart

. The command `sudo service apache2 restart` is used to restart the Apache web server on
systems that use the "service" command for service management. Here's a breakdown of the
command:

- `sudo`: Execute the command with superuser privileges.

- `service`: A command-line tool for managing services on Unix-based systems.

- `apache2`: The name of the service you want to manage, in this case, the Apache web server.
This command stops and then starts the Apache service, effectively restarting it. After executing
this command, any configuration changes you made will take effect, and the server will be
reloaded with the updated settings.

Keep in mind that the specific service management commands may vary depending on the Linux
distribution and init system in use. The `service` command is commonly used on older systems
with the SysV init system. On more modern systems using systemd, you might use `systemctl
restart apache2` instead.

Finqlly we type in the browser ipadress/work

Type continue

Then we fill in the boxes choose site title ;username;and password


Last step login in our wordpress

You might also like