Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure HHVM environment in Ubuntu

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to configure the HHVM environment in Ubuntu, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Step 1: install Nginx or Apache server

1. First, upgrade the system and update the list of software repositories, as follows

# apt-get update & & apt-get upgrade

System upgrade

2. As I said before, HHVM can integrate with Nginx and Apache. So it's up to you to decide which server to use, but we'll teach you how to install both servers.

Install Nginx

We install the Nginx/Apache server with the following command

# apt-get install nginx

Install the Nginx server

Install Apache# apt-get install apache2

Install the Apache server

To complete this step, you can see the default page of Nginx or Apache through the following link

Http://localhost or http://IP-Address

Nginx default page

Apache default page

Step 2: install and configure MariaDB

3. In this step, we will install MariaDB, which is a better database than MySQL, with the following command

# apt-get install mariadb-client mariadb-server

Install MariaDB

4. After MariaDB is successfully installed, you can start it and set the root password to protect the database:

# systemctl start mysql# mysql_secure_installation

To answer the following questions, just press y or n and enter. Please make sure you read the instructions carefully.

Enter current password for root (enter for none) = press enterSet root password? [YBO] = yRemove anonymous users [YBO] = yDisallow root login remotely [YBO] = yRemove test database and access to it [YBO] = yReload privileges tables now [YBO] = y

5. After setting the password, you can log in to MariaDB.

# mysql-u root-p step 3: install HHVM

6. At this stage, we will install HHVM. We need to add HHVM's repository to your sources.list file, and then update the software list.

# wget-O-http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add-# echo deb http://dl.hhvm.com/ubuntu DISTRIBUTION_VERSION main | sudo tee / etc/apt/sources.list.d/hhvm.list# apt-get update

Important: don't forget to replace the above DISTRIBUTION_VERSION (such as lucid, precise, trusty) or Debian's jessie or wheezy with your Ubuntu distribution code. The same is true in Linux Mint, but only petra is supported.

Once you have added the HHVM repository, you can easily install it.

# apt-get install-y hhvm

After installation, it can be started, but it does not boot up. You can boot with the following command.

# update-rc.d hhvm defaults step 4: configure Nginx/Apache connection HHVM

7. Now that nginx/apache and HHVM are installed and running independently, we need to set them up to relate them to each other. This critical step is to tell nginx/apache to hand over all the php files to HHVM for processing.

If you use Nginx, please follow these steps:

The configuration file for nginx is in / etc/nginx/sites-available/default, and these configuration files look for files to execute in / usr/share/nginx/html, but it doesn't know what to do with PHP.

To ensure that Nginx can connect to HHVM, we need to execute the following script with it. It helps us to configure Nginx correctly and put hhvm.conf in the header of the configuration file nginx.conf mentioned above.

This script ensures that Nginx handles .hh and .php correctly and sends them to HHVM via fastcgi.

# / usr/share/hhvm/install_fastcgi.sh

Configure Nginx, HHVM

Important: if you are using Apache, you don't need to configure it here.

8. Next, you need to use hhvm to provide a running environment for php.

# / usr/bin/update-alternatives-install / usr/bin/php php / usr/bin/hhvm 60

After the above steps have been completed, you can now start and test it.

# systemctl start hhvm step 5: test HHVM and Nginx/Apache

9. To confirm that hhvm is working, you need to create a hello.php in the document root of nginx/apache.

# nano / usr/share/nginx/html/hello.php [for Nginx] or # nano / var/www/html/hello.php [for Nginx and Apache]

Add the following code to the file:

Then visit the link below to make sure you can see "hello world"

Http://localhost/info.php or http://IP-Address/info.php

On how to configure the HHVM environment in Ubuntu to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report