EdwardElricNavigate back to the homepage

Ubuntu 安裝 php

Edward Elric
February 6th, 2016 · 1 min read
  1. 安装 apt 源管理工具、添加 nginx 和 php 的安装源
1apt-get install python-software-properties
2add-apt-repository ppa:nginx/stable
3add-apt-repository ppa:ondrej/php5
  1. 更新系统软件
1apt-get update
  1. 安装 mysql
1apt-get install mysql-server mysql-client
  1. 安装 php 及对 mysql 的支持
1apt-get install php5-fpm php5-mysql
  1. 根据实际需要,选择性的安装 php 的各类功能模块
1apt-get install php-pear php5-dev php5-curl
2apt-get install php5-gd php5-intl php5-imagick
3apt-get install php5-imap php5-mcrypt php5-memcache
4apt-get install php5-ming php5-ps php5-pspell
5apt-get install php5-recode php5-snmp php5-sqlite
6apt-get install php5-tidy php5-xmlrpc php5-xsl
  1. 安装 nginx
1apt-get install nginx
  1. 修改 nginx 默认站点配置文件
1vim /etc/nginx/sites-available/default
2
3server {
4 listen 80 default_server;
5 listen [::]:80 default_server ipv6only=on;
6
7 root /usr/share/nginx/html;
8 index index.php index.html index.htm;
9
10 server_name server_domain_name_or_IP;
11
12 location / {
13 try_files $uri $uri/ =404;
14 }
15
16 error_page 404 /404.html;
17 error_page 500 502 503 504 /50x.html;
18 location = /50x.html {
19 root /usr/share/nginx/html;
20 }
21
22 location ~ \.php$ {
23 try_files $uri =404;
24 fastcgi_split_path_info ^(.+\.php)(/.+)$;
25 fastcgi_pass unix:/var/run/php5-fpm.sock;
26 fastcgi_index index.php;
27 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
28 include fastcgi_params;
29 }
30}

Join our email list and get notified about new content

Be the first to receive our latest content with the ability to opt-out at anytime. We promise to not spam your inbox or share your email with any third parties.

More articles from Edward Elric

Play Framework項目初始化

安裝 Activator 先下載 Activator 解壓到 D:\Program Files\activator-1.3.2 將 D:\Program Files\activator-1.3.2 加到環境變量 Path…

May 23rd, 2015 · 1 min read

Ubuntu安裝java8

添加 ppa 更新系統 安裝 java8 檢測是否成功 結果如下 設置環境變量 版本切換

May 23rd, 2015 · 1 min read
© 2015–2020 Edward Elric
Link to $https://twitter.com/sasuke688848Link to $https://github.com/sasuke40Link to $https://www.linkedin.com/in/sasuke/