Installing Apache+php+ftp+mysql on VM virtual machines

Source: Internet
Author: User
Tags iptables server port

I want to install WinXP and Linux on VM VMs and then Mount Apache+php+ftp+mysql on a Linux machine, here's my reload process:

1 : Connect virtual machine : Two virtual machines are selected Host-onl, view host VirtualBox host-only Network IP address is 192.168.56.1, then I let Linux, WindowsXP all let 192.168.56.2,192.168.56.3 for the URL,

You can then ping each of the two virtual machines in the following way, only the settings above, and may not be guaranteed to ping the Windows and Linux issues. This involves both sides of the firewall problem.

1. There is a firewall on the WinDOS side. If you find that Windows can ping Linux, and Linux cannot ping windows, it should be a problem with your Windows native Firewall policy. I was also tortured by this problem for a long time, until the shutdown of the WINDOSW this machine's firewall, and finally to achieve ping interoperability. The shutdown method for shutting down the native Windows Firewall is as follows:

Start, Control Panel, System and security, Windows Firewall on or off Windows Firewall, shut down Windows Firewall

2, there is a firewall on the Linux side. Linux can ping windows at this point, but Windows cannot ping Linux.

The way to check if Linux has a firewall is to:

The Iptables-l command looks at the current Linux system's policies.

I don't need a variety of firewall policies here, so it's straightforward to set up a firewall rule as follows:

Iptables-f//emptying current firewall rules

Iptables-x//Remove all firewall rules for system configuration

Iptables-p INPUT ACCEPT

Iptables-p OUTPUT ACCEPT

Iptables-p FORWARD ACCEPT

As long as the above command is configured to boot automatically, the current firewall policy for Linux systems after booting is as follows:

In this way, the firewall settings for Linux are removed.

Now, you can implement IP interoperability between Windows <-> Linux systems. With the SSH service on Linux, Samba services can be logged on from Windows normally.

2 : Install ftp:

The software is brought in RHEL6 CD-ROM, #mkdir/mnt/cdrom

#mount/dev/cdrom/mnt/cdrom

Installation package: #cd/mnt/cdrom/packages

#rpm-IVH vsftpd*

Ann needs to modify the main configuration file:/etc/vsftpd/vsftpd.conf

Problems may occur:

A: When landing, "OOPS", this is because SELinux restricts the user to log on to the FTP server, to modify the SELinux setpoint: #setsebool-P ftp_home_dir on

B: If there is a "Ftp:connect:NO route to host" error, we want to modify the firewall rules to let port 21st through the firewall: #iptables-i input-p TCP--dport 21-j ACCEPT, edit/etc /selinux/config file, change "selinux=enforcing" to "SELinux =disabled" and turn off SELinux.

C: Add FTP User, #useradd-s/sbin/nologin user1

#passwd user1

Modify FTP directory Permissions: #chmod-R o+w/var/www/html

Turn on the transfer auditing feature for disabling SELinux ftp: #getsebool-a|grep FTP

#setsebool-P Allow_ftpd_anon_write off

#setsebool-P Ftpd_disable_trans on

#getsebool-a|grep FTP

3: Installing Apache

A to see if the system is installed: #rpm-qa |grep httpd

b, with the software in the RHEL6 CD-ROM, #mkdir/mnt/cdrom

#mount/dev/cdrom/mnt/cdrom

Installation package: #cd/mnt/cdrom/packages

Use #find apr*, find Appache dependent software, install all: # RPM-IVH apr*

Then install: # RPM-IVH http_tools*

# RPM-IVH http-2.2.15*

# RPM-IVH httpd_manual*

Then use #rpm-qa |grep httpd to confirm that the installation is complete.

Start Apache server: #service httpd restart

View Status: Service httpd status

To view server-occupied port conditions: Netstat-tnlp|grep httpd

If you enter a server address in IE to appear on the Read Hat Testpage page, you have successfully installed

4: install MySQL

A, install with Yum tool, #yum groupinstall MySQL

When you are done, use Setup to start the MySQL service.

B: Unable to connect to MySQL

/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///

There are two ways to connect native MySQL under Linux:

1. Socket mode

2. TCP/IP mode

This is the kind of problem that sometimes uses TCP/IP and sometimes is another.

So you can solve it in two ways:

1, directly enforce the use of TCP/IP mode

2. Fill in the socket

Method:

1. Add a--protocol=tcpip after MySQL

2. Turn off MySQL, CD to/TMP and enter: Ln-s/var/lib/mysql/mysql.sock mysql.sock, start MySQL

//////////////////////////////////////////////////////////////

MySQL Configuration port access rule-Allow extranet access 3306

After MySQL is installed, the default is to allow access to port 3306 on the server via 127.0.0.1 only

1). is the 3306 port not open?

Use the Nestat command to view the 3306 port status:

~# Netstat-an | grep 3306

TCP 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

From the results, it can be seen that port 3306 is only listening on IP 127.0.0.1, so it denies access to other IPs.

Workaround: Modify /etc/mysql/my.cnf file. Open the file and find the following:

# Instead of skip-networking The default is now-listen only on
# localhost which are more compatible and are not less secure.
Bind-address = 127.0.0.1

Comment out the above line or replace the 127.0.0.1 with the appropriate IP.

After restarting, re-use netstat detection:

~# Netstat-an | grep 3306
TCP 0 00.0.0.0:3306 0.0.0.0:* LISTEN

2). Does the problem solve?

Now test with the following command:

~# mysql-h 10.1.1.2-u root-p
Enter Password:
ERROR 1130 (00000): Host ' b0324-desktop.local ' isn't allowed to connect tothis MySQL server

The result is unexpected, or not.

Workaround: You will also need to assign user rights to each remote user , MySQL default Root account not with % but 127.0.0.1 , so you need to modify it.

Log on to the MySQL server and use the grant command to assign permissions

Mysql> Grant all on database_name.*to [email protected] '% ' identified by ' User_password ';

where database_name, user_name and User_password are set according to the actual situation.

After the completion of the use of the MySQL command connection, prompt success, in order to ensure that the correct can be remote landing test.


ERROR 1130:host ' 192.168.1.3 ' isn't allowed to connect to this MySQL server

Workaround:
1. Change the table method. It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost, log in to MySQL, change the "MySQL" Database in the "User" table "host", from "localhost" to "%"

Mysql-u root-pvmwaremysql>use mysql;mysql>update User Set host = '% ' where user = ' root '; mysql>select host, user from user;

Execute the Flush privileges command and then connect again

2. Authorization law. For example, if you want to myuser use MyPassword to connect to a MySQL server from any host.

GRANT all privileges on * * to ' myuser ' @ ' percent ' identified by ' MyPassword ' withgrant OPTION;
If you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.3 and use MyPassword as the password
GRANT all privileges on * * to ' root ' @ ' 192.168.1.3 ' identified by ' MyPassword ' with GRANT OPTION;

GRANT all privileges on * * to ' root ' @ ' 10.10.40.54 ' identified by ' 123456 ' withgrant OPTION;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////

Common check steps.

1. Ping hostname or ping 189.xx.xx.xx confirm that there is no problem with the server IP layer communication. If the ping general continues (2), Ping does not seek expert assistance in networking.
2. TELNET hostname 3306 confirms that there is no problem with the server TCP layer communication. (Your port number may not be 3306), as the general rule continues, if not, please check if MYSQLD is already running and the firewall is blocking the port.
3. Check user permissions, show grants ...

Your user is not using the root account, or your root account has not been granted login rights, you need to use
GRANT all privileges on * * to ' myuser ' @ ' percent ' identified by ' MyPassword ' with GRANT OPTION;
An authorized host is a%,% that represents a host in any location.

//////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////================================= ====================================================================
Symptom  :  Unable to connect  mysql 
Error message  :ERROR 1045  (28000): access denied for user  ' UserA ' @ ' localhost '   (using password:yes)
cause  :  user account not created
Check  : After logging in as Administrator root, show grants  for  ' UserA ' @ ' localhost ';  or  select user from mysql.user;  confirm that the user account exists.
Process  : Create user account.
=====================================================================================================

==========================================================================
Symptom  :  Unable to connect   mysql 
Error message  :error 1130: host xx.xx.xx.xx is not allowed to &NBSP;CONNECT&NBSP;TO&NBSP;THIS&NBSP;MYSQL&NBSP;SERVER&NBSP
Cause the  : mysql server does not have permission to grant this client remote connection.  
Check  : In the MySQL server local query MySQL library, the user table corresponding to the host contains the client machine IP (% is not limited IP allow remote connection).  
processing  : Modify user table under MySQL library:update user set host =  '% '   where  user = ' XXX ';flush privileges;
====================================================================================

=====================================================================================================
Symptom  :  unable to connect  mysql 
Error message  :ERROR 2003  (HY000):  can ' t connect to  MySQL server on  ' hostxxxxx '   (10061)
Reason &NBSP;:&NBSP;MYSQLD database service did not start.
Check  : In windows  Task Manager, or under  unix/linux   ps -aux | grep mysql   Check it out. Confirm that the service is started.
Handling  : Starting mysqld  service
============================================================================= ========================

===================================================================================================== 
Symptom  :  Unable to connect  mysql 
Error message  :ERROR 2003  (HY000):  can ' T connect  to MySQL server on  ' hostxxxxx '   (10061)  
Cause  : mysqld  The client is inconsistent with the service-side port.  
Check  : Service port under my.ini  settings   This situation, especially if the client is inconsistent with the remote server port   is prone to problems
processing  : Starting the mysqld  service  
=====================================================================================================  

===================================================================================================== 
Symptom  :  Unable to connect  mysql windows
Error message  :ERROR 2003  (HY000):  can ' t  connect to mysql server on  ' hostxxxxx '   (10061)  
Cause  :   While opening a large number of TCP ports and only a small fraction of the ephemeral ports, when they are in the time_wait period, MySQL may run the wrong port
Check  : 5,000 temporary port confession calls are turned on by default on windows , And their life is only 120s, meaning that when the port is closed there will be 120 seconds delay
Processing  : Reduce unnecessary TCP ports.
Modify the Registry
================================================================================================== === 

=====================================================================================================
Symptom: Unable to connect to MySQL
Err Message: Error 2002 (HY000): Can ' t connect to local MySQL server server through socket '/var/lib/mysql/mysql.sock ' (111)
Reason: Mysqld's mysql.sock is not in the corresponding position.
Processing: 1. Check the/etc/rc.d/init.d/mysql status to see if it starts
2. Change Permissions Chown-r Mysql:msyql/var/lib/mysql
3. Modify/ETC/MY.CNF (Note: first stop database)
[Mysqld]
Datadir=/usr/local/mysql/data
Socket=/var/lib/mysql/mysql.sock
[Mysql.server]
User=mysql
Basedir=/usr/local/mysql
[Client]
Socker=/var/lib/mysql/mysql.sock
4. Start the database
=====================================================================================================

Summarized as follows:

Symptom: Unable to connect to MySQL
===================================================================================
Err Message: Error 2003 (HY000): Can ' t connect to MySQL server on ' hostxxxxx ' (10061)
Cause: The MYSQLD database service did not start.
Check: Task Manager in Windows, or unix/linux under Ps-aux | grep MySQL to look at. Confirm that the service is started.
Processing: Starting the MYSQLD service
===================================================================================
Err Message: Error 1130:host xx.xx.xx.xx is not allowed to connect to this MySQL server
Cause: The MySQL server does not have permission to grant this client remote connection.
Check: in MySQL server local query the MySQL library in the user table corresponding to the host contains the client machine IP (% is not limited to allow remote connections IP).
Processing: Modify the user table under MySQL library: Update user set host = '% ' where user = ' XXX '; flush privileges;
===================================================================================
Err Message: Error 1045 (28000): Access denied for user ' usera ' @ ' localhost ' (using Password:yes)
Cause: User account not created
Check: After login with Administrator root, show grants for ' UserA ' @ ' localhost '; Or select User from Mysql.user; Verify that the user account is present.
Process: Create user account.
===================================================================================
Err Message: Error 2003 (HY000): Can ' t connect to MySQL server on ' hostxxxxx ' (10061)
Cause: The MYSQLD client is inconsistent with the service-side port.
Check: Service port under My.ini settings This situation, especially if the client is inconsistent with the remote server port, is prone to problems
Processing: Starting the MYSQLD service
===================================================================================
Err Message: Error 2002 (HY000): Can ' t connect to local MySQL server server through socket '/var/lib/mysql/mysql.sock ' (111)
Reason: Mysqld's mysql.sock is not in the corresponding position.
Processing: 1. Check the/etc/rc.d/init.d/mysql status to see if it starts
2. Change Permissions Chown-r Mysql:msyql/var/lib/mysql
3. Modify/ETC/MY.CNF (Note: first stop database)
[Mysqld]
Datadir=/usr/local/mysql/data
Socket=/var/lib/mysql/mysql.sock
[Mysql.server]
User=mysql
Basedir=/usr/local/mysql
[Client]
Socker=/var/lib/mysql/mysql.sock
4. Start the database
===================================================================================



Installing Apache+php+ftp+mysql on VM virtual machines

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.