基于gentoo安裝Nginx php mysql的方法
更新時(shí)間:2011年05月02日 13:48:35 作者:
新買的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下crontab的使用與注意事項(xiàng)
這篇文章主要介紹了詳解Linux下crontab的使用與注意事項(xiàng),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01
apachetop 實(shí)現(xiàn)實(shí)時(shí)監(jiān)測(cè)web服務(wù)器運(yùn)行情況
這篇文章主要介紹了apachetop 實(shí)現(xiàn)實(shí)時(shí)監(jiān)測(cè)web服務(wù)器運(yùn)行情況的相關(guān)資料,需要的朋友可以參考下2016-10-10
Linux中驗(yàn)證tar包在傳輸后的完整性的過(guò)程詳解
在日常的系統(tǒng)管理或軟件部署過(guò)程中,文件傳輸是一項(xiàng)常規(guī)操作,特別是當(dāng)處理大型文件(如tar包)時(shí),驗(yàn)證文件的完整性變得尤為重要,本文將介紹如何使用校驗(yàn)和來(lái)驗(yàn)證tar包在從一臺(tái)機(jī)器傳輸?shù)搅硪慌_(tái)機(jī)器后的完整性,需要的朋友可以參考下2023-12-12
Linux通過(guò)匿名管道進(jìn)行進(jìn)程間通信
這篇文章主要介紹了Linux通過(guò)匿名管道進(jìn)行進(jìn)程間通信,介紹了什么是管道,popen函數(shù),pipe調(diào)用等相關(guān)內(nèi)容,小編覺(jué)得還是挺不錯(cuò)的,具有一定借鑒價(jià)值,需要的朋友可以參考下2018-01-01
Ubuntu無(wú)法連接網(wǎng)絡(luò)的解決辦法
這篇文章主要為大家詳細(xì)介紹了虛擬機(jī)中Ubuntu無(wú)法連接網(wǎng)絡(luò)的有效解決辦法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-03-03
Linux如何定時(shí)清空日志內(nèi)容和刪除日志文件
這篇文章主要介紹了Linux如何定時(shí)清空日志內(nèi)容和刪除日志文件,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-12-12
zabbix進(jìn)行數(shù)據(jù)庫(kù)備份以及表分區(qū)的方法
這篇文章主要介紹了zabbix進(jìn)行數(shù)據(jù)庫(kù)備份以及表分區(qū)的方法,需要的朋友可以參考下2015-10-10
Apache網(wǎng)頁(yè)的優(yōu)化、安全與防盜鏈圖文詳解
防盜鏈就是防止別人的網(wǎng)站代碼里面盜用服務(wù)器的圖片、文件、視頻等相關(guān)資源,下面這篇文章主要給大家介紹了關(guān)于Apache網(wǎng)頁(yè)的優(yōu)化、安全與防盜鏈的相關(guān)資料,需要的朋友可以參考下2022-10-10
Linux printf如何將十進(jìn)制轉(zhuǎn)換為十六進(jìn)制
文章總結(jié):介紹了十進(jìn)制、十六進(jìn)制和八進(jìn)制之間的轉(zhuǎn)換方法,包括使用\b命令和bc工具進(jìn)行轉(zhuǎn)換的技巧2024-12-12

