How to install nginx and then php: first install PHP and PHP-FPM through "yum install php php-fpm"; then start php-fpm; then associate PHP with the mysql module; finally configure nginx Just works with php.
The operating environment of this article: centOS6.8 system, PHP7.1 version, DELL G3 computer
How to install php after nginx is installed ?
Install PHP and PHP-FPM
1 |
|
Start php-fpm
1 |
|
Associate PHP with the mysql module
This is the mariadb database
Installation
1 |
|
Association
1 |
|
Configure nginx to work with php
Open the nginx main configuration file.
1 |
|
Add configuration in the http module:
1 2 3 4 5 6 7 8 9 10 11 |
|
Change nginx default fastcgiparams configuration file: vim /etc/nginx/fastcgi_params Add two lines at the end of the file:
1 2 |
|
Then restart the service:
1 2 |
|
Run
Create an index.php file in the root directory of the website
The content of the file is as follows:
1 2 3 |
|
Tips that the default website root directory installed by yum in nginx is /usr/share/nginx/html
So create a new file in this folder
It can be run and accessed under normal circumstances php file.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to install php after installing nginx. For more information, please follow other related articles on the PHP Chinese website!