How To Install Apache, MySQL, PHP & Composer On Ubuntu
Step 1: Installing Apache
To begin, refresh the cache. If this is the first time using sudo in this session, you will have to enter the user’s password in order to continue. This ensures that the user has the necessary privileges to manage the system packages using apt and that they are not being interfered with by other users, please follow step by step:
Then, install Apache with:
Once installed you can open localhost on any browser and have a look at the apache default page.
If you can view this page, your web server is correctly installed and accessible through your firewall.
Step 2: Installing MySQL
Once installed you can type this on terminal and type your password to login: mysql -u root -p
Step 3: Installing PHP
You have Apache installed to serve your content and MySQL to store and manage your data. PHP acts as the processing component, generating dynamic content for users. Along with the PHP package, you’ll need php-mysql, a module that enables PHP to interact with MySQL databases. Additionally, libapache2-mod-php is required to allow Apache to process PHP files. The core PHP packages will be installed automatically as dependencies.
To install these packages, run the following command:
Once the installation is finished, run the following command to confirm your PHP version:
You can also install more than one package at a time. Here are a few suggestions of the most common modules you will most likely want to install:
Step 4: Setting Up Composer for Dependency Management
Libraries are reusable collections of code that simplify solving common problems without requiring you to write everything from scratch. With a wide range of libraries available, a dependency manager becomes essential for efficiently handling multiple libraries as you advance in PHP development.
Composer is a PHP dependency management tool that lets you specify the libraries your project requires and handles their installation and updates seamlessly.
To install Composer, download the installer first with the following curl command:
To test your installation, run:
Thanks,
AAI