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

Centos7 installs nginx and php7

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Centos7 installs nginx and php7

There will be some strange problems in installing php7 in centos7 system, which will delay time and affect efficiency. Direct yum installation is recommended here.

1. Before we start installing Nginx and php7-fpm, we will also learn to add the repository source of the EPEL package. Use the following command:

Yum-y install epel-release

Then we need to add another warehouse for php7-fpm. There are many remote repositories on the Internet that offer PHP 7 series packages, and I use webtatic here.

Add a PHP7-FPM webtatic repository:

Rpm-Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Then it's time to install PHP7-FPM and some of the packages that Nextcloud needs.

Yum-y install php70w-fpm php70w-cli php70w-gd php70w-mcrypt php70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json php70w-pecl-apcu php70w-pecl-apcu-devel

Finally, check the version number of PHP from the server terminal to verify that PHP is installed correctly.

Php-v

2. Configure php7-fpm

In this step, we will configure php-fpm to run in conjunction with Nginx. Php7-fpm will run with the nginx user and listen on port 9000.

Use vim to edit the default php7-fpm configuration file.

Vim / etc/php-fpm.d/www.conf

On lines 8 and 10, user and group are assigned nginx.

User = nginxgroup = nginx

On line 22, make sure php-fpm is running on the designated port.

Listen = 127.0.0.1 9000

Uncomment lines 366-370 and enable the system environment variable for php-fpm.

Env [HOSTNAME] = $HOSTNAMEenv [path] = / usr/local/bin:/usr/bin:/binenv [TMP] = / tmpenv [TMPDIR] = / tmpenv [TEMP] = / tmp

Save the file and exit the vim editor.

The next step is to create a new folder session under the / var/lib/ directory and change its owner to the nginx user.

Mkdir-p / var/lib/php/sessionchown nginx:nginx-R / var/lib/php/session/

Then start php-fpm and Nginx and set them to services that start with boot.

Systemctl start php-fpmsystemctl start nginx systemctl enable php-fpmsystemctl enable nginx

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