Home  >  Article  >  Database  >  How to build a VPS based on Nginx+PHP+MySQL

How to build a VPS based on Nginx+PHP+MySQL

WBOY
WBOYforward
2023-06-02 22:12:12936browse

Currently nginx's worker_processes is set to 4, php-fpm is set to dynamic mode, max_children=32, start_servers=8, min_spare_servers=4, max_spare_servers=16, max_request=512, 540mb of memory remains 380mb, compared to before The optimization effect of lamp memory overhead built with zend server ce is still very obvious, and the website speed is also very ideal. My biggest feeling is that the response speed of page requests is greatly improved than before.
In view of the fact that the new product mysql5.5.8 has been released not long ago, there is a lack of relevant information on the Internet, so I will add some content on compilation (note that I have no need for innodb, so I have blocked the innodb engine. If necessary, I can enable parameters - dwith_innobase_storage_engine=1.

Copy code The code is as follows:

#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 -ddef ault_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: If an error is reported when compiling php error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: no such file or directory, you can Solved by the following method:

Copy code The code is as follows:

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

The above is the detailed content of How to build a VPS based on Nginx+PHP+MySQL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete