As the application of centos on the server side becomes more and more popular, centos7 is also being used more and more. In the past two years, I have gone from a novice who rarely touches the maintenance of centos server to more and more basic maintenance operations. While it has brought me a lot of troubles, it has also increased my knowledge of setting up and operating centos servers. Today I will record it step by step. 1. Install PHP As WeChat became popular in 2013, the use of PHP has become popular again. Many companies on the market choose to use PHP as their application background. I think the reasons are: 1. The cost of PHP is low 2. Quick introduction 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 in order to complete the project construction. In fact, there are generally two types of software installation on centos. The first is quick installation and the second is compilation and installation. I personally recommend compilation and installation. As for the quick installation method, it is simple and fast. Just load it to the corresponding php source and complete the step-by-step installation process through yum install. Here I will only talk about how to compile and install and the compilation and installation process. The first step is to check whether the system has PHP by default before installation. You can verify it by looking for PHP files or processes. If it is installed and it is not the version we need, you can uninstall the relevant files with the following command: Step 2: Install related PHP dependencies Step 3. Go to the PHP official website http://php.net/downloads.php to view the tar.gz link to be downloaded, as shown in the figure below: List of php versions On this page, select the file source for the country you want to download After selecting the file source, copy the file download link, and download, compile and install it in the system through the wget command. I usually operate in the /usr/local directory. The specific steps are as follows: Enter the operation 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 unzipped file directory: cd php-7.2.10.tar.gz Then compile it with the following command:
Then complete the final compilation and installation with the following command: If there are errors or dependencies during the installation process, you need to solve them according to the specific situation. At this point, we can use the php -v command to check whether the installation is successful. Note: If the version you are viewing is inconsistent with the version you installed, you can find the location of the prompted version file and then delete it, or you can ignore it. After that, we modify the environment variables to point to the file directory we installed. The operation is as follows: First edit the environment variable file: vim /etc/profile Add export PATH="/usr/local/php/bin:$PATH" to the end of the file Where "/usr/local/php/bin" is the specific path for your installation. After saving and exiting, execute the following changes and execute the command: At this time, we use php -v again to view the current version and we can see the version number we installed. 2. Install Nginx Nginx is the most mainstream server software besides Apache, so installing Nginx is also a basic configuration. The compilation and installation methods are similar: The first step is to check and install related dependency packages 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 version link you want to install. The official website address is: http://nginx.org/download/, as shown in the figure below: Nginx version list Copy the corresponding version link and enter the above operation directory, /usr/local to operate 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 unzipped 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 starting, verify whether the service is really started. Use a browser to access the server address to see if it is successfully started. I personally like to verify it through curl http://localhost, because if some server providers prohibit port 80 or the site, it cannot be accessed through an external browser. Of course, you can also use grep or nstat to check whether the corresponding service has been started. At this point, the installation of PHP and nginx under centos7 is over. If you have more centos server configuration exchanges, you can leave a comment at the end of the article. Summarize The above is a detailed tutorial on how to install PHP and Nginx on Centos7. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Three ways to share component logic in React
>>: A brief talk about MySQL semi-synchronous replication
1. Introduction to mysqldump mysqldump is a logic...
Mobile Mobile pages only need to be compatible wi...
This article uses examples to illustrate how to i...
background Since I converted all my tasks to Dock...
need: Usually, sites want to prevent videos and p...
This article example shares the specific code of ...
Table of contents 1. beforeunload event 2. Unload...
Folding display multi-line text component Fold an...
When writing a web project, I encountered an intr...
Preface Not long ago, I saw an interesting proble...
Table of contents Preface Features of Vue Native ...
Table of contents 1. Number in JavaScript 2. Math...
1. What is Continuous Delivery The software produ...
emmm the name is just a random guess 2333 Preface...
Environment Introduction: Ubuntu Server 16.04.2+M...