基于gentoo安裝Nginx php mysql的方法
更新時(shí)間:2011年05月02日 13:48:35 作者:
新買(mǎi)的VPS。在上面部署了nginx mysql php。需要的朋友可以參考下。
1、先在/etc/make.conf加入sync站點(diǎn),待會(huì)兒要用emerge進(jìn)行同步。
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
在執(zhí)行 emerge --sync 同步portage樹(shù)。
2、升級(jí)portage 版本,要不待會(huì)兒安裝mysql的時(shí)候會(huì)提示portage 版本舊的!
emerge portage
先定義USE:
/etc/portage/package.use
dev-lang/php cli ming xml ftp curl pdo mysqli mysql sqlite json cgi ctype gd hash
www-servers/nginx fastcgi
編輯/etc/portage/package.keywords
www-servers/spawn-fcgi ~x86
3、安裝 mysql nginx php spawn-fcgi pecl-apc pecl-memcache。
emerge mysql nginx php spawn-fcgi pecl-apc pecl-memcache
4、配置mysql。
mkdir -p /data0/mysql/data
mysql_install_db --user=mysql --basedir=/usr --datadir=/data0/mysql/data
配置my.cnf
rm -f /etc/mysql/my.cnf
vim /etc/mysql/my.cnf
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysql]
prompt="(\u:s135[\d]> "
no-auto-rehash
[mysqld]
bind-address = 173.252.207.109
user = mysql
port = 3306
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
datadir = /data0/mysql/data
open_files_limit = 600
back_log = 20
max_connections = 100
max_connect_errors = 200
table_cache = 60
external-locking = FALSE
max_allowed_packet = 16M
sort_buffer_size = 128K
join_buffer_size = 128K
thread_cache_size = 10
thread_concurrency = 8
query_cache_size = 0M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default_table_type = MyISAM
thread_stack = 192K
transaction_isolation = READ-UNCOMMITTED
tmp_table_size = 512K
max_heap_table_size = 32M
/var/log/slow.log
/var/log/error.log
long_query_time = 1
log_long_format
server-id = 1
#log-bin = /usr/local/mysql/data/binlog
binlog_cache_size = 2M
max_binlog_cache_size = 4M
max_binlog_size = 512M
expire_logs_days = 7
key_buffer_size = 4M
read_buffer_size = 1M
read_rnd_buffer_size = 2M
bulk_insert_buffer_size = 2M
myisam_sort_buffer_size = 4M
myisam_max_sort_file_size = 10G
myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
[mysqldump]
quick
max_allowed_packet = 16M
mysqladmin -uroot password ""
啟動(dòng)mysql
/etc/init.d/mysql start
5、配置nginx
vim /etc/nginx/nginx.conf
user nginx nginx;
worker_processes 1;
error_log /var/log/nginx/nginx_error.log crit;
pid /var/run/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 52100;
events
{
use epoll;
worker_connections 52100;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
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 70 20;
tcp_nodelay on;
server_tokens off;
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 off;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
server
{
server_name www.freebsdsystem.org;
root /data0/www/wwwroot/;
index index.html index.htm index.php;
location ~ .*\.php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
log_format blog '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /var/log/nginx/blog.log blog;
}
}
配置spawn-fcgi
vim /usr/local/bin/php-fcgi
#!/bin/sh
# author:coralzd
# powered by www.freebsdsystem.org
bin=/usr/bin/php-cgi
case $1 in
start)
echo "starting php-cgi"
spawn-fcgi -a 127.0.0.1 -p 9000 -C 8 -u nginx -g nginx -f /usr/bin/php-cgi 2>&1 >/dev/null &
echo "Done"
stop)
killall php-cgi
echo "php-cgi stop"
*)
echo "usage start|stop";;
esac
6、開(kāi)機(jī)啟動(dòng) nginx mysql
rc-update add nginx default
rc-update add mysql default
至此配置完成!
復(fù)制代碼 代碼如下:
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
在執(zhí)行 emerge --sync 同步portage樹(shù)。
2、升級(jí)portage 版本,要不待會(huì)兒安裝mysql的時(shí)候會(huì)提示portage 版本舊的!
復(fù)制代碼 代碼如下:
emerge portage
先定義USE:
復(fù)制代碼 代碼如下:
/etc/portage/package.use
dev-lang/php cli ming xml ftp curl pdo mysqli mysql sqlite json cgi ctype gd hash
www-servers/nginx fastcgi
編輯/etc/portage/package.keywords
www-servers/spawn-fcgi ~x86
3、安裝 mysql nginx php spawn-fcgi pecl-apc pecl-memcache。
復(fù)制代碼 代碼如下:
emerge mysql nginx php spawn-fcgi pecl-apc pecl-memcache
4、配置mysql。
復(fù)制代碼 代碼如下:
mkdir -p /data0/mysql/data
mysql_install_db --user=mysql --basedir=/usr --datadir=/data0/mysql/data
配置my.cnf
復(fù)制代碼 代碼如下:
rm -f /etc/mysql/my.cnf
vim /etc/mysql/my.cnf
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysql]
prompt="(\u:s135[\d]> "
no-auto-rehash
[mysqld]
bind-address = 173.252.207.109
user = mysql
port = 3306
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
datadir = /data0/mysql/data
open_files_limit = 600
back_log = 20
max_connections = 100
max_connect_errors = 200
table_cache = 60
external-locking = FALSE
max_allowed_packet = 16M
sort_buffer_size = 128K
join_buffer_size = 128K
thread_cache_size = 10
thread_concurrency = 8
query_cache_size = 0M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default_table_type = MyISAM
thread_stack = 192K
transaction_isolation = READ-UNCOMMITTED
tmp_table_size = 512K
max_heap_table_size = 32M
/var/log/slow.log
/var/log/error.log
long_query_time = 1
log_long_format
server-id = 1
#log-bin = /usr/local/mysql/data/binlog
binlog_cache_size = 2M
max_binlog_cache_size = 4M
max_binlog_size = 512M
expire_logs_days = 7
key_buffer_size = 4M
read_buffer_size = 1M
read_rnd_buffer_size = 2M
bulk_insert_buffer_size = 2M
myisam_sort_buffer_size = 4M
myisam_max_sort_file_size = 10G
myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
[mysqldump]
quick
max_allowed_packet = 16M
mysqladmin -uroot password ""
啟動(dòng)mysql
/etc/init.d/mysql start
5、配置nginx
vim /etc/nginx/nginx.conf
復(fù)制代碼 代碼如下:
user nginx nginx;
worker_processes 1;
error_log /var/log/nginx/nginx_error.log crit;
pid /var/run/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 52100;
events
{
use epoll;
worker_connections 52100;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
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 70 20;
tcp_nodelay on;
server_tokens off;
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 off;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
server
{
server_name www.freebsdsystem.org;
root /data0/www/wwwroot/;
index index.html index.htm index.php;
location ~ .*\.php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
log_format blog '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /var/log/nginx/blog.log blog;
}
}
配置spawn-fcgi
復(fù)制代碼 代碼如下:
vim /usr/local/bin/php-fcgi
#!/bin/sh
# author:coralzd
# powered by www.freebsdsystem.org
bin=/usr/bin/php-cgi
case $1 in
start)
echo "starting php-cgi"
spawn-fcgi -a 127.0.0.1 -p 9000 -C 8 -u nginx -g nginx -f /usr/bin/php-cgi 2>&1 >/dev/null &
echo "Done"
stop)
killall php-cgi
echo "php-cgi stop"
*)
echo "usage start|stop";;
esac
6、開(kāi)機(jī)啟動(dòng) nginx mysql
復(fù)制代碼 代碼如下:
rc-update add nginx default
rc-update add mysql default
至此配置完成!
相關(guān)文章
linux安裝部署ftp圖片服務(wù)器的實(shí)現(xiàn)方法
這篇文章主要介紹了linux安裝部署ftp圖片服務(wù)器的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06linux操作系統(tǒng)下配置ssh/sftp和權(quán)限設(shè)置方法
這篇文章主要介紹了linux操作系統(tǒng)下配置ssh/sftp和權(quán)限設(shè)置方法 ,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-11-11ubuntu16.04 升級(jí)內(nèi)核的方法步驟
這篇文章主要介紹了ubuntu16.04 升級(jí)內(nèi)核的方法步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08關(guān)于linux分區(qū),文件系統(tǒng),目錄結(jié)構(gòu)的概述
下面小編就為大家?guī)?lái)一篇關(guān)于linux分區(qū),文件系統(tǒng),目錄結(jié)構(gòu)的概述。小編覺(jué)得挺不錯(cuò)的?,F(xiàn)在就分享給大家。也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-12-12Linux命令學(xué)習(xí)總結(jié)之rmdir命令
這篇文章主要介紹了Linux命令學(xué)習(xí)總結(jié)之rmdir命令的相關(guān)資料,需要的朋友可以參考下2016-01-01Linux使用定時(shí)任務(wù)每周定時(shí)清理45天以前日志
linux是一個(gè)很能自動(dòng)產(chǎn)生文件的系統(tǒng),日志、郵件、備份等。雖然現(xiàn)在硬盤(pán)廉價(jià),我們可以有很多硬盤(pán)空間供這些文件浪費(fèi),讓系統(tǒng)定時(shí)清理一些不需要的文件很有一種爽快的事情。有需要的朋友看一下。2016-10-10