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