0 basic XAMPP for Linux virtual machine Building station teach (pen) Cheng (kee)

Source: Internet
Author: User
Tags change settings php error tmp folder iptables phpmyadmin

The reason for writing 0 basis is because they do not start groping, stepping on the pit, strictly speaking only as a record of their own operating procedures of a note, and did not rise to the level of the tutorial.

XAMPP is generally used as a development environment, or for learning; it's easy to use under Windows, and there are a lot of tutorials on the web, while the tutorials under Linux are small or incomplete; this is only a new installation of the built-in virtual machine Linux system, and does not involve front-end code and PHP.

Software used:

1) VMware workstation 12.0.0;

2) CentOS 6.4 mirror;

3) XAMPP for Linux;

4) Xshell 4;

5) EMS SQL Manager.

Operation Steps:

One, virtual machine Linux Installation

1.VMware installation skipped, no difficulty.

2. Open vmware-> Create a new virtual machine, select "Typical", Next, select "Install operating system later", Next, select "Linux" and Version "CentOS 6.4", Next, select the installation path, next- > select the disk size and "split into multiple Files", Next, select "Custom Hardware", in the pop-up window, change the network default NAT to bridge, select the prepared ISO image path, close the pop-up window, click Finish.

3. In the VMware title bar tab, select "Edit", "Virtual Network editor" and pop-up window to select "Change Settings", at this time VMnet0 corresponding to the Vmnet information box, the value of the bridge mode selection box is "automatic", change to your network card, OK.

4. Start the virtual machine, install CentOS, the installation process by default is minimal installation, if the first contact, you can choose Desktop.

Note: All relevant IP or network settings in this article are based on the situation of the virtual machine in the LAN, if there is a public network IP.

Second, the basic configuration

1. Before the network selected is the bridge mode, that is, the virtual machine and the physical machine in the same network segment, in the terminal input:

Ifconfig

Can view IP, default is auto get, can be manually set to fixed value, enter in Terminal:

VI /etc/sysconfig/network-scripts/ifcfg-eth0

Change the value on the right side of the Bootproto equal to static to add:

dns1=192.168. 1.1 # Note: According to the actual situation, such as your physical machine IP is 192. 168.1. 159 192.168. 1.1 ipaddr=192.168. 1.155 # Note: Specify the IP address yourself, with the physical machine IP in the same segment netmask=255.255. 255.0 # Note: Subnet mask gateway=192.168. 1.1 # Note: ditto, Gateway

Save the closed file and reboot to see if it takes effect.

2. If you find that the network is not connected automatically, still open the file in 1, modify the value of Onboot is yes.

3. Configure the firewall to open 80 and 3306 ports, which are used by Web services, which are used by the database; Terminal input:

VI /etc/sysconfig/iptables

In-a input-m state--state new-m tcp-p TCP--dport 22-j accept this rule after adding:

 -J accept# Note: Allow 80 ports to pass through the firewall 3306 -J accept# Note: Allow 3306 ports through the firewall

Save closed File (Note: If added at the end of the configuration file error), terminal input:

/etc/init.d/iptables restart

Restart the firewall for the configuration to take effect.

Third, XAMPP installation and basic configuration

1. Install the Xshell before this; Click New to establish an SSH connection, the host is the virtual machine IP address, after the successful connection, as the basic settings, "File", "Properties", "terminal", "Encoding" and select Utf-8, if the font size is too small can be self-adjustable.

2.ctrl+alt+f Open the File transfer window and upload the next good XAMPP installation package, such as uploading to/tmp folder.

3. Go to the TMP folder:

CD/tmpchmod777 xampp-linux-x64-1.8. 3-5-installer.run# Note: Enter the first few letters and press TAB to complete it automatically. /xampp-linux-x64-1.8. 3-5-installer.run

Follow the prompts to complete the installation, at this point enter:

/opt/lampp/lampp start

To turn on the server.

4. In the Physical machine browser, enter 192.168.1.155/phpmyadmin will prompt 403 error, this is because the default state can only open this page locally, at this time in Xshell input:

VI /opt/lampp/etc/extra/httpd-xampp.conf

Find "/opt/lampp/phpmyadmin" and change its corresponding require local to

Require all granted

Save closed File (Note: Modify the way according to the version, some of the old version directly under the Locationmatch tag require local comment out, but the new version will directly lead to error, so first try to modify), enter:

/OPT/LAMPP/LAMPP restart

Restart the server.

5. If no accident 192.168.1.155/phpmyadmin can already be in the physical machine normal access, for the future ease of use, the XAMPP set to start with the system, enter:

egrep : initdefault:/etc/inittab# Note: Regular match, find the form in the/etc/inittab file: Initdefault: The code snippet

If Desktop is selected when the system is installed, the search results should be id:5:initdefault:; If you want to change the startup mode to start for the command line, you can enter/etc/inittab to Id:5:initdefault: Modify to Id:3:initdefault : Here the assumption has been changed to 3, enter:

cd/etc/rc.d/rc3.d# Note: If not changed to 3, write RC3 as RC5 to ln -s/opt/lampp/lampp s99lampp# Note: This sentence adds xampp into the startup item

If you want to cancel boot, s99lampp change to K01LAMPP.

6. When developing the page, just put the project folder into/opt/lampp/htdocs, such as project folder test, the entry page is index.html, then enter 192.168.1.155/test/index.html in the physical machine can be accessed.

Another: When the log is saved, remember to add write access to the log folder, such as the log folder name as log, placed under/OPT/LAMPP, enter the directory, enter:

chmod -r +W Log

Can.

Iv. MySQL Basic configuration

1. First set the password, enter:

/opt/lampp/bin/mysql-uroot-p

Enter, default no password, press ENTER again to enter the database, input:

show databases;

You can view an existing database, such as the user information that is logged into the database, that exists in the users table under the MySQL database, and enter:

Use MySQL;

Select the database and enter:

Select * from user;

To see the user information under the Users table, you can find that the password for the root user is empty and enter:

Update user set Password=password ('yourpassword') where user='root  ';

You can change the user name root user password to the password you set, note must use Password (").

2. Do not exit the database at this time, enter:

Delete from user where user=';

Delete anonymous user; If you do not have this step, after the next, there will be a frequent error in database access, the password is set to the root user can not log in normally, with the anonymous user may log in (in fact, the default match to the anonymous user login), but no MySQL database (no permissions), Therefore, the unified removal of anonymous users.

If it is not deleted and the database is inaccessible, it prompts "ERROR 1045 (28000): Access denied ..." to try to use the statement

192.168. 1.155 -u root-p

To log in, and then modify the database.

3. Next, enter:

Update user set host='%' where user='root' and host=' localhost ';

Set the root user to remote access, and finally enter:

Flush privileges;

Exits the database.

4. At this point, you will find that 192.168.1.155/phpmyadmin is inaccessible, enter:

VI /opt/lampp/phpmyadmin/config.inc.php

Find $cfg[' Servers ' [$i] [' password '] = '; Enter the password you just set in ', save the closing file, type:

/OPT/LAMPP/LAMPP restart

Restart the server, 192.168.1.155/phpmyadmin access is normal.

5. Here the database is not working properly, because the default encoding format is not UTF8, at this time to add database information will result in Chinese garbled, log into the database, enter:

' %char% ';

You can view the current encoding format and find that the values for Character_set_database and Character_set_server are latin1 and enter:

Set character_set_database=utf8;set character_set_server=utf8;

You can change the encoding format to UTF8 in this login, that is, after exiting the database, if you want to save the default settings, enter:

VI /OPT/LAMPP/ETC/MY.CNF

Under [client] and [MySQL] add:

Default-character-set = UTF8

Under [Mysqld], add:

Character-set-server = UTF8

Save the shutdown file and restart the server, the database encoding is set.

V. Basic MySQL operation

1. In the fourth step, XAMPP's own database management tool is available, and the browser enters 192.168.1.155/phpmyadmin. About the operation of phpMyAdmin, here is an example of EMS SQL Manager.

2. After installing the software, open the "Database" tab, "Register Host" and fill in the basic information, then select the specific Database to the right of the box, and complete.

3. The left column will show your host IP, click the plus sign to expand the host under the database you added, double-click the connection, the first subkey tables is the form under this database.

4. Right-click Tables can create a new form, in the Right tab, the properties can be set table sole name and storage engine; fields can edit form structure, add field, data can add or modify form data, and all operations must remember point compile save changes.

5. Press F12 to run the SQL statement directly.

Vi. XAMPP safety and optimal configuration

1. As a production environment, further setup is required to enter:

VI /opt/lampp/etc/httpd.conf

Find "/opt/lampp/htdocs";, add or modify to:

Options Followsymlinksallowoverride None

Intended to make the directory under Htdocs inaccessible.

2. Change the PHP error level and enter:

VI /opt/lampp/etc/php.ini

Use the "/" full-Text search keyword instead:

error_reporting = e_all & ~e_deprecateddisplay_errors=offdisplay_startup_errors=off

3. Close the FTP service and enter:

/opt/lampp/lampp stopftp

, the FTP service will not start the next time you restart the server.

4. Before the development of the time allows phpMyAdmin remote access, remember to close, the/opt/lampp/etc/extra/httpd-xampp.conf file is modified to the original.

5. Modify MySQL high concurrency optimization configuration (MyISAM for example), enter:

VI /OPT/LAMPP/ETC/MY.CNF

which

Key_buffer = 16M modified to key_buffer_size == 1M modified to Max_allowed_packet =256K modified to Read_buffer_size = the

The settings are modified according to the actual requirements.

(End of this article)

0 Base XAMPP for Linux virtual machine build station teach (note)

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.