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 install Lighttpd Web server in Ubuntu15.04/CentOS7

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to install Lighttpd Web server in Ubuntu15.04/CentOS7". In daily operation, I believe many people have doubts about how to install Lighttpd Web server in Ubuntu15.04/CentOS7. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to install Lighttpd Web server in Ubuntu15.04/CentOS7". Next, please follow the editor to study!

Install lighttpd

Install using the package Manager

Here we install lighttpd by using the package manager, which is the easiest way. Simply enter the following instructions in the terminal or console in sudo mode.

Centos 7

Since lighttpd is not available in the official repository of centos 7.0, we need to install an additional software source epel repository in the system. Use the following yum directive to install epel.

# yum install epel-release

Then, we need to update the system and prepare for the installation of lighttpd.

# yum update# yum install lighttpd

Ubuntu 15.04

Lighttpd is included in the official warehouse of ubuntu 15.04, so you only need to update the local warehouse index and use the apt-get directive to install lighttpd.

# apt-get update# apt-get install lighttpd

Install lighttpd from source code

If you want to install the latest version (for example, 1.4.39) from the lighttpd source code, we need to compile the source code locally and install it. First, we need to install the dependency packages needed to compile the source code.

# cd / tmp/# wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.39.tar.gz

When the download is complete, execute the following instructions to extract it.

# tar-zxvf lighttpd-1.4.39.tar.gz

Then use the following instructions to compile.

# cd lighttpd-1.4.39#. / configure# make

Note: in this tutorial, we installed lighttpd with the default configuration. Other extension features, such as support for ssl, modrewrite,modredirect, etc., need to be configured by yourself.

When the compilation is complete, we can install it into the system.

# make install

Set up lighttpd

If there is a higher requirement, we can make further settings for lighttpd by modifying the default settings file, such as / etc/lighttpd/lighttpd.conf. In this tutorial, we will use the default settings and do not modify the settings file. If you have made any changes and want to check the settings file for errors, you can execute the following instructions.

# lighttpd-t-f / etc/lighttpd/lighttpd.conf

Use centos 7

In centos 7, we need to create a webroot folder that is set in the lighttpd default configuration file, such as / src/www/htdocs.

# mkdir-p / srv/www/htdocs/

Then copy the default welcome page from / var/www/lighttpd to the newly created directory:

# cp-r / var/www/lighttpd/* / srv/www/htdocs/

Start the service

Now restart the web service by executing the systemctl instruction.

# systemctl start lighttpd

Then we set it to run automatically with the system started.

# systemctl enable lighttpd

Set up a firewall

If we want our web pages or websites running on lighttpd to be accessed in internet or within the same network, we need to open port 80 in the firewall program. Since both centos 7 and ubuntu15.04 come with systemd as the default initialization system, we use firewalld by default. To open port 80 or the http service, we only need to execute the following command:

# firewall-cmd-permanent-add-service=httpsuccess# firewall-cmd-reloadsuccess

Connect to a web server

After setting port 80 as the default port, we can directly access the default welcome page of lighttpd. We need to set the browser's ip address and domain name according to the device running lighttpd. In this tutorial, we have the browser access http://lighttpd.linoxide.com/ and point the subdomain name to the above ip address. In this way, we can see the following welcome page in the browser.

In addition, we can add the files of the website to the webroot directory and delete the default index file of lighttpd to make our static website accessible on the Internet.

If you want to run the php application in the lighttpd web server, please refer to the following steps:

Install the php5 module

After lighttpd is successfully installed, we need to install php and related modules to run the php5 script in lighttpd.

Use ubuntu 15.04

# apt-get install php5 php5-cgi php5-fpm php5-mysql php5-curl php5-gd php5-intl php5-imagick php5-mcrypt php5-memcache php-pear

Use centos 7

# yum install php php-cgi php-fpm php-mysql php-curl php-gd php-intl php-pecl-imagick php-mcrypt php-memcache php-pear lighttpd-fastcgi

Set up the php service for lighttpd

To get php and lighttpd to work together, we just need to execute the following instructions depending on the distribution we are using.

Use centos 7

The first thing to do is to use the file editor to edit the php settings file (for example, / etc/php.ini) and uncomment the line cgi.fix_pathinfo=1.

# nano / etc/php.ini

After completing the above steps, we need to transfer ownership of the php-fpm process from apache to lighttpd. To do this, first open the / etc/php-fpm.d/www.conf file with a file editor.

# nano / etc/php-fpm.d/www.conf

Then add the following statement to the file:

User = lighttpdgroup = lighttpd

After doing this, we save and exit the text editor. Then add the fastcgi module from the / etc/lighttpd/modules.conf settings file.

# nano / etc/lighttpd/modules.conf

Then, uncomment it by removing the # before the following statement.

Include "conf.d/fastcgi.conf"

Finally, we need to set up the settings file for fastcgi in the text editor.

# nano / etc/lighttpd/conf.d/fastcgi.conf

Add the following code at the end of the file:

Fastcgi.server + = (".php" = > (("host" = > "127.0.0.1", "port" = > "9000", "broken-scriptfilename" = > "enable")

Save and exit the text editor after editing.

Use ubuntu 15.04

To enable fastcgi for lighttpd, simply execute the following code:

# lighttpd-enable-mod fastcgienabling fastcgi: okrun / etc/init.d/lighttpd force-reload to enable changes# lighttpd-enable-mod fastcgi-phpenabling fastcgi-php: okrun `/ etc/init.d/ Lighttpd` force-reload to enable changes

Then, execute the following command to restart lighttpd.

# systemctl force-reload lighttpd

Check the working status of php

To check whether php is working as expected, we need to create a new php file in the webroot directory of lighttpd. In this tutorial, create and open info.php using a text editor under the / var/www/html directory under ubuntu and / src/www/htdocs directory under centos.

Use centos 7

# nano / var/www/info.php

Use ubuntu 15.04

# nano / srv/www/htdocs/info.php

Then simply add the following statement to the file.

After editing, save and launch the text editor.

Now, we need to point our web browser to the lighttpd running on the system based on the ip address or domain name of the info.php file under the path http://lighttpd.linoxide.com/info.php. If everything follows the above instructions, we will see the php page information shown in the following figure.

At this point, the study on "how to install the Lighttpd Web server in Ubuntu15.04/CentOS7" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Development

Wechat

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

12
Report