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

The method of installing PHP and Nginx in Centos7

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the relevant knowledge of "how to install PHP and Nginx in Centos7". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

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 official website of php to see the tar.gz link you want to download, as shown below:

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

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:, as shown below:

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

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, because if some server providers prohibit port 80 or site port, browsers through the public network cannot access it. Of course, you can also check whether the corresponding service has been started through grep or nstat.

This is the end of the content of "how to install PHP and Nginx in Centos7". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report