VM built-in lamp and LAN access

Source: Internet
Author: User
Tags apc file info imap pear phpinfo snmp tidy password protection

(2012-11-06 14:29:17) reproduced
Tags: it Category: WEB
1.apache:
[email protected] liuhan]# Yum install httpd
...

Start
[[email protected] liuhan]#/etc/init.d/httpd start
Starting httpd:

View Run status
[Email protected] liuhan]#/ETC/INIT.D/HTTPD status
HTTPD (PID 2633) is running ...

http://localhost or http://127.0.0.1, see Apache 2 Test page.

Modify configuration file: Modify listening port 8080
[Email protected] liuhan]# nano/etc/httpd/conf/httpd.conf
...
#Listen 12.34.56.78:80
Listen 8080

Restart Service
/ETC/INIT.D/HTTPD restart

Apache2 This version of the structure:
/etc/httpd/conf/httpd.conf: The most important configuration file;
/etc/httpd/conf.d/*.conf: This is a CentOS feature, if you do not want to modify the original configuration file httpd.conf, the other configuration in this stand-alone configuration, the launch of Apache, this file will be read into the main configuration file;
/usr/lib/httpd/modules:apache support a lot of modules, the module you want to use by default is placed in this directory;
/var/www/html: This is the CentOS default "home" directory;
/var/www/error: The default system error message, host settings error or browser-side requirements of data errors, the browser appears on the error message is mainly the information here;
/var/www/icons: To provide some small Apache icons;
/var/www/cgi-bin: Default some executable CGI programs to place the directory;
/VAR/LOG/HTTPD: Log file directory, the file here is very easy to become large, need to provide enough space;
/usr/sbin/apachectl: This is Apache's main execution file, this executable file is actually shell script, it can actively detect some settings on the system, so that you start Apache easier;
/USR/SBIN/HTTPD: This is the main Apache binary file;
/USR/BIN/HTPASSWD: When you want to log in to certain pages, you need to enter your account number and password. Then Apache itself provides a basic password protection, the generation of this password is achieved through this command.

2.mysql:
[email protected] liuhan]# yum install MySQL Mysql-server
...

Start MySQL
[[email protected] liuhan]#/etc/init.d/mysqld start
Starting mysqld: [OK]

Set a password for the root user
[Email protected] liuhan]# mysqladmin-u-root-p Password [email protected]
Enter Password:
Mysqladmin:can ' t turn off logging; Error: ' Access denied; You need the SUPER privilege for this operation '

[[email protected] liuhan]#/etc/init.d/mysqld stop
Stopping mysqld: [OK]

Start
mysql> Update user set Password=password (' [email protected] ') where user= ' root ';
Query OK, 3 Rows Affected (0.00 sec)
Rows Matched:3 Changed:3 warnings:0

mysql> flush Privileges;
Query OK, 0 rows affected (0.01 sec)

Mysql> quit
Bye
[Email protected] liuhan]# mysql-u root-p
Enter Password:
...
Mysql>

MySQL has several important directories and files:
/ETC/MY.CNF: This is the MySQL configuration file, including the MySQL database optimization;
/usr/lib/mysql: This directory is the location where the MySQL database is placed, so be sure to back up the directory with a full backup.

3,php:
[[email protected] liuhan]# Yum install PHP

Then you need to restart Apache:
[Email protected] liuhan]#/etc/init.d/httpd restart
stopping httpd: [OK]
Starting httpd: [OK]


The path to the default document for the Apache site is/var/www/html, creating a simple file info.php in this directory, and calling http://localhost/info.php in the browser will display a lot of PHP5 installation information.
[Email protected] liuhan]# nano/var/www/html/info.php
[Email protected] liuhan]# cat/var/www/html/info.php
<? Php

Show all information, defaults to Info_all
Phpinfo ();

Show just the module information.
Phpinfo (8) yields identical results.
Phpinfo (Info_modules);

? >

4,PHP5 supports MySQL:

[email protected] liuhan]# Yum Search ph
...
Php.i686:PHP scripting language for creating dynamic Web sites
PHP-BCMATH.I686:A module for PHP applications for using the Bcmath library
Php-cli.i686:command-line Interface for PHP
Php-common.i686:common files for PHP
PHP-DBA.I686:A Database Abstraction Layer module for PHP applications
Php-devel.i686:files needed for building PHP extensions
php-embedded.i686:php library for embedding in applications
PHP-GD.I686:A module for PHP applications for using the GD graphics library
PHP-IMAP.I686:A Module for PHP applications this use IMAP
Php-intl.i686:internationalization Extension for PHP applications
PHP-LDAP.I686:A Module for PHP applications this use LDAP
PHP-MBSTRING.I686:A module for PHP applications which need multi-byte string
: Handling
PHP-MYSQL.I686:A Module for PHP applications this use MySQL databases
PHP-ODBC.I686:A Module for PHP applications This use ODBC databases
PHP-PDO.I686:A Database access Abstraction module for PHP applications
php-pear.noarch:php Extension and Application Repository framework
PHP-PECL-APC.I686:APC caches and optimizes PHP intermediate code
PHP-PGSQL.I686:A PostgreSQL Database Module for PHP
Php-process.i686:modules for PHP script using system process interfaces
PHP-PSPELL.I686:A module for PHP applications for using Pspell interfaces
PHP-RECODE.I686:A module for PHP applications for using the Recode library
PHP-SNMP.I686:A module for PHP applications that query snmp-managed devices
PHP-SOAP.I686:A Module for PHP applications This use the SOAP protocol
Php-tidy.i686:standard PHP module provides tidy library support
PHP-XML.I686:A module for PHP applications which use XML
PHP-XMLRPC.I686:A module for PHP applications which use the XML-RPC protocol
Php-zts.i686:thread-safe PHP interpreter for use with the Apache HTTP Server
...

[email protected] liuhan]# Yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
...


[email protected] liuhan]# Yum install Php-mysql
Loaded Plugins:fastestmirror, Refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base:mirror.bit.edu.cn
* extras:mirror.bit.edu.cn
* updates:mirror.bit.edu.cn
Setting up Install Process
Package php-mysql-5.3.3-14.el6_3.i686 already installed and latest version
Nothing to do

Restart Pache

Reload the http://localhost/info.php page in your browser and you'll see more MySQL modules just installed.

5. Set up Apache and MySQL boot
[[email protected] liuhan]# chkconfig--levels 3 httpd on
[Email protected] liuhan]# chkconfig--list httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off
[[email protected] liuhan]# chkconfig--levels 3 mysqld on
[Email protected] liuhan]# chkconfig list mysqld
Chkconfig version 1.3.49.3-copyright (C) 1997-2000 Red Hat, Inc.
This is freely redistributed under the terms of the GNU public License.

Usage:chkconfig [--list] [--type <type>] [name]
Chkconfig--add <name>
Chkconfig--del <name>
Chkconfig--override <name>
Chkconfig [--level <levels>] [--type <type>] <name> <on|off|reset|resetpriorities>

6: Visit lamp to set the listening port in httpd.conf back to 80#listen 12.34.56.78:80
Listen 80 [[email protected] liuhan]#/sbin/iptables-i input-p TCP--dport 80-j ACCEPT
[Email protected] liuhan]#/etc/rc.d/init.d/iptables saved
usage:iptables {Start|stop|restart|condrestart|status|panic|save}
[Email protected] liuhan]#/etc/rc.d/init.d/iptables Save
iptables:saving firewall rules to/etc/sysconfig/iptables:[OK]
[Email protected] liuhan]#/etc/init.d/iptables restart
iptables:flushing firewall rules: [OK]
Iptables:setting chains to Policy Accept:filter [OK]
iptables:unloading modules: [OK]
iptables:applying firewall rules: [OK]
[[email protected] Liuhan] #在我的win7下输入http://192.168.56.129/info.php can access the lamp in the virtual machine.

Other PC access lamp in LAN: Change NAT to bridge mode, auto get or manual configuration. Use bridged networking (bridging mode)
In this mode, the VMware virtual operating system is like a separate host in the LAN, which can access any machine in the network. In bridging mode, you need to manually configure the virtual system with an IP address, subnet mask, and a host machine in the same network segment so that the virtual system can communicate with the host machine. Also, configure the gateway and DNS addresses to enable access to the Internet through a LAN gateway or router.

Use Network address Translation (NAT mode)
Using NAT mode, the virtual system uses the NAT (network address translation) function to access the public network through the network where the host machine resides. In other words, the use of NAT mode enables access to the Internet in virtual systems. The TCP/IP configuration information for a virtual system in NAT mode is provided by the DHCP server of the VMNET8 (NAT) virtual network and cannot be modified manually, so the virtual system cannot communicate with other real hosts on the local area network. The biggest advantage of using NAT mode is that the virtual system access to the Internet is very simple, only the host machine can access the Internet, you do not need to configure the IP address, subnet mask, gateway, but the DNS address should be filled according to the actual situation. Add a DNS address in addition to the network card properties, you can also add it by tapping the Edit button in the Nat tab in the Virtual network editor in the virtual machine.

If you just let the virtual function on the Internet, the two modes can be, with the bridge if you have a legitimate address in the LAN, such as your ADSL cat is the leading way by the function, if it is in the unit, it will be network management to your legitimate IP (now the company is the Mac and IP binding).
Now is the host and virtual machine interoperability, if your ADSL led by the function, that shut down the virtual machine DHCP, select Bridge, check whether 2 machine is assigned the same network segment IP, shut down the firewall.

VM built-in lamp and LAN access

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.