This is an article recorded in the log, today while there is time to tidy up. This article records the entire server switch specific steps and implementation details, some small site relocation and server migration can be a reference. At the same time also recorded, convenient for their own inspection. This is a php+mysql written by the site, pre-used by the WINDOWS2003 server. Later, due to business needs, it was replaced with a Linux VPS server.
First, the environment:
Operating system: Linux VPS Server
Server programs: Apache, PHP, and MySQL
Second, the operation steps:
1. Create database, user, authorization and import data
Login database:
- -P
To create a database:
Create database mywebdb;
Create a user (in this case security considerations can also change "%" to "localhost"):
CREATE USER ' myWebDb789 '@ '%' by'mywebdbpwd_456';
Authorization (if the user authorizes "localhost" to be accessible, it needs to be adjusted accordingly):
Grant All Privileges on Mywebdb. * to ' myWebDb789 '@'%'withgrantoption;
Commit Changes:
privileges;
Exit MySQL, and then import the data (double quotation marks if the password has special characters):
mysql-umywebdb789-pmywebdbpwd_456 Myweb</var/www/html/myweb.sql
2 , add IP
To switch directories:
Cd/etc/sysconfig/network-scripts
To create a file:
vi ifcfg-eth0:2
and add the following content
Device="eth0:2"bootproto=staticipaddr= your ipNETMASK = Subnet mask gateway = Gateway nm_controlled="Yes"onboot ="Yes"
Restart the NIC after saving:
/sbin/service Network Restart
To see if the add succeeds:
ifconfig eth0: 2 Link encap:ethernet: b6:wd:1A inet addr: Your IP bcast: Gateway Mask: Subnet mask up broadcast RUNNING multicast MTU: Metric:1 Interrupt: Base Address:0xe000
3, upload the program decompression and modify the database user and password
4. Configure Apache
Switch directories
Cd/usr/local/apache2/conf
Backup configuration file
CP httpd.conf Httpd.conf_bak
Add IP port Listener, service name
VI httpd.conf
#添加ip端口监听Listen Your IP: your IP
Virtual directory configuration, add the following content
Namevirtualhost Your IP: the<virtualhost Your IP: the>DocumentRoot"/var/www/html/myweb/"#你web程序的根目录 errorlog"|/usr/local/apache2/bin/rotatelogs/var/www/html/myweb/logs/error_log_%y%m%d 86400"#你的error日志路径 ServerName www.myweb.com #你的域名 customlog"|/usr/local/apache2/bin/rotatelogs/var/www/html/myweb/logs/access_log_%y%m%d 86400"combined #你的访问日志路径</virtualhost><directory"/var/www/html/myweb/">#你web程序的根目录 Options-Indexes followsymlinks allowoverride all Order allow,deny</Directory>
Restart Apache
Service httpd Restart
5. See if the configuration is successful
http:// your IP (or domain name)/
Note, sometimes there will be a lot of unexpected problems resulting in inaccessible, then you need to solve the flexibility, the following are the problems you may encounter:
- There may be a problem with permissions, so you can change directory permissions through chmod, chown change directory Users, and so on, to keep your site up and running.
- It may also be inaccessible due to a firewall problem in the engine room.
- What's more, the DNS cache is too heavy to take effect temporarily.
Remember the site server relocation record