1.安裝mysqlphp
安裝過程當中要輸入root用戶的密碼。html
我在安裝中出錯,是原來的mysql-cilent mysql-workbench 未徹底卸載,將mysql組件徹底卸載的方法:mysql
刪除mysql前 先刪除一下 /var/lib/mysql 還有 /etc/mysqlnginx
所有刪除以後再執行 apt-get install mysql-server mysql -client 正則表達式
2.安裝nginxsql
3.安裝成功後。咱們重啓下nginx服務apache
啓動以後咱們就能夠訪問如下咱們的地址了。看能不能出現nginx的歡迎界面。ubuntu
4.這裏咱們使用php5-fpm來做爲咱們的php解析。服務器
5.接下來咱們要修改一下nginx的站點配置了。
session
ngnix的配置文件存放在/etc/nginx/sites-availble/default
6.咱們在安裝php5相關的一些組件。
7.重啓服務
經測試,如今應該已經安裝成功了。
PHP擴展的安裝方式一般分爲兩種:
1. 隨同PHP編譯
2. 生成單獨的.so文件
這裏介紹第二種方式,對於第二種方式執行效率可能低些,可是模塊化,就是能夠保持php安裝不變的狀況下,經過php.ini鏈接單獨生成的so文件實現擴展,
好比您已經經過了tar包方式安裝了php,那麼如今想增長擴展:
安裝CURL擴展
I. 生成動態連接庫文件.SO
方法以下:
方法1. apt-get install php5-curl
方法2. 去PHP網站下載tar包,phpize本地編譯生成.so
方法3. pear方式安裝,經過pecl命令去在線下載編譯生成.so
方法1在ubuntu下是最簡單的,命令執行完會告知.so所在目錄
II. 配置php.ini
打開php.ini,指定extension_dir目錄,若是extension_dir = '/usr/lib',那麼接下來把生成的.so文件(如curl.so)複製到/usr/lib目錄下,而且加入一個新條目:
extension=curl.so
III. 使之生效
從新啓動apache,運行phpinfo()看是否生效
安裝PDO_MYSQL擴展
採用pear方式安裝
I. 安裝pear
apt-get install php-pear 若是沒有pear要先安裝pear
II. 安裝pdo,pdo_mysql
pecl install pdo pecl install pdo_mysql
生成.so複製到/usr/lib目錄下.
若是沒有安裝php和mysql的開發包,在執行第II步以前還須要安裝
apt-get install php5-devapt-get install libmysqlclient15-dev
III. 修改配置文件php.ini
增長條目
extension=pdo.so
extension=pdo_mysql.so
IV. 使之生效
從新啓動apache,運行phpinfo()看是否生效
在php5.2.10中,php默認已經安裝了pdo,因此extension=pdo.so不加,可是發現和本身生成的pdo_mysql.so不匹配錯誤,解決辦法是:
從新安裝php,增長參數--disable-pdo 禁止pdo模塊,用本身前面生成pdo.so,pdo+mysql.so就OK了
安裝ImageMagic擴展
採用pear方式安裝
I. 安裝ImageMagick
sudo apt-get install imagemagick
II. 安裝imagemagick 的lib 供php調用
sudo apt-get install libmagick++-dev
III. 調用當前的pecl安裝imagick
pecl install imagick
IV. 修改php.ini.重啓apache服務器
在php.ini中添加: extension = imagick.so
phpize的安裝
phpize是屬於php-devel的內容,因此只要運行
apt-get install php-devel就行。ubuntu 下是 apt-get install php-dev
我安裝的時候裝的是php5-dev
裝完以後是用phpize5來裝本身編寫的php擴展
本人轉自 http://blog.csdn.net/zhxp_870516/article/details/8520358
同時也參考了 http://blog.slps.tp.edu.tw/00086/?p=585
下面是我本身的defalut 文件內容 #的是註釋 由於有的爲了tp整合 支持pathinfo 因此有不少註釋沒去掉,能夠參考上面原做者的default配置 這一段我和原做者不同
/*
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;
}
*/
如下是defautl的配置
# You may add here your# server {# ...# }# statements for each of your virtual hosts to this file### You should look at the following URL's in order to grasp a solid understanding# of Nginx configuration files in order to fully unleash the power of Nginx.# http://wiki.nginx.org/Pitfalls# http://wiki.nginx.org/QuickStart# http://wiki.nginx.org/Configuration## Generally, you will want to move this file somewhere, and start with a clean# file but keep this around for reference. Or just disable in sites-enabled.## Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.##server { listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default ipv6only=on; ## listen for ipv6 server_name bbb.test.pt; root /usr/share/nginx/www; index index.php index.html index.htm; #index index.php #1.php # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } # include /etc/nginx/naxsi.rules } location /doc/ { root /usr/share/; autoindex on; allow 127.0.0.1; deny all; } # Only for nginx-naxsi : process denied requests #location /RequestDenied { # For example, return an error code #return 418; #} #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/www; } # 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; }############################### #去掉$是爲了避免匹配行末,便可以匹配.php/,以實現pathinfo #若是你不須要用到php5後綴,也能夠將其去掉# location ~ .php# { #原有代碼 #定義變量 $path_info ,用於存放pathinfo信息 # set $path_info ""; #定義變量 $real_script_name,用於存放真實地址 # set $real_script_name $fastcgi_script_name; #若是地址與引號內的正則表達式匹配 # if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { #將文件地址賦值給變量 $real_script_name # set $real_script_name $1; #將文件地址後的參數賦值給變量 $path_info # set $path_info $2; # } #配置fastcgi的一些參數 # fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; # fastcgi_param SCRIPT_NAME $real_script_name; # fastcgi_param PATH_INFO $path_info; # }####### #若是請求既不是一個文件,也不是一個目錄,則執行一下重寫規則 # if (!-e $request_filename) # { #地址做爲將參數rewrite到index.php上。 # rewrite ^/(.*)$ /index.php/$1; #如果子目錄則使用下面這句,將subdir改爲目錄名稱便可。 #rewrite ^/subdir/(.*)$ /subdir/index.php/$1; # }#################################### # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; }# include /etc/nginx/conf.d/*}#include /etc/nginx/conf.d/*;# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# root html;# index index.html index.htm;## location / {# try_files $uri $uri/ /index.html;# }#}# HTTPS server##server {# listen 443;# server_name localhost;## root html;# index index.html index.htm;## ssl on;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;## ssl_session_timeout 5m;## ssl_protocols SSLv3 TLSv1;# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;# ssl_prefer_server_ciphers on;## location / {# try_files $uri $uri/ /index.html;# }#}