Back to the list of posts

Настройка сервера на Ubuntu/Debian для развертывания проекта на PHP

If you want to deploy a PHP project, you need a server that supports PHP and can store your files. Ubuntu is one of the most widely used Linux distributions and can be a great choice for your server. In this article, we'll look at how to set up an Ubuntu server to deploy a PHP project.

Step 1: Install Apache

Apache is the most popular web server in the world. It can be used to store and serve your web pages and applications. To install Apache on Ubuntu, run the following commands in a terminal:

sudo apt update
sudo apt install apache2

Step 2: Install MySQL

MySQL is a database management system that can be used to store your project data. To install MySQL on Ubuntu, run the following commands in a terminal:

sudo apt install mysql-server
sudo mysql_secure_installation

Step 3: Install PHP

PHP is a programming language that is used to create web applications. To install PHP on Ubuntu run the following commands in a terminal:

sudo apt install php libapache2-mod-php php-mysql

Step 4: Set up the web server

Now that you have Apache, MySQL, and PHP, you need to set up your web server so it knows where your application and database are. To do this, you need to edit the Apache configuration file called "000-default.conf". You can find it in "/etc/apache2/sites-available/" directory. Open this file with a text editor and make the following changes:

<VirtualHost *:80>
     ServerName {name of your server}
     DocumentRoot /var/www/{name of your project}
     <Directory /var/www/{your project name}>
         AllowOverride All
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Replace {your server name} and {your project name} with the appropriate values. Save the file and restart Apache:

sudo systemctl restart apache2

Step 5: Testing Your Server

To make sure your server is working properly, create an "index.php" file in the "/var/www/{your project name}/" directory. Open it with a text editor and enter the following code:

<?php
phpinfo();
?>

Save the file and open it in a web browser using your server's URL. If everything is configured correctly, you should see information about PHP and its settings.

You are now ready to use your Ubuntu server to deploy your simple PHP. Good luck!

#DevOps #PHP

Back to the list of posts Next post

menuclose

start a project

Заявка отправлена

Спасибо! Заявка отправлена. Свяжемся с вами в течении часа!