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;# }#}