Ubuntu14.04搭建LNMP
一、操作步驟 (具體文件請聯絡本博主,首頁有博主郵箱)
1.更新
2.安裝Nginx
3.安裝MySQL
# 連續輸入兩次相同的密碼
4.安裝PHP
5.配置PHP,修改php.ini檔案
將cgi.fix_pathinfo=1 設定為 cgi.fix_pathinfo=0
啟動php-fpmsudo
6.配置Nginx讓其使用php-fpm程式
備份/etc/nginx/sites-available/default檔案
7.修改default配置檔案支援PHP
下邊是配置檔案詳細資訊
[…]
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;
}
}
[…]
取消同時偵聽 IPv4 和 IPv6 的80埠。
server_name _; 預設主機名 (當然你可以修改,例如修改為: www.example.com).
index主頁這一行我們加入 index.php。
PHP 重要配置配置 location ~ .php$ {} 這幾行我們需要啟動,反註釋掉。另外再新增一行:try_files $uri =404。
8.重新載入nginx
9.修改PHP配置檔案
修改 #cgi.fix_pathinfo=1: 為 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.重新載入 PHP-FPM:
11.現在建立一個探針檔案儲存在 /usr/share/nginx/html目錄下
vi /usr/share/nginx/html/index.php
搭建成功PHP版本為
PHP logo
PHP Version 5.5.9-1ubuntu4.21
相關文章
- 搭建lnmp環境LNMP
- LNMP 環境搭建LNMP
- 搭建LNMP架構LNMP架構
- docker 搭建 lnmp 環境DockerLNMP
- docker搭建lnmp環境DockerLNMP
- Windows 下搭建 lnmp 環境WindowsLNMP
- LNMP環境搭建(二):NginxLNMPNginx
- 阿里雲centOS下LNMP搭建阿里CentOSLNMP
- docker下LNMP環境搭建DockerLNMP
- PHP-lnmp 環境搭建PHPLNMP
- Docker LNMP Redis 環境搭建DockerLNMPRedis
- 搭建 lnmp 環境之 nginx 篇LNMPNginx
- Deepin 15 搭建 LNMP 環境 + swooleLNMP
- Dockfile搭建極簡LNMP環境LNMP
- docker 學習筆記之實戰 lnmp 環境搭建系列 (2) ------ 手動搭建 lnmp 環境Docker筆記LNMP
- 利用 Docker 一鍵搭建 LNMP 環境DockerLNMP
- docker搭建laravel開發環境lnmpDockerLaravel開發環境LNMP
- 雲伺服器怎麼搭建lnmp伺服器LNMP
- LNMP網站框架搭建(編譯安裝)LNMP網站框架編譯
- Nginx網站服務LNMP搭建論壇Nginx網站LNMP
- Ubuntu18.04 桌面版 搭建 LNMP 環境UbuntuLNMP
- 快速搭建 Linux(LNMP + Linux 安裝 + 環境配置)LinuxLNMP
- CentOS 7 使用 docker 搭建基本的 lnmp 環境CentOSDockerLNMP
- Ubuntu Server 16.04.1 LTS 64位 搭建LNMP環境UbuntuServerLNMP
- 畫江湖之 docker 篇 【lnmp 環境基礎搭建】DockerLNMP
- 畫江湖之 docker 篇 [lnmp 環境基礎搭建]DockerLNMP
- LNMP環境VPS搭建織夢DEDECMS網站教程LNMP網站
- Linux 上部署 docker,基於 docker 搭建 lnmp 環境LinuxDockerLNMP
- Inmp-(2)在ubuntu18.04中搭建lnmp環境UbuntuLNMP
- 記錄一次 LNMP 環境搭建到 Https 配置LNMPHTTP
- ubuntu14.04 升級gcc的方法UbuntuGC
- 基於LNMP的WordPress搭建與速度最佳化實踐LNMP
- 伺服器LNMP環境搭建的一些問題伺服器LNMP
- 在ubuntu14.04上配置SNMPv3Ubuntu
- Ubuntu14.04 安裝搜狗輸入法Ubuntu
- 小白折騰伺服器(一):docker 搭建 lnmp+ 使用 deployer 部署伺服器DockerLNMP
- lnmp完美搭建核心thinkphp5的易優CMS站點配置LNMPPHP
- LNMP 分散式叢集(四):Memcached 快取伺服器的搭建LNMP分散式快取伺服器
- 阿里雲體驗實驗室 教你如何《快速搭建LNMP環境》阿里LNMP