PHP GEOS is a PHP extension for geographic objects support, while RunCloud is a cloud server control panel designed for PHP applications. With PHP GEOS module installed on RunCloud, PHP applications can take advantage of geographic data and use the GEOS (Geometry Engine – Open Source) library to perform spatial operations.
In this blog post, I will show you how to install PHP GEOS module on RunCloud module.
Steps 1. Install the required development tools
Before installing the PHP GEOS module, make sure that the required development tools are installed on your Ubuntu server. You can install them by running the following command:
apt-get install autoconf
2. Install GEOS library Next, download and install the latest GEOS (Geometry Engine – Open Source)
wget http://download.osgeo.org/geos/geos-3.9.4.tar.bz2 tar xvf geos-3.9.4.tar.bz2 cd geos-3.9.4/ ./configure make make install
3. Install PHP GEOS module
Now, it’s time to install the PHP GEOS module. Follow the steps below to install it for PHP 8.2:
# make clean will always fail if you never compile it before make clean /RunCloud/Packages/php82rc/bin/phpize --clean /RunCloud/Packages/php82rc/bin/phpize ./configure --with-php-config=/RunCloud/Packages/php82rc/bin/php-config make && make install
This will install geos.so in the correct php extension directory
4. Add the module to PHP.ini file echo "extension=$MODULE_NAME.so" > /etc/php82rc/conf.d/$MODULE_NAME.ini
And finally restart the PHP FPM service systemctl restart php82rc-fpm
It’s important to note that the above steps are specific to PHP 8.2. If you wish to install the module for a different version, you will need to modify the commands accordingly. For instance, you can replace PHP 8.2 with 8.1 with below changes: Replace /RunCloud/Packages/php82rc/bin/phpize with /RunCloud/Packages/php81rc/bin/phpize, replace ./configure –with-php-config=/RunCloud/Packages/php82rc/bin/php-config with ./configure –with-php-config=/RunCloud/Packages/php81rc/bin/php-config, replace /etc/php82rc/conf.d/$MODULE_NAME.ini with /etc/php81rc/conf.d/$MODULE_NAME.ini, and replace systemctl restart php82rc-fpm with systemctl restart php81rc-fpm.
You can contact me if you need help with installing any custom modules on RunCloud control panel.
Recently, I helped one of my clients who was using an Amazon Lightsail WordPress instance provided by Bitnami. Bitnami is advantageous in that it provides a fully working stack, so you don’t have to worry about configuring LAMP or environments. You can find more information about the Bitnami Lightsail stack here.
However, the client’s stack was using the latest PHP 8.x version, while the WordPress site he runs uses several plugins that need PHP 7.4. I advised the client to consider upgrading the website to support the latest PHP versions. However, since that would require a lot of work, and he wanted the site to be up and running, he decided to downgrade PHP.
The issue with downgrading or upgrading PHP on a Bitnami stack is that it’s not possible. Bitnami recommends launching a new server instance with the required PHP, MySQL, or Apache version and migrating the data over. So, I decided to do it manually.
Here are the server details:
Debian 11 Current installed PHP: 8.1.x
Upgrading or downgrading PHP versions on a Bitnami stack is essentially the same as on a normal Linux server. In short, you need to:
Ensure the PHP packages for the version you want are installed. Update any configuration for that PHP version. Update your web server configuration to point to the correct PHP version. Point PHP CLI to the correct PHP version. Restart your web server and php-fpm.
What we did was install the PHP version provided by the OS. Then, we updated php.ini to use the non-default MySQL socket location used by the Bitnami server. We created a php-fpm pool that runs as the “daemon” user. After that, we updated the Apache configuration to use the new PHP version.
1. Make sure packages for your target version of PHP are installed To make sure that the correct packages are available on your system for the PHP version you want, first make sure your system is up to date by running these commands:
sudo apt update sudo apt upgrade If it prompts you to do anything with config files, usually, you should just go with the default option and leave the current config as-is. Then, install the packages you need. For example, you can use the following command to install common PHP packages and modules: sudo apt install -y php7.4-cli php7.4-dev php7.4-pgsql php7.4-sqlite3 php7.4-gd php7.4-curl php7.4-memcached php7.4-imap php7.4-mysql php7.4-mbstring php7.4-xml php7.4-imagick php7.4-zip php7.4-bcmath php7.4-soap php7.4-intl php7.4-readline php7.4-common php7.4-pspell php7.4-tidy php7.4-xmlrpc php7.4-xsl php7.4-fpm
2. Make sure PHP configuration for your target version is updated Find the mysql socket path used by your Bitnami stack by running this command:
[Pdo_mysql] ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. pdo_mysql.default_socket=
Replace with
[Pdo_mysql] ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. pdo_mysql.default_socket= “/opt/bitnami/mariadb/tmp/mysql.sock”
Feel free to adjust the PHP FPM settings to match your server specifications or needs. Check out this informative article for more tips on optimizing PHP FPM performance. Just keep in mind that Bitnami configures their stack with the listen.owner and listen.group settings set to daemon.
This pool will listen on unix socket “/opt/bitnami/php/var/run/www2.sock”.
Test the installed version by running below command ~# php -v PHP 7.4.33 (cli) (built: Feb 22 2023 20:07:47) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
In today’s digital age, website security is more important than ever. One of the key components of website security is SSL (Secure Sockets Layer). SSL is a protocol for establishing secure, encrypted connections between a web server and a web browser. SSL (Secure Socket Layer) has historically been the standard encryption protocol for secure communication over the internet. However, it has been replaced by TLS (Transport Layer Security) as the standard encryption protocol. Despite this, SSL is still commonly used as a general term to refer to both SSL and TLS. In this article, we’ll explore what SSL is, why it’s important for website security, and how it works.
Definition of SSL SSL is a security protocol that uses encryption to protect data transmitted between a web server and a web browser. SSL ensures that any data transmitted between the two parties is kept confidential, authenticated, and secure from unauthorized access. SSL is often used to secure online transactions, such as e-commerce purchases, online banking, and other sensitive data transmissions.
Importance of SSL in website security Without SSL, data transmitted between a web server and a web browser is sent in plain text, which can be intercepted and read by hackers. SSL helps to prevent this by encrypting the data so that it cannot be intercepted or read. SSL also provides authentication, which ensures that the website being accessed is the genuine website and not a fake website designed to steal data. In addition, SSL provides integrity, which ensures that the data being transmitted has not been tampered with during transmission. SSL helps prevent man-in-the-middle attacks, where an attacker intercepts the data being transmitted and alters it without the knowledge of the sender or receiver.
How SSL Works
Explanation of SSL handshake When a web browser establishes a connection with a web server using SSL, a process called the SSL handshake occurs. During the SSL handshake, the web browser and web server exchange information and establish a secure, encrypted connection. The SSL handshake consists of the following steps:
1. The web browser sends a “hello” message to the web server, along with the SSL version number and the list of encryption algorithms that the browser supports. 2. The web server responds with a “hello” message, along with the SSL version number and the encryption algorithm that will be used for the connection. 3. The web server sends its SSL certificate to the web browser, which contains the public key needed to encrypt data sent to the server. 4. The web browser verifies the SSL certificate and sends a message to the web server to begin encrypting data. 5. The web server responds with a message indicating that it is ready to begin encrypting data.
SSL encryption and decryption process Once the SSL handshake is complete and the secure connection has been established, all data transmitted between the web browser and the web server is encrypted. The data is encrypted using the encryption algorithm negotiated during the SSL handshake. When the encrypted data reaches the web server, it is decrypted using the private key associated with the SSL certificate.
Role of SSL certificates in SSL SSL certificates are an essential component of SSL. SSL certificates are digital certificates that are used to verify the identity of a website and establish a secure, encrypted connection. SSL certificates contain information about the website, such as the domain name, the owner of the website, and the expiration date of the certificate. SSL certificates are issued by trusted third-party certificate authorities (CA) and must be installed on the web server.
In order to obtain an SSL certificate, the website owner must generate a Certificate Signing Request (CSR), which contains information about the website and the public key that will be used for encryption. The CSR is then submitted to a trusted third-party CA, who will verify the website’s identity before issuing the SSL certificate.
Types of SSL Certificates
SSL certificates come in different types, each with different validation requirements and levels of assurance. Here are the most common types:
1. Domain Validated (DV) SSL Certificates Domain Validated (DV) SSL certificates are the most basic type of SSL certificate. They verify that the domain name is registered and under the control of the certificate applicant. DV certificates are easy to obtain and are usually issued within minutes of submitting a certificate signing request (CSR).
To get a DV SSL certificate, you simply need to prove that you own the domain name by responding to an email or uploading a file to your website. DV certificates only provide basic encryption and do not display any company information in the certificate details.
2. Organization Validated (OV) SSL Certificates Organization Validated (OV) SSL certificates offer a higher level of assurance than DV certificates. In addition to validating the domain ownership, OV certificates also verify that the organization applying for the certificate is legitimate and registered to do business.
To obtain an OV SSL certificate, the applicant must provide additional information about their organization, such as business registration documents and legal information. OV certificates display the company name in the certificate details, which can help to build trust with website visitors.
3. Extended Validation (EV) SSL Certificates Extended Validation (EV) SSL certificates are the highest level of SSL certificate and offer the strongest level of assurance. They provide the most visible sign of trust with a green address bar and the company name displayed in the certificate details.
To obtain an EV SSL certificate, the applicant must go through a rigorous validation process that includes verifying the legal, physical, and operational existence of the organization. This process can take several days to complete, but the result is a certificate that provides the highest level of assurance and trust.
EV certificates are typically used by high-profile websites such as banks, e-commerce sites, and government agencies that handle sensitive information.
Besides the standard SSL certificates, some Certificate Authorities (CA’s) also offer Wildcard SSL certificates. These can be used to secure multiple subdomains with a single certificate.
The Process of Getting an SSL Certificate
SSL certificates are issued by a trusted third-party called a Certificate Authority (CA). Getting an SSL certificate involves several steps, including choosing a CA, generating a Certificate Signing Request (CSR), and validating the SSL certificate.
Choosing a Certificate Authority (CA) There are many CAs that offer SSL certificates, including popular options such as Let’s Encrypt, Comodo, DigiCert, and Symantec. When choosing a CA, consider factors such as the level of customer support, pricing, and the types of certificates they offer.
Generating a Certificate Signing Request (CSR) A CSR is a file that contains information about your website and is used to apply for an SSL certificate. To generate a CSR, you will need to have access to your web server and use a tool such as OpenSSL to create the file.
When generating a Certificate Signing Request (CSR), you will need to provide the following information:
Common Name (CN): This is the domain name that you want to secure with SSL. For example, www.example.com.
Organization (O): The legal name of your organization.
Organizational Unit (OU): This is the department within your organization that is responsible for the certificate.
City/Locality (L): The city where your organization is located.
State/Province (ST): The state or province where your organization is located.
Country (C): The two-letter country code where your organization is located.
Email Address: An email address where the Certificate Authority (CA) can contact you if needed.
Make sure to double-check your entries for accuracy as any errors may result in delays in obtaining your SSL certificate.
Here’s how to generate a CSR using OpenSSL:
1. Open a command prompt or terminal app. 2. Run the following command to generate a private key: openssl genrsa -out private.key 2048 3. Run the following command to generate a CSR: openssl req -new -key private.key -out mydomain.csr 4. Follow the prompts to enter the required information, such as your website’s domain name, location, and contact information.
It’s important to keep your private key safe and secure because it is required during the installation of your SSL certificate. If your private key is lost or compromised, your SSL certificate will no longer be valid and you will need to generate a new CSR and request a new SSL certificate.
Validation of the SSL certificate Once you have generated a CSR, you will need to submit the CSR to the Certificate Authority (CA). CA will then needs to verify the SSL request. So, you will need to validate your domain ownership to obtain the SSL certificate. The type of validation required will depend on the type of SSL certificate you have chosen.
a. Domain Validated (DV) SSL Certificates For DV SSL certificates, the CA will only validate that you own the domain for which you are requesting the certificate. There are three methods of domain validation that are commonly used:
Email Validation: The CA will send an email to a predefined email address associated with the domain, such as admin@yourdomain.com, and ask you to click on a link or reply with a code to confirm ownership.
DNS Validation: The CA will ask you to add a specific DNS record to your domain’s DNS settings. This proves that you have control over the domain’s DNS.
HTTP File Upload: The CA will ask you to upload a specific file to your website’s root directory. This proves that you have control over the domain and the website associated with it. b. Organization Validated (OV) SSL Certificates For OV SSL certificates, the CA will perform additional checks to validate the organization’s legal identity, including:
Checking the organization’s business registration documents
Checking the organization’s physical address and phone number
Verifying the organization’s name and the name of the person requesting the certificate
c. Extended Validation (EV) SSL Certificates For EV SSL certificates, the CA will perform the most rigorous checks to validate the organization’s legal identity, including:
Checking the organization’s legal existence and business’s government registration documents
Checking the organization’s physical address and phone number
Verifying the organization’s name and the name of the person requesting the certificate
Conducting a thorough background check on the organization’s reputation and business practices
Once the validation process is complete and the CA will issue the SSL certificate and then the certificate can be installed on the web server.
In addition to purchasing SSL certificates from a CA, some web hosting providers offer free SSL certificates through Let’s Encrypt, a nonprofit CA that provides free SSL certificates to promote web security. This can be an affordable option for website owners who want to ensure their website is secure. You can also install certbot tools and obtain free SSL certificates from Let’s Encrypt if you have a root or SSH access to your server.
Installing an SSL Certificate on Your Server The specific steps for installing an SSL certificate may vary depending on your server or service. Be sure to follow the instructions provided by your certificate authority or web server documentation.
When you receive an SSL certificate for your domain, the Certificate Authority (CA) typically provides a zip file that contains the following files:
SSL certificate: This is the primary certificate that contains your domain name, public key, expiration date, and other details. The certificate may be in different formats, such as .pem, .crt, or .cer. Intermediate certificate(s): These certificates form the chain of trust between the SSL certificate and the root certificate of the CA. They are required for SSL validation and may be included in the SSL certificate itself or provided as separate files. Root certificate: This certificate is at the top of the certificate chain and is used to establish trust. It may or may not be included in the SSL certificate.zip file.
The correct order of installation would be: Domain certificate Intermediate certificate Root certificate
Note that some SSL/TLS certificate providers may bundle the intermediate and root certificates together in a single file. If this is the case, you only need to install the bundled certificate and the domain certificate.
You can find detailed instructions on how to install an SSL certificate on Nginx and Apache by following the links provided.
SSL or Secure Socket Layer is a widely used technology to encrypt the data being transmitted between a web server and a web browser. It provides a secure connection and helps protect against cyber attacks like phishing, data theft, and man-in-the-middle attacks. In this section, we will explore how SSL helps protect against cyber attacks and some best practices for SSL implementation to enhance website security.
How SSL helps protect against cyber attacks:
Data Encryption: SSL encrypts the data being transmitted between the server and the browser, ensuring that the information is protected and cannot be intercepted by third-party attackers.
Authentication: SSL certificates provide authentication to the website, ensuring that the user is connecting to the correct website and not a malicious imposter.
Trustworthiness: SSL certificates are issued by trusted third-party Certificate Authorities (CA), which helps establish the trustworthiness of the website.
SSL best practices for website security:
Use strong encryption algorithms: Always use the latest and most secure encryption algorithms, such as AES 256-bit encryption, to encrypt the data being transmitted.
Keep SSL certificates up-to-date: Regularly update SSL certificates to ensure that they are not expired or revoked.
Implement HTTPS: Always use HTTPS instead of HTTP to secure your website. HTTPS is a protocol that encrypts the data being transmitted over the internet and provides a secure connection.
Common SSL vulnerabilities and how to avoid them:
Weak Encryption: Always use strong encryption algorithms and keep them updated to avoid weak encryption.
Insecure Certificates: Ensure that SSL certificates are issued by trusted third-party Certificate Authorities (CA) to avoid insecure certificates.
Expired Certificates: Regularly update SSL certificates to avoid expired certificates, which can lead to vulnerabilities and cyber attacks.
Conclusion
In summary, SSL is an essential technology for ensuring secure communication between a website and its visitors. It uses a combination of encryption, authentication, and trust mechanisms to protect against eavesdropping, tampering, and phishing attacks. With the increasing reliance on online services and the growing sophistication of cyber threats, it is more important than ever to secure your website with SSL.
To get started with SSL, you need to choose a certificate authority, generate a CSR, and complete the validation process. Once you have obtained your SSL certificate, you can install it on your server following the instructions provided by your web server software or hosting provider. Remember to keep your private key secure and regularly renew your SSL certificate to maintain the highest level of security.
By using SSL, you can not only safeguard your visitors’ data and privacy, but also enhance your website’s reputation, trustworthiness, and search engine visibility. SSL is not just a best practice, but a necessity for any website that wants to thrive in the digital age. So, don’t wait any longer, get your SSL certificate today and start reaping the benefits of a secure website!
Introduction Redmine is a powerful and versatile project management tool that can help teams stay organized, collaborate effectively, and track progress towards their goals. Originally developed for the Ruby on Rails community, Redmine is now used by thousands of organizations worldwide, from small startups to large enterprises.
With Redmine, you can create projects and sub-projects, define tasks and issues, assign them to team members, set due dates and priorities, and track time spent on each task. You can also add comments and attachments to issues, create custom fields and workflows, and generate reports and graphs to visualize project status and progress.
It is open-source software written in Ruby on Rails and is available under the GNU General Public License.
Whether you’re a software development team, a marketing agency, a non-profit organization, or any other type of group that needs to manage projects and tasks, Redmine can be a valuable tool to help you stay on track, collaborate effectively, and achieve your goals. In this blog, we’ll explore some of the key features and use cases of Redmine, and provide tips and best practices for getting the most out of this powerful project management tool.
In this tutorial, we will go through the steps of installing Redmine on an Ubuntu 22.04 server and secure it Let’s Encrypt SSL.
Prerequisites:
Ubuntu 22.04 Server Root or sudo user access A domain name pointed to the server is required for accessing Redmine via a web browser.
Step 1: Update Ubuntu System The first step is to update the Ubuntu system to ensure that all the packages are up-to-date. You can do this by running the following command: sudo apt update Step 2: Install Dependencies Redmine requires several dependencies to be installed before it can be installed. To install them, run the following command:
Also, install Apache and Apache mod Passenger module sudo apt install -y apache2 libapache2-mod-passenger
Note: libapache2-mod-passenger is a module for the Apache web server that enables the deployment of Ruby on Rails web applications. It provides an easy way to configure and manage Ruby on Rails applications within an Apache web server environment.
Step 3: Create a Redmine User Create a dedicated Linux user for running Redmine: useradd -r -m -d /opt/redmine -s /usr/bin/bash redmine
Add the user to the www-data group to enable Apache to access Redmine files: usermod -aG redmine www-data
Step 4: Install and Secure MariaDB MariaDB is a popular open-source database management system and is used as the backend for Redmine. To install and secure MariaDB, run the following commands: sudo apt install -y mariadb-server
Since the configuration file is an yaml, you need to use proper Indentation.
Save and close the file.
Step 7: Install Bundler and Redmine Dependencies Install Bundler for managing gem dependencies and run the following commands:
sudo gem install bundler
Login as redmine user and execute below commands:
su - redmine
bundle config set --local without 'development test'
bundle install
bundle update
exit
Step 8: Configure File System Permissions Ensure that the following directories are available in the Redmine directory (/opt/redmine):
tmp and tmp/pdf public and public/plugin_assets log files
Create them if they don’t exist and ensure that they are owned by the user used to run Redmine:
for i in tmp tmp/pdf public/plugin_assets; do [ -d $i ] || mkdir -p $i; done
chown -R redmine:redmine files log tmp public/plugin_assets
chmod -R 755 /opt/redmine
Step 9: Configure Apache Create a new Apache virtual host file for Redmine: sudo nano /etc/apache2/sites-available/redmine.conf
Paste the following configuration into the file:
<VirtualHost *:80>
ServerName redmine.linuxwebhostingsupport.in
DocumentRoot /opt/redmine/public
ErrorLog ${APACHE_LOG_DIR}/redmine-error.log
CustomLog ${APACHE_LOG_DIR}/redmine-access.log combined
<Directory /opt/redmine/public>
Require all granted
Options -MultiViews
PassengerEnabled on
PassengerAppEnv production
PassengerRuby /usr/bin/ruby
</Directory>
</VirtualHost>
Save the file and exit the text editor. Replace redmine.linuxwebhostingsupport.in with your domain name.
Enable the Redmine site by running the following command:
sudo a2ensite redmine.conf
Restart Apache to apply the changes:
sudo systemctl restart apache2
Allow Apache through the Ubuntu UFW firewall:
sudo ufw allow 'Apache Full'
Install Certbot and the Apache plugin for Let’s Encrypt:
sudo apt install certbot python3-certbot-apache
Adding Lets Encrypt SSL certificate
You need to make sure your domain is properly pointed to the server IP, otherwise, Let’s encrypt will fail.
Obtain an SSL certificate for your domain by running the following command:
sudo certbot --apache
Follow the on-screen instructions to complete the process.
Restart Apache to apply the SSL configuration:
sudo systemctl restart apache2
Open your web browser and go to https://redmine.linuxwebhostingsupport.in/. You should see the Redmine home screen.
Login to the admin area using your Redmine admin username and password. If this is your first login, you will need to reset your admin password.
https://redmine.linuxwebhostingsupport.in/login
Congratulations! You have successfully installed and configured Redmine on your Ubuntu server. In the previous steps, we have covered the installation and configuration of Redmine, including setting up the database, configuring Apache, and securing Redmine with Let’s Encrypt SSL.
However, one critical aspect of Redmine that you might want to configure is email delivery for notifications. This feature is essential for keeping team members informed about project updates, new issues, and changes to existing issues. In this section, we will show you how to configure email delivery in Redmine.
Configuring SMTP for Email Delivery in Redmine
Redmine supports email delivery for notifications, which you can set up using the following steps:
Step 1 – Open Configuration File
First, you need to open the configuration.yml file in a text editor:
sudo nano /opt/redmine/config/configuration.yml
Step 2 – Configure Email Settings
Next, scroll down to the production section of the file, uncomment the following lines by removing the # symbol at the beginning of each line, and replace the values with your SMTP server’s settings:
# specific configuration options for production environment# that overrides the default ones
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "your.smtp.server.com"
port: 587
domain: "your.domain.com"
authentication: :login
user_name: "your_email@example.com"
password: "your_email_password"
enable_starttls_auto: true
# specific configuration options for development environment# that overrides the default ones
Replace the values for address, port, domain, user_name, and password with your SMTP server’s settings:
address: The address of your SMTP server. port: The port number to use for SMTP server (usually 587). domain: The domain name of your organization or server. user_name: The email address of the user account to use for sending emails. password: The password for the user account to use for sending emails. Save the configuration.yml file.
Since the configuration file is an yaml, you need to use proper Indentation.
Step 3 – Restart Apache
Finally, restart Apache to apply the changes:
sudo systemctl restart apache2 And that’s it! Redmine is now configured to deliver email notifications to your team members.
Conclusion
Redmine is a powerful project management tool that can help you manage your software development projects effectively. In this blog post, we have covered the installation and configuration of Redmine on Ubuntu, including setting up the database, configuring Apache, securing Redmine with Let’s Encrypt SSL, and configuring email delivery.
With these steps, you should now have a working Redmine installation that can help you track your projects, collaborate with your team, and stay on top of your development process. Good luck!
In today’s world of online business and communication, security is more important than ever. One essential aspect of website security is SSL (Secure Sockets Layer), a protocol that encrypts data sent between a web server and a user’s web browser. By using SSL, website owners can protect their users’ personal information from being intercepted or stolen by hackers.
In this tutorial, we’ll walk you through the steps to install and secure your website with SSL on Ubuntu 22.04 using Apache2. By the end of this guide, you’ll have a secure, encrypted connection between your web server and your users’ browsers, helping to ensure their safety and privacy.
Section 1: Installing Apache2 on Ubuntu 22.04
Apache2 is a popular open-source web server software that plays a crucial role in hosting websites on the internet. In this section, we will walk through the process of installing Apache2 on Ubuntu 22.04.
Step 1: Update the Package List Before installing any new software, it’s always a good idea to update the package list to ensure you are installing the latest version of the software. To update the package list, open the terminal on Ubuntu 22.04 and run the following command:
sudo apt update
Step 2: Install Apache2 Once the package list is updated, you can proceed with installing Apache2 by running the following command:
sudo apt install apache2
This command will download and install Apache2 along with all its dependencies. During the installation process, you will be prompted to confirm the installation by typing y and pressing Enter.
Step 3: Verify Apache2 Installation To test if Apache2 is working correctly, open a web browser and enter your server’s IP address or domain name in the address bar. You should see the default Apache2 web page.
I hope that helps! Let me know if you have any questions or suggestions for the blog post. If Apache2 is installed correctly, you should see a page that says “Apache2 Ubuntu Default Page”.
Congratulations, you have successfully installed Apache2 on Ubuntu 22.04! In the next section, we will proceed with securing the web server by enabling SSL.
If you encounter any issues like Connection timeout or Unable to reach the website during the verification process, one possible cause could be that the Ubuntu firewall is blocking Apache2 traffic.
To check if Apache2 is currently enabled in the firewall, you can use the following command:
sudo ufw status
If the output shows that the firewall is active and Apache2 is not listed as an allowed service, you can add it by running the following command:
sudo ufw allow 'Apache Full'
This will allow both HTTP (port 80) and HTTPS (port 443) traffic to pass through the firewall, ensuring that your website is accessible to visitors.
Section 2: Installing SSL Certificate on Ubuntu 22.04 with Apache2
There are different types of SSL certificates, including domain validated, organization validated, and extended validation certificates. Each type has different features and provides varying levels of trust and security.
To install an SSL certificate on Ubuntu 22.04 with Apache2, you’ll need to follow these steps:
Obtain an SSL certificate: You can purchase an SSL certificate from a certificate authority (CA) or obtain a free SSL certificate from Let’s Encrypt. If you already have an SSL certificate, make sure it is valid and up-to-date.
Configure Apache2 to use the SSL certificate: Apache2 needs to be configured to use the SSL certificate for secure communication. This involves creating a virtual host for the SSL-enabled website, specifying the SSL certificate and key files, and enabling SSL encryption.
You can read more about different SSL certificate types, the process to create a Certificate signing request(CSR), etc in the below blog post:
This will open a text editor. Add the following code to the file:
<html><head><title>Hello, world!</title></head><body><h1>Hello, world!</h1><p>Welcome to my website!</p></body></html>
5. Reload Apache for the changes to take effect:
sudo systemctl reload apache2
Section 3: Testing SSL on Ubuntu 22.04 with Apache2
Test your SSL configuration by visiting your domain in a web browser and verifying that the SSL certificate is valid and the website loads correctly over HTTPS. The browser should display a padlock icon and the connection should be secure
You can also use the online tools like https://www.sslshopper.com/ssl-checker.html to check the configuration further. It can show if there any issues with certificate chain or trust.
Section 4. Troubleshooting SSL on Ubuntu 22.04 with Apache2
1. Certificate errors: If you encounter a certificate error, such as a warning that the certificate is not trusted or has expired, check the certificate’s validity and ensure it’s installed correctly. You can check the certificate’s details using your web browser, and make sure it matches the domain name and other relevant details.
2. Mixed content warnings: If you see mixed content warnings, which indicate that some parts of the site are not secure, check for any resources that are still being loaded over HTTP instead of HTTPS. This can include images, scripts, and other files.
3. SSL handshake errors: If you see an SSL handshake error, this usually means there’s an issue with the SSL configuration. Check your Apache configuration files and make sure the SSL directives are properly set up. You can also check for any issues with the SSL certificate, such as an invalid or mismatched domain name.
4. Server configuration errors: If the SSL certificate is working properly, but the site is still not loading over HTTPS, check your server configuration files to make sure the VirtualHost configuration is correct. Make sure the correct SSL certificate and key files are specified and that the SSL directives are set up correctly.
5. Browser-specific issues: If you’re only experiencing SSL issues in a specific web browser, make sure the browser is up to date and try clearing the cache and cookies. You can also try disabling any browser extensions that may be interfering with the SSL connection.
Remember, troubleshooting SSL issues can be complex and may require some technical expertise. If you’re not comfortable with these steps or need additional help, it’s always a good idea to consult with a professional. You can contact me at admin @ linuxwebhostingsupport.in
Section 5: Best Practices for SSL Configuration on Ubuntu 22.04 with Apache2
Here are some tips and best practices for configuring SSL on Ubuntu 22.04 with Apache2:
1. Keep SSL certificates up to date: Make sure to renew your SSL certificates before they expire. This can be done through the certificate authority where you purchased the certificate. Keeping your SSL certificates up to date will ensure that your website visitors are not presented with security warnings or errors.
2. Configure Apache2 for HTTPS-only access: Configure your web server to only serve HTTPS traffic. This can be done by redirecting all HTTP traffic to HTTPS. To do this, add the following lines to your Apache virtual host configuration or. htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
3. Use secure ciphers and protocols: Use secure ciphers and protocols to protect the confidentiality and integrity of your website traffic. Disable weak ciphers and protocols such as SSLv2 and SSLv3. Use TLSv1.2 or higher, and prefer the use of forward secrecy. You can configure this in your Apache virtual host configuration file by adding the following lines:
SSLProtocol -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 +TLSv1.2
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLHonorCipherOrder on
You can find more detailed instruction on making your SSL configuration strong and best practices in the below post:
By following these best practices, you can ensure that your SSL configuration is secure and up to date.
Section 6. Summary
In this tutorial, we discussed how to install and configure SSL certificates on Ubuntu 22.04 with Apache2. We covered the different types of SSL certificates, the steps for obtaining and installing an SSL certificate, and how to configure Apache2 to use the SSL certificate. We also discussed how to create virtual hosts for both SSL and non-SSL sites and how to troubleshoot SSL issues.
It’s important to emphasize the importance of SSL for website security and user trust. SSL encryption helps protect sensitive information, such as passwords and credit card numbers, from being intercepted by attackers. Additionally, having a valid SSL certificate gives users confidence that they are interacting with a legitimate website and not an imposter.
To follow best practices for SSL configuration, it’s recommended to keep SSL certificates up to date, configure Apache2 for HTTPS-only access, and use secure ciphers and protocols. By following these best practices, website owners can help ensure the security and trustworthiness of their website.
LAMP stack is a popular combination of open-source software that is used to run dynamic websites and web applications. The acronym LAMP stands for Linux (operating system), Apache (web server), MySQL (database management system), and PHP (scripting language).
Linux provides the foundation for the LAMP stack, serving as the operating system on which the other software components are installed. Apache is the web server that handles HTTP requests and serves web pages to users. MySQL is a powerful database management system that is used to store and manage website data. PHP is a popular scripting language used to create dynamic web content, such as interactive forms and web applications.
Together, these software components create a powerful platform for building and deploying web applications. The LAMP stack is highly customizable and widely used, making it an excellent choice for developers and system administrators alike.
Prerequisites
1. Ubuntu server: You will need an Ubuntu server to install the LAMP stack. You can use a Virtual/CLoud server or a physical server as per your requirement.
2. SSH access: You will need SSH access to your Ubuntu server to be able to install the LAMP stack. SSH (Secure Shell) is a secure network protocol that allows you to access and manage your server remotely.
3. Non-root user with sudo privileges: It is recommended that you use a non-root user with sudo privileges to install and configure the LAMP stack. This is because running as root can pose a security risk and may lead to unintended consequences if something goes wrong. You can also run the commands as root user.
4. Basic familiarity with Linux command line: A basic understanding of how to use the Linux command line interface (CLI) to run commands and navigate your Ubuntu server is recommended, not mandatory.
Installing a LAMP Stack on Ubuntu In this section, the process of installing a LAMP Stack on Ubuntu 22.04 LTS is outlined. These instructions can be applied to Ubuntu 20.04 LTS as well.
A LAMP stack is a popular combination of open-source software used to run dynamic websites or web applications. LAMP stands for Linux (operating system), Apache (web server), MySQL (database management system), and PHP (scripting language). In this guide, we will walk you through the steps involved in installing and configuring a LAMP stack on an Ubuntu server.
Step 1: Update Your Ubuntu Server Before we begin installing LAMP stack components, let’s update the server’s software packages by running the following command:
sudo apt update && sudo apt upgrade
Step 2: Install Apache Apache is the most widely used web server software. To install it, run the following command:
sudo apt install apache2
Once the installation is complete, you can check the status of Apache by running the following command:
sudo systemctl status apache2 This will display Apache’s status as either active or inactive.
Step 3: Install MySQL MySQL is a popular open-source database management system. To install it, run the following command:
sudo apt install mysql-server Once the installation is complete, you can check the status of MySQL by running the following command:
sudo systemctl status mysql This will display MySQL’s status as either active or inactive.
Step 4: Install PHP PHP is a popular server-side scripting language used to create dynamic web content. To install it, run the following command:
sudo apt install php libapache2-mod-php php-mysql
There are several additional PHP modules recommended for a CMS like WordPress. You can install them by running the command below: sudo apt-get install php-curl php-gd php-xml php-mbstring php-imagick php-zip php-xmlrpc After installing these modules, you will need to restart your Apache server for the changes to take effect. You can do this by running the following command:
sudo systemctl restart apache2
Setting up firewall rules to allow access to Apache web server
UFW is the default firewall with Ubuntu systems, providing a simple command-line interface to configure iptables, the software-based firewall used in most Linux distributions. UFW provides various application profiles that can be utilized to manage traffic to and from different services. To view a list of all the available UFW application profiles, you can run the command:
sudo ufw app list
Output Available applications: Apache Apache Full Apache Secure OpenSSH
These application profiles have different configurations for opening specific ports on the firewall. For instance:
Apache: Allows traffic on port 80, which is used for normal, unencrypted web traffic. Apache Full: Allows traffic on both port 80 and port 443, which is used for TLS/SSL encrypted traffic. Apache Secure: Allows traffic only on port 443 for TLS/SSL encrypted traffic.
To allow traffic on both port 80 and port 443(SSL), you can use the Apache Full profile by running the following command:
sudo ufw allow in "Apache Full"
You can verify that the change has been made by running the command: sudo ufw status
Output
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Apache Full ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Apache Full(v6) ALLOW Anywhere (v6)
To test if the ports are open and Apache web server is accessible, you can try visiting your server’s public IP address in a web browser using the URL http://your_server_ip. If successful, you should see the default Apache web page.
If you can view this page, your web server is correctly installed and accessible through your firewall.
Configuring the MySQL Database server Upon installation of MySQL, it is immediately available for use. However, in order to utilize it for web applications such as WordPress and improve the security of said applications, it is imperative to generate a database user and database. To complete the configuration process for MySQL, please adhere to the following steps.
To configure MySQL and improve application security, follow these steps:
1. Log in to the MySQL shell as the root user:
sudo mysql -u root
2. Using the MySQL shell, you can create the wpdatabase database and generate a new user account for accessing the web application. Instead of using the placeholders “dbuser” and “password” in the CREATE USER query, you should provide a real username and password. Furthermore, you should grant complete permissions to the user. After each line, MySQL should respond with “Query OK.”
CREATE DATABASE wpdatabase ; CREATE USER 'dbuser' IDENTIFIED BY 'password'; GRANT ALL ON wpdatabase .* TO 'dbuser';
Exit the SQL shell: quit
3. Set a password for root’@’localhost:
sudo mysql ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'password';
Exit the SQL shell: quit
Note: Replace “password” with a strong password. 4. Use the mysql_secure_installation tool to increase database security:
sudo mysql_secure_installation
When prompted to change the root password, leave it unchanged. Answer Y for the following questions:
Remove anonymous users? Disallow root login remotely? Remove test database and access to it? Reload privilege tables now?
To log in to the MySQL shell as root after this change, use “sudo mysql -u root” and type “quit” exit the SQL Shell.
It’s worth noting that when connecting as the root user, there’s no need to enter a password, despite having defined one during the mysql_secure_installation script. This is due to the default authentication method for the administrative MySQL user being unix_socket rather than password. Although it may appear to be a security issue, it actually strengthens the security of the database server by only allowing system users with sudo privileges to log in as the root MySQL user from the console or through an application with the same privileges. As a result, you won’t be able to use the administrative database root user to connect from your PHP application. However, setting a password for the root MySQL account acts as a precautionary measure in case the default authentication method is changed from unix_socket to password.
Creating a Virtual Host for your Website
In order to host multiple domains from a single server, Apache web server provides the capability to create virtual hosts. These virtual hosts are beneficial as they allow you to encapsulate configuration details for each domain. In this tutorial, we will walk you through setting up a domain named “example.com”. However, it is important to keep in mind that you should replace “example.com” with your own domain name.
By default, Ubuntu 22.04’s Apache web server has a single virtual host that is enabled and configured to serve documents from the /var/www/html directory. While this is a workable solution for a single site, it becomes cumbersome when hosting multiple sites. Therefore, instead of modifying /var/www/html, we will create a directory structure within the /var/www directory specifically for the example.com site. In doing so, we will leave /var/www/html in place as the default directory to be served if a client request does not match any other sites.
1. First, create a new directory for the “example.com” website files:
sudo mkdir /var/www/example.com
2. Assign the ownership of the directory to the web server user (www-data):
10. Finally, configure your DNS records to point the “example.com” domain to your server’s IP address. Once the DNS records are updated, you can access the website by visiting “http://example.com” in your web browser.
Testing the LAMP Stack Installation on Your Ubuntu Server To ensure that the LAMP stack configuration is fully functional, it’s necessary to conduct tests on Apache, PHP, and MySQL components. Verifying the Apache operational status and virtual host configuration was done earlier. Now, it’s important to test the interaction between the web server and PHP and MySQL components.
The easiest way to verify the configuration of the Ubuntu LAMP stack is by using a short test script. The PHP code does not need to be lengthy or complex; however, it must establish a connection to MySQL. The test script should be placed within the DirectoryRoot directory.
To validate the database, use PHP to invoke the mysqli_connect function. Use the username and password created in the “Configuring the MySQL Database server” section. If the attempt is successful, the mysqli_connect function returns a Connection object. The script should indicate whether the connection succeeded or failed and provide more information about any errors.
To verify the installation, follow these steps:
1. Create a new file called “phptest.php” in the /var/www/example.com directory.
<html><head><title>PHP MySQL Test</title></head><body><?php echo '<p>Welcome to the Site!</p>'; // When running this script on a local database, the servername must be 'localhost'. Use the name and password of the web user account created earlier. Do not use the root password. $servername = "localhost"; $username = "dbuser"; $password = "password"; // Create MySQL connection $conn = mysqli_connect($servername, $username, $password); // If the conn variable is empty, the connection has failed. The output for the failure case includes the error message if (!$conn) { die('<p>Connection failed: </p>' . mysqli_connect_error()); } echo '<p>Connected successfully</p>'; ?></body></html>
2. To test the script, open a web browser and type the domain name followed by “/phptest.php” in the address bar. For example, if your domain name is “example.com”, you would enter “example.com/phptest.php” in the address bar. Make sure to substitute the actual name of the domain for “example.com” in the example provided.
http://example.com/phptest.php
3. Upon successful execution of the script, the web page should display without any errors. The page should contain the text “Welcome to the Site!” and “Connected successfully.” However, if you encounter the “Connection Failed” error message, review the SQL error information to troubleshoot the issue.
Bonus: Install phpMyAdmin phpMyAdmin is a web-based application used to manage MySQL databases. To install it, run the following command:
sudo apt install phpmyadmin During the installation process, you will be prompted to choose the web server that should be automatically configured to run phpMyAdmin. Select Apache and press Enter.
You will also be prompted to enter a password for phpMyAdmin’s administrative account. Enter a secure password and press Enter.
Once the installation is complete, you can access phpMyAdmin by navigating to http://your_server_IP_address/phpmyadmin in your web browser.
Congratulations! You have successfully installed and configured a LAMP stack on your Ubuntu server.
Summary This guide walks through the process of setting up a LAMP Stack, a combination of the Linux operating system, Apache web server, MySQL RDBMS, and PHP programming language, to serve PHP websites and applications. The individual components are free and open source, designed to work together, and easy to install and use. Following the steps provided, you can install the LAMP Stack on Ubuntu 22.04 LTS using apt, configure the Apache web server, create a virtual host for the domain, and integrate the MySQL web server by creating a new account to represent the web user. Additional PHP packages are required for Apache, PHP, and the database to communicate. A short PHP test script can be used to test the new installation by connecting to the database.
iRedMail is a powerful and open-source mail server solution that simplifies the process of setting up and managing email services. It supports popular email protocols, including IMAP, POP3, and SMTP, and can be used to host multiple email domains. In this guide, we’ll explore how to add domain aliases to iRedMail’s free version with a MySQL backend.
What Are Domain Aliases? Domain aliases are additional domain names that point to an existing email domain. For example, if you have a primary domain like example.com, you can set up domain aliases like domain.ltd so that emails sent to username@domain.ltd are delivered to the corresponding mailbox of username@example.com. Domain aliases are a convenient way to manage multiple email addresses under a single domain.
The Bash Script: Here’s a Bash script that simplifies the process of adding domain aliases in iRedMail. You can use this script to automate the task:
#!/bin/bash# Author: Abdul Wahab# Website: Linuxwebhostingsupport.in# Print purpose and noteprintf"Purpose: Add an alias domain in iRedMail. \n\n"printf"Note: Let's say you have a mail domain example.com hosted on your iRedMail server, if you add domain name domain.ltd as an alias domain of example.com, all emails sent to username@domain.ltd will be delivered to user username@example.com's mailbox. So here domain.ltd is the alias domain and example.com is the traget domain \n\n"# Prompt the user to enter the alias domain nameread -p "Enter the alias domain name: " ALIAS_DOMAIN
# Prompt the user to enter the target domain nameread -p "Enter the target domain name: " TARGET_DOMAIN
# Connect to the vmail database and check if the target domain exists in the domain tableRESULT=`mysql vmail -N -B -e "SELECT COUNT(*) FROM domain WHERE domain='$TARGET_DOMAIN'"`if[$RESULT -ne 1 ]thenecho"Error: The target domain $TARGET_DOMAIN does not exist in the domain table. You need to add the target domain first"exit 1
fi# Insert the alias domain record
mysql vmail <<EOFINSERT INTO alias_domain (alias_domain, target_domain)VALUES ('$ALIAS_DOMAIN', '$TARGET_DOMAIN');EOF# Print completion messageecho"Alias domain $ALIAS_DOMAIN has been added for $TARGET_DOMAIN."
How to Use the Script:
Copy the provided Bash script into a text file, e.g., add_domain_alias.sh. Make the script executable by running the following command:
chmod +x add_domain_alias.sh
Execute the script by running ./add_domain_alias.sh in your terminal. Follow the prompts to enter the alias domain and target domain names. The script will connect to the MySQL database and insert the alias domain record.
Conclusion: Adding domain aliases in iRedMail is a straightforward process, and the provided Bash script can simplify it even further. With domain aliases, you can efficiently manage multiple email addresses under a single domain, enhancing your email hosting capabilities.
Feel free to use this script to streamline your iRedMail email domain management, making it easier to accommodate various email addresses and domains.
How to remove or compress huge MySQL general and query log table
If you have enabled MySQL general or slow logging, it can create quite big log, depending upon your MySQL usage/queries. So we may have to periodically clear them to save space.
Please note that MySQL can save logs to either table or files. This document assumes you are using table as log output.
Files: slow_log.CSV and general_log.CSV (The location and the name of the file can be different)
By default, logging is to CSF file.
MYSQL supports run time clearing of these logs. So no need to restart the MySQL service. Never delete the CSV file directly. It can crash MySQL.
Slow query log
SET GLOBAL slow_query_log='OFF';
DROP TABLE IF EXISTS slow_log2;
CREATE TABLE slow_log2 LIKE slow_log;
RENAME TABLE slow_log TO slow_log_backup, slow_log2 TO slow_log;
gzip /var/db/mysql/mysql/slow_log_backup.CSV
DROP TABLE slow_log_backup;
SET GLOBAL slow_query_log = 'ON';
General log
USE mysql;
SET GLOBAL general_log = 'OFF';
DROP TABLE IF EXISTS general_log2;
CREATE TABLE general_log2 LIKE general_log;
RENAME TABLE general_log TO general_log_backup, general_log2 TO general_log;
gzip /var/db/mysql/mysql/general_log_backup.CSV
DROP TABLE general_log_backup;
What we did is create new log table, move current log file to a backup copy and compress the backup and remove it.
phpMyAdmin is installed with CentOS Web Panel. By default, it is not protected and there is only MySQL user authentication. This can put your server vulnerable. So it is recommended to add additional layer protection.
phpMyAdmin is available through the following url in a CWP based server.
http:/hostname/phpmyadmin http:/hostname:2030/pma
CWP panel runs its core services through its own version of Nginx. So normal htaccess based password protection will not work.
Create the Password File
You can do this by using the OpenSSL utilities that may already be available on your server. Alternatively, you can use the purpose-made htpasswd utility included in the apache2-utils package(Debian/ubuntu) or httpd-tools(Redhat/Centos).
Using OpenSSL Utilities
We will create a hidden file called .pma_pass /usr/local/cwpsrv/var/services/ folder. You can use any username. I am using dbadmin here as an example
sudo sh -c "echo -n 'dbadmin:' >> /usr/local/cwpsrv/var/services/.pma_pass"
Next, add an encrypted password entry for the username by typing:
sudo sh -c "openssl passwd -apr1 >> /usr/local/cwpsrv/var/services/.pma_pass"
Using Apache Utilities
This tool is already installed and available on all CWP servers.
We will need to configure Nginx to read this file before serving our protected content. CWP Service Nginx configuration file: /usr/local/cwpsrv/conf/cwp_services.conf
Open the above file add the following to the location block of phpMyAdmin.
To confirm that your content is protected, try to access your restricted content in a web browser. You should be presented with a username and password prompt
How to block Outgoing Port 25 for all VPS/Containers of SolusVM(Both OpenVZ/KVM)
Sometimes,when providing VPS service, it is necessary to block mailing service for VPS. Otherwise your IP ranges will be blocked by RBLs and other common mail providers like Gmail, Hotmail, AOL, etc. It is recommended to open ports by case by case for your customers, after establishing trust with your client.
Normally we block the port using the “OUTPUT” chain. However, SolusVM uses the chain “FORWARD” for routing traffic from containers/VPSs.
So by adding following rules, you can block all outgoing mails ports completely for all VPSs. iptables -I FORWARD -d 0.0.0.0/0 -p tcp -m tcp --dport 25 -j DROP iptables -I FORWARD -d 0.0.0.0/0 -p tcp -m tcp --dport 465 -j DROP iptables -I FORWARD -d 0.0.0.0/0 -p tcp -m tcp --dport 587 -j DROP