|
系统优化完毕后、防火墙我们也安装好、今天我们接着讲如何安装生产环境,服务器运行环境安装篇,安装PHP环境有两种方式安装,一种是二进制安装,另一种是ports源码安装篇,
一、安装更新ports包
portsnap fetch extract
二、安装NGINX
cd /usr/ports/www/nginx
make install clean
一路默认回车即可 设置开机启动:
echo nginx_enable="YES" >> /etc/rc.conf
三、安装MYSQL57
cd /usr/ports/databases/mysql57-server
make install clean
一路默认回车即可 设置开机启动:
echo mysql_enable="YES" >> /etc/rc.conf
四、安装PHP74
(1)
cd /usr/ports/lang/php74
make config
make install clean
一路默认回车即可 设置开机启动:
echo php_fpm_enable="YES" >> /etc/rc.conf
(2)
安装PHP74扩展
cd /usr/ports/lang/php74-extensions
make config
make install clean
五、安装Memcache扩展
cd /usr/ports/databases/pecl-memcache
make install clean
六、安装Memcached扩展
cd /usr/ports/databases/pecl-memcached
make install clean
七、安装Memcached服务器
cd /usr/ports/databases/memcached
make install clean
一路默认回车即可 设置开机启动:
echo memcached_enable="YES" >> /etc/rc.conf
八、安装Redis
cd /usr/ports/databases/redis
make install clean
一路默认回车即可 设置开机启动:
echo redis_enable="YES" >> /etc/rc.conf
九、安装PHP redis PHP扩展
cd /usr/ports/databases/pecl-redis
make install clean
一路默认回车即可
二 配置篇
一、配置nginx .conf
user www www;
worker_processes auto;
worker_cpu_affinity auto;
worker_rlimit_nofile 51200;
events {
use kqueue;
worker_connections 51200;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
server_tokens off;
fastcgi_intercept_errors on;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml
gzip_vary on;
server
{
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name _;
index index.html index.htm index.php;
root /home/wwwroot/default;
#error_page 404 /404.html;
[striped]# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }[/striped]
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{ deny all;
}
access_log /home/wwwlogs/access.log;
}
include vhost/*.conf;
}
2、配置php
cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini
3、重启系统
reboot |
|