LNMP notes: Changing the site file and MySQL database storage directory

Source: Internet
Author: User

After configuring the LNMP environment, the default site directory and database storage directory are in the system disk, so we need to transfer them to the data disk.

Change the Web site file directory

If you're using the LNMP one-click installation package, the default virtual host configuration environment is in the/usr/local/nginx/conf/vhost/directory:

vi/usr/local/nginx/conf/vhost/domain name. conf

You can open the corresponding virtual host configuration and then modify the site directory in it. Then execute: cp-a old directory new directory, chown www:www-r new directory.

Change MySQL Directory

1. Shut down the MySQL server:

/etc/init.d/mysql stop

2. The following new directory takes/data/mysql/as an example, and then copies the old directory's database to the new directory:

Cp-r/usr/local/mysql/var/*/data/mysql/

3. Assign the new directory to the MySQL user group:

Chown Mysql:mysql-r/data/mysql/

4. Modify the configuration file again:

Vi/etc/my.cnf

Find [mysqld], add datadir below =/data/mysql/Save

5. Start MySQL:

/etc/init.d/mysql start

LNMP notes: Changing the site file and MySQL database storage directory

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.