登录
首页 >  数据库 >  MySQL

如何在VPS上基于Nginx+PHP+MySQL搭建网站?

来源:亿速云

时间:2023-04-30 14:41:56 501浏览 收藏

知识点掌握了,还需要不断练习才能熟练运用。下面golang学习网给大家带来一个数据库开发实战,手把手教大家学习《如何在VPS上基于Nginx+PHP+MySQL搭建网站?》,在实现功能的过程中也带大家重新温习相关知识点,温故而知新,回头看看说不定又有不一样的感悟!

目前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

理论要掌握,实操不能落!以上关于《如何在VPS上基于Nginx+PHP+MySQL搭建网站?》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!

声明:本文转载于:亿速云 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>