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

Build LNMP by Ubuntu14.04

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Operation steps (for specific documents, please contact this blogger, there is a blogger's email address on the home page)

1. Update

two。 Install Nginx

3. Install MySQL

# enter the same password twice in a row

4. Install PHP

5. Configure PHP, modify php.ini file

Set cgi.fix_pathinfo=1 to cgi.fix_pathinfo=0

Start php-fpmsudo

6. Configure Nginx to use the php-fpm process

Backing up / etc/nginx/sites-available/default files

7. Modify default configuration file to support PHP

Here are the configuration file details

[...]

Server {

Listen 80

Listen [::]: 80 default_server ipv6only=on

Root / usr/share/nginx/html

Index index.php index.html index.htm

# Make site accessible from http://localhost/

Server_name _

Location / {

# First attempt to serve request as file, then

# as directory, then fall back to displaying a 404.

Try_files $uri $uri/ / index.html

# Uncomment to enable naxsi on this location

# include / etc/nginx/naxsi.rules

}

Location / doc/ {

Alias / usr/share/doc/

Autoindex on

Allow 127.0.0.1

Allow:: 1

Deny all

}

# Only for nginx-naxsi used with nginx-naxsi-ui: process denied requests

# location / RequestDenied {

# proxy_pass http://127.0.0.1:8080;

#}

# error_page 404 / 404.html

# redirect server error pages to the static page / 50x.html

#

Error_page 500 502 503 504 / 50x.html

Location = / 50x.html {

Root / usr/share/nginx/html

}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

Location ~ .php ${

Try_files $uri = 404

Fastcgi_split_path_info ^ (. + .php) (/. +) $

# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

# With php5-cgi alone:

# fastcgi_pass 127.0.0.1:9000

# With php5-fpm:

Fastcgi_pass unix:/var/run/php5-fpm.sock

Fastcgi_index index.php

Include fastcgi_params

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

Location ~ / .ht {

Deny all

}

}

[...]

Cancel port 80 that listens on both IPv4 and IPv6.

Server_name _; default hostname (of course you can change it, for example: www.example.com).

In the line of index home page, we join index.php.

PHP important configuration configuration location ~ .php ${} these lines we need to start and uncomment. Add another line: try_files $uri = 404.

8. Reload nginx

9. Modify PHP configuration file

Modify # cgi.fix_pathinfo=1 to cgi.fix_pathinfo=0:

[...]

; cgi.fix_pathinfo provides * real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's

; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok

; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting

; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting

; of zero causes PHP to behave as before. Default is 1. You should fix your scripts

; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.

; http://php.net/cgi.fix-pathinfo

Cgi.fix_pathinfo=0

[...]

10. Reload PHP-FPM:

11. Now create a probe file and save it in the / usr/share/nginx/html directory

Vi / usr/share/nginx/html/index.php

The successful PHP version is

PHP logo

PHP Version 5.5.9-1ubuntu4.21

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

Servers

Wechat

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

12
Report