Centos7 installation of PHP and Nginx tutorial detailed

As the application of the server-side centos becomes more and more popular, the use of centos7 is also increasing. In the past two years, I have been a little white who rarely touches the centos server-side maintenance, and also more and more basic maintenance operations, to While I have caused a lot of trouble, I also added a lot of knowledge about centos server construction and operation and maintenance. Today, I will record it step by step.

1. Install PHP

As WeChat started to catch fire in 13 years, the use of php has become popular again. Many companies on the market choose to use php as their application backend. I think the reasons are

1、 Low cost of php

2、 Quick entry to php

3、 The development cycle of php is relatively short

4、 The birth of tp5 improves the efficiency of php interface development. Because of so many demands, the server configuration of many companies needs to be able to support the PHP environment to complete the project. In fact, the installation of centos installation software is generally divided into two types. The first is quick installation and the second is compiling and installing. Personally recommend compiling and installing. As for the quick installation method, it is simple and fast. Just load the corresponding php source and complete it through yum install Step-by-step installation process, I will only talk about how to compile and install and the process of compiling and installing.

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

yum remove php*

The second step, 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

The third step, go to php official website http://php.net/downloads.php to view the tar.gz link to be downloaded, as shown in the following figure:

php version list

Select the file source of the country you want to download on this page

After selecting the file source, copy the file download link, download, compile and install in the system through the wget command, and personally operate in the /usr/local directory. The specific steps are as follows:

Enter the operating directory: cd /usr/local

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

Unzip 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 through the following command:

make && make install

If the installation process prompts an error or dependency, you need to solve it according to the specific situation. So far we can check whether the installation is successful through the php -v command.

Note: If the version you are viewing is inconsistent with the version you installed, you can find the location of the suggested version file and delete it, or you can leave it alone. After that, we point to the file directory we installed by modifying the environment variable, the operation method is 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

Among them, "/usr/local/php/bin" is the specific path you installed. After saving and exiting, execute the following changes and execute the command:

source /etc/profile

At this time, we can use php -v to view the current version again to see the version number we have installed.

2. Install Nginx

Nginx has become the most mainstream server software except apache, so installing Ngix is also a basic configuration, and the methods of compiling and installing are similar:

The first step is to check and install related dependencies

yum -y install gcc gcc-c++ autoconf automake make

yum -y install zlib zlib-devel openssl 

yum -yinstallopenssl-devel pcre pcre-devel

Step 2: Go to the nginx official website to find the link of the version you want to install, the official website address: http://nginx.org/download/, as shown below:

Nginx version list

Copy the corresponding version link, enter the above operation directory, /usr/local for operation

Enter the directory: cd /usr/local

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

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

Enter the decompressed file directory: cd nginx-1.8.0

Then compile and install through the command:

. /configure 
make && make install

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

After startup, check whether the service really starts the browser and visit the server address to check whether it is successfully started. I personally like to check it through curl http://localhost, because if some server providers ban 80 or site port, it is through the external network The browser cannot be accessed. Of course, you can also check whether the corresponding service has been started through grep or nstat.

At this point, the installation of php and nginx under centos7 is over, there are more centos server-side configuration exchanges, you can leave a comment at the end of the article.

to sum up

The above is a detailed explanation of the Centos7 installation PHP and Nginx tutorial introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!

Recommended Posts

Centos7 installation of PHP and Nginx tutorial detailed
CentOS 8 installation of MariaDB detailed tutorial
Detailed explanation of Spark installation and configuration tutorial under centOS7
Centos8 minimal deployment and installation of OpenStack Ussuri detailed tutorial
Centos7 installation and deployment of Airflow detailed
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
Detailed tutorial of installing nginx on centos8 (graphic)
Centos7 installation and configuration of Jenkins
Centos7 installation of Dameng database tutorial
Centos6.5 installation and deployment of KVM
CentOS6 minimal installation KVM detailed tutorial
Centos8 installation diagram (super detailed tutorial)
CentOS7 installation and maintenance of nginx from entry to master
CentOS 7 system installation and configuration graphic tutorial
Installation and use of Mysql under CentOS
Centos-6.5 installation and deployment of LNMP environment
Installation and configuration of redis under centos7
Centos7 installation and deployment of gitlab server
CentOS7 installation zabbix 4.0 tutorial (graphics and text)
Jenkins installation and deployment tutorial under CentOS 7
Installation and configuration of JDK in CentOS 7 system
Install nginx in centos8 custom directory (detailed tutorial)
Graphical installation of CentOS8
Installation and configuration of rsync server under CentOS 6.5
Installation and configuration of CentOS 7 in VMware Workstation
CentOS7 Docker Nginx deployment and operation detailed explanation
MySQL 8.0 installation and deployment under CentOS, super detailed!
Linux CentOS 7 installation tutorial
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Installation and cracking of confluence6.3 operation records under Centos
Installation and cracking of Jira7 operation records under Centos
Centos8 (minimal installation) a new installation of Python3.8+pip method tutorial
Detailed installation steps of CentOS6.4 system in virtual machine
Detailed explanation of CentOS7 network setting tutorial in vmware
Detailed tutorial on installing JDK8 on Linux system (CentOS7 installation)
Centos mysql installation and configuration
CentOs7.3 compile and install Nginx 1.9.9
Centos7 installation and configuration prometheus
CentOS 7 installation and configuration PPTP
Graphical centos installation detailed process
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
Hyper-V + CentOS7 installation video tutorial
centos7 kvm installation and use
Centos7 silent installation of Oracle11g
vmware install CentOS 7 detailed tutorial
CentOS7 postgresql installation and use
CentOS environment installation of Docker
Centos7.4 environment installation lamp-php7.0 tutorial
CentOS 7 yum install PHP7.3 tutorial
Centos7 elk7.1.1 installation and use
Introduction to CentOS7 installation process of openjdk, tomcat and mysql
Analysis of Hyper-V installation CentOS 8 problem
Centos iso image file installation tutorial
Use Nginx and u under CentOS
CentOS 7 install Nginx, PHP, MySQL packages
Installation under centos6.9 of jenkins learning
CentOS8.1 build Gitlab server detailed tutorial
Detailed use of nmcli in CentOS8
Centos7 hadoop cluster installation and configuration
CentOS 6.x compile and install Nginx