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 PHP and Nginx in Centos7

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

Share

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

This article mainly introduces Centos7 how to install PHP and Nginx, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

First, install PHP

With the popularity of Wechat in the past 13 years, the use of php has become popular again. Many enterprises in the market have chosen to use php as their application background. Personally, I think the reasons are

1. The cost of php is low

2. Getting started with php

3. The development cycle of php is relatively short

4. The birth of tp5 improves the efficiency of php interface development. Because there are so many requirements, the server configurations of many enterprises need to be able to support the php environment to complete the project construction. In fact, the installation of centos installation software is generally divided into two types, the first is fast installation, the second is compilation and installation, it is recommended to compile and install, as for quick installation simple and fast, as long as it is loaded into the corresponding php source, step by step installation process can be completed through yum install, I just talk about how to compile and install as well as the process of compilation and installation.

The first step is to check whether there is php by default in the system before installation. You can verify it by looking for php files or processes. If you have an installed version and it is not the version we need, you can uninstall the relevant files with the following command:

Yum remove php*

The second step is to install related php dependencies

Yum install-y gcc gcc-c++ libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel freetype freetype-devel

Step 3. Go to the php website http://php.net/downloads.php to see the tar.gz link you want to download, as shown in the following figure:

List of versions of php

On this page, select the file source of the country you want to download

Select the file source, copy the file download link, and download, compile and install it in the system through the wget command. You are accustomed to operating in the / usr/local directory. Specific steps are as follows:

Enter the operation directory: cd / usr/local

Download file: wget http://tz1.php.net/distributions/php-7.2.10.tar.gz

Extract the file: tar-zxvf php-7.2.10.tar.gz

Enter the decompressed file directory: cd php-7.2.10.tar.gz

Then compile with the following command:

/ configure-- prefix=/usr/local/php-- with-config-file-path=/usr/local/php/etc-- with-mysql=/usr/local/mysql-- with-mysqli=/usr/local/mysql/bin/mysql_config-- with-iconv-- with-zlib-- with-libxml-dir=/usr-- enable-xml-- disable-rpath-- enable-bcmath-- enable-shmop-- enable-sysvsem-- enable-inline-optimization-- with-curl-- enable-mbregex-- Enable-fpm-enable-mbstring-with-gd-enable-gd-native-ttf-with-openssl-with-mhash-enable-pcntl-enable-sockets-with-xmlrpc-enable-zip-enable-soap-enable-opcache-with-pdo-mysql enable-maintainer-zts with-mcrypt=/usr/include with-mysql=shared Mysqlnd-with-mysqli=shared,mysqlnd-with-pdo-mysql=shared,mysqlnd-enable-ftp-enable-session-with-gettext-with-jpeg-dir-with-freetype-dir-enable-fastcgi without-gdbm-disable-fileinfo

Then complete the final compilation and installation with the following command:

Make & & make install

If the installation process indicates that there is an error or dependency, it needs to be resolved on a case-by-case basis, so we can use the php-v command to see if the installation is successful.

Note: if the version you are viewing is not consistent with your own installation, you can find out where the prompted version file is, and then delete it, or you can ignore it. Then we point to the file directory we installed by modifying the environment variable, as follows:

First edit the environment variable file: vim / etc/profile

Add export PATH= "/ usr/local/php/bin:$PATH" at the end of the file

"/ usr/local/php/bin" is the specific path of your installation. After saving and exiting, make the following changes and execute the command:

Source / etc/profile

At this point we can see the version number we installed by using php-v again to look at the current version.

Second, install Nginx

Nginx is the most mainstream server software except apache, so installing Ngix is also a basic configuration, which is compiled and installed in a similar way:

The first step is to check the installation-related dependency packages

Yum-yinstall gcc gcc-c++ autoconf automake makeyum-yinstall zlib zlib-devel openssl yum-yinstallopenssl-devel pcre pcre-devel

Step 2, go to the nginx official website to find the link to the version you want to install, the official website address: http://nginx.org/download/, as shown in the following figure:

Nginx version list

Copy the corresponding version link, enter the operation directory above, and / usr/local perform the operation.

Enter the directory: cd / usr/local

Download file: wget http://nginx.org/download/nginx-1.8.0.tar.gz

Extract the file: tar-zxvf nginx-1.8.0.tar.gz

Enter the decompressed file directory: cd nginx-1.8.0

Then compile and install with the command:

. / configure make & & make install

After the installation is completed, there will be an extra nginx folder under the / usr/local folder with four files: conf, html, logs and sbin. We only need to run. / sbin/nginx to start the nginx service.

After startup, verify whether the service really starts the browser to access the server address to check whether it has been started successfully. Individuals like to verify through curl http://localhost, because browsers through the public network cannot access it because some server providers prohibit port 80 or site. Of course, you can also check whether the corresponding service has been started through grep or nstat.

Thank you for reading this article carefully. I hope the article "how to install PHP and Nginx in Centos7" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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