freebsd10下安装Nginx+php56+mysql56其实很简单,只是很多PHP组件怎么装?网上少有提及,我来给大家一个比较全的安装命令吧。
引用
pkg install nginx php56 php56-extensions php56-mysql php56-mysqli php56-mbstring php56-soap php56-gd php56-curl php56-bz2 php56-mcrypt php56-xsl php56-ftp php56-pdo_mysql php56-sockets php56-tidy mysql56-server


引用
pkg install nginx php70 php70-extensions php70-mysqli php70-mbstring php70-soap php70-gd php70-curl php70-bz2 php70-mcrypt php70-xsl php70-ftp php70-pdo_mysql php70-sockets php70-tidy mysql57-server

这样一句命令就把这些都装完了。剩下的就是配置了。
首先在启动中加入开启服务命名。
引用
# ee /etc/rc.conf
在最后加入下面三句
nginx_enable="YES"
php_fpm_enable="YES"
mysql_enable="YES"

完成下面的步骤,才可以重启服务器啊,否则会有rc.conf报错
配置mysql
引用
# ee /usr/local/etc/my.cnf
[mysqld]
socket = /tmp/mysql.sock

skip-networking
skip-name-resolve
然后启动mysql
# service mysql-server start
修改root的密码
# /usr/local/bin/mysqladmin -u root password '你的密码'

配置 PHP
引用
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
# ee php.ini
修改post_max_size = 200M
upload_max_filesize = 200M
max_file_uploads = 100
display_errors = On

配置php-fpm
引用

# ee /usr/local/etc/php-fpm.conf
修改
pm.max_children = 300
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 10240
启动php-fpm
# service php-fpm start

配置Nginx
引用

建立日志目录
# mkdir /var/log/nginx/
编辑nginx配置文件
# ee /usr/local/etc/nginx/nginx.conf
写入下面内容
user  www www;
worker_processes 8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
worker_rlimit_nofile 204800;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        /var/run/nginx.pid;


events {
   use kqueue;
   multi_accept on;
   worker_connections  204800;
}


http {
   server_tokens off;
   sendfile on;
   tcp_nopush on;
   tcp_nodelay on;

   access_log off;
   error_log /var/log/nginx/error.log crit;

   keepalive_timeout 60;
   client_header_timeout 10;
   client_body_timeout 10;
   reset_timedout_connection on;
   send_timeout 10;

   limit_conn_zone $binary_remote_addr zone=addr:5m;
   limit_conn addr 100;

   include mime.types;
   default_type application/octet-stream;
   charset UTF-8;

   gzip on;
   gzip_disable "msie6";
   gzip_proxied any;
   gzip_min_length 1k;
   gzip_buffers 4 16k;
   gzip_comp_level 6;
   gzip_vary on;
   gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

   open_file_cache max=204800 inactive=20s;
   open_file_cache_valid 30s;
   open_file_cache_min_uses 2;
   open_file_cache_errors on;
   server_names_hash_bucket_size 128;
   client_header_buffer_size 2k;
   large_client_header_buffers 4 4k;
   client_max_body_size 8m;
   fastcgi_connect_timeout 300;
   fastcgi_send_timeout 300;
   fastcgi_read_timeout 300;
   fastcgi_buffer_size 4k;
   fastcgi_buffers 8 4k;
   fastcgi_busy_buffers_size 8k;
   fastcgi_temp_file_write_size 8k;
   fastcgi_cache_valid 200 302 1h;
   fastcgi_cache_valid 301 1d;
   fastcgi_cache_valid any 1m;
   fastcgi_cache_min_uses 1;
   upstream fastcgi_backend {
       server 127.0.0.1:9000;
       keepalive 60;
   }
   #include       mime.types;
   #default_type  application/octet-stream;

   #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
   #                  '$status $body_bytes_sent "$http_referer" '
   #                  '"$http_user_agent" "$http_x_forwarded_for"';

   #access_log  logs/access.log  main;

   #sendfile        on;
   #tcp_nopush     on;

   #keepalive_timeout  0;
   #keepalive_timeout  65;

   #gzip  on;

   server {
       listen       80;
       server_name  localhost;

       #charset koi8-r;

       #access_log  logs/host.access.log  main;

       location / {
           root   /usr/local/www/nginx;
           index  index.html index.htm index.php;
     #try_files $uri $uri/ /index.php$uri?$args;

       }

       #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/local/www/nginx-dist;
       }
 location ~ ^/(status)$ {
      access_log off;
      include fastcgi_params;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_param SCRIPT_FILENAME /usr/loca/www/nginx$fastcgi_script_name;
 }

 location /myadmin {
      alias /usr/local/www/phpMyAdmin;
            index index.php;
 }
 location ~ /myadmin/.+\.php$ {
      if ($fastcgi_script_name ~ /myadmin/(.+\.php.*)$) {
          set $valid_fastcgi_script_name $1;
      }
      include fastcgi_params;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param SCRIPT_FILENAME /usr/local/www/phpMyAdmin/$valid_fastcgi_script_name;
 }
       # proxy the PHP scripts to Apache listening on 127.0.0.1:80
       #
       #location ~ \.php$ {
       #    proxy_pass   http://127.0.0.1;
       #}

       # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
       #
       location ~ \.php$ {
     fastcgi_pass 127.0.0.1:9000;
     fastcgi_index index.php;
     include fastcgi_params;
     fastcgi_split_path_info ^(.+\.php)(/?.*)$;
     fastcgi_param PATH_INFO $fastcgi_path_info;        
     fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx$fastcgi_script_name;

           #root           html;
     #fastcgi_pass fastcgi_backend;
     #fastcgi_keep_conn on;
       }

       # deny access to .htaccess files, if Apache's document root
       # concurs with nginx's one
       #
       #location ~ /\.ht {
       #    deny  all;
       #}
   }


   # another virtual host using mix of IP-, name-, and port-based configuration
   #
   #server {
   #    listen       8000;
   #    listen       somename:8080;
   #    server_name  somename  alias  another.alias;

   #    location / {
   #        root   html;
   #        index  index.html index.htm;
   #    }
   #}


   # HTTPS server
   #
   #server {
   #    listen       443 ssl;
   #    server_name  localhost;

   #    ssl_certificate      cert.pem;
   #    ssl_certificate_key  cert.key;

   #    ssl_session_cache    shared:SSL:1m;
   #    ssl_session_timeout  5m;

   #    ssl_ciphers  HIGH:!aNULL:!MD5;
   #    ssl_prefer_server_ciphers  on;

   #    location / {
   #        root   html;
   #        index  index.html index.htm;
   #    }
   #}

}
启动nginx
# service nginx start

测试是否工作正常
引用
# ee /usr/local/www/nginx/info.php
写入下面的内容
<?php phpinfo(); ?>

用浏览器访问http://IP/info.php,如果能看到就说明工作正常了。

FreeBSD | 评论(0) | 引用(0) | 阅读(7670)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]