首页 >数据库 >mysql教程 >基于Nginx+PHP+MySQL怎么搭建VPS

基于Nginx+PHP+MySQL怎么搭建VPS

WBOY
WBOY转载
2023-06-02 22:12:12992浏览

目前nginx的worker_processes设置为4,php-fpm设置为dynamic模式,max_children=32,start_servers=8,min_spare_servers=4,max_spare_servers=16,max_request=512的环境下,540mb内存剩余380mb,相比之前用zend server ce搭建的lamp内存开销,优化效果还是十分明显的,而且网站速度也很理想,给我最大的感受就是页面请求的响应速度比以前大大提升了。
鉴于mysql5.5.8这个新产品发布不久,网上的相关资料匮乏,补充一些自己在编译上的内容(注意,我因为自己对innodb无需求,因此屏蔽了innodb引擎,如果需要可以开启参数-dwith_innobase_storage_engine=1。

复制代码 代码如下:

#download software package
wget http://www.cmake.org/files/v2.8/cmake-2.8.3.tar.gz
wget http://ftp.gnu.org/gnu/bison/bison-2.4.3.tar.gz
tar zxvf cmake-2.8.3.tar.gz
cd cmake-2.8.3/
./configure --prefix=/usr
gmake
gmake install
cd ../
tar zxvf bison-2.4.3.tar.gz
cd cd bison-2.4.3
./configure
make
make install

#install mysql5.5.8
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
mkdir -p /data/mysql
chown -r mysql:mysql /data/mysql
tar zxvf mysql-5.5.8.tar.gz
cd mysql-5.5.8
cmake . -dcmake_install_prefix=/usr/local/mysql -dmysql_datadir=/data/mysql -dwithout_innobase_storage_engine=1 -dwith_memory_storage_engine=1 -dwith_myisam_storage_engine=1 -dsysconfdir=/etc/ -dwith_ssl=yes -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci -dwith_readline=on
make
make install
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql --user=mysql

#modify mysql config
vim /etc/my.cnf

[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256m
max_allowed_packet = 1m
table_open_cache = 256
sort_buffer_size = 1m
read_buffer_size = 1m
read_rnd_buffer_size = 4m
myisam_sort_buffer_size = 64m
thread_cache_size = 8
query_cache_size= 16m
thread_concurrency = 1
basedir = /usr/local/mysql
datadir = /data/mysql
default-storage-engine = myisam
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16m
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 128m
sort_buffer_size = 128m
read_buffer = 2m
write_buffer = 2m
[mysqlhotcopy]
interactive-timeout

#add to boot config
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
/etc/rc.d/init.d/mysqld start
/usr/local/mysql/bin/mysql -u root -p -s /tmp/mysql.sock

ps:如果在编译php的时候报错error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: no such file or directory,可以通过以下方法解决:

复制代码 代码如下:

ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16

以上是基于Nginx+PHP+MySQL怎么搭建VPS的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:yisu.com。如有侵权,请联系admin@php.cn删除