Last update at :2023-12-25,Edit by888u
In fact, it is relatively safer to store data on the data disk. In fact, I am now more interested in separating the website and the database! At present, many cloud hosting providers in mainland China have launched database storage services, but we will not discuss this today! For cloud hosting providers in mainland China such as Alibaba Cloud, Tencent Cloud, Western Digital, Huaxia Xiaoyun, etc., it is generally recommended to buy a data disk, that is, separate the system disk and data disk, and save website files and MySQL databases in the data disk. Even if there is a problem with the system disk or environment, resetting the system disk and reconfiguring the environment will not affect the data disk. After configuring the LNmp environment, the default website directory and database storage directory are both in the system disk, so we need to transfer them to the data disk.
Change website file directory
If you are using Junge’s lnmp installation package, the default virtual host configuration environment is in the /usr/local/nginx/conf/vhost/ directory. Modify:
You can open the corresponding virtual host configuration and then modify the website directory in it. Then execute:
cp -a old directory new directorychown www:www -R new directory
Change the MySQL data storage directory
1. Stop the mysql server:
2. Take /storage/mysql/ as an example for the new directory below, and then copy the database of the old directory to the new directory:
cp -R /usr/local/mysql/var/* /storage/mysql/3. Grant the new directory to the mysql user group:
chown mysql:mysql -R /storage/mysql/4. Modify the configuration file again:
vi /etc/my.cnfFind the original directory of mysql data /usr/local/mysql/var and change it to:
datadir = /storage/mysqlinnodb_data_home_dir = /storage/mysql
innodb_log_group_home_dir = /storage/mysql
5. Start mysql:
/etc/init.d/mysql start
Recommended site search: overseas virtual host space, European server, Wanwang registered domain name, domain name free registration 0 yuan registration, Zhengzhou virtual host, mainland China virtual host, website agent registration, Japanese proxy server ip, foreign virtual space, check IP detailed address,
发表评论