1. Theoretical part
LAMP is linux apache MySQL php shorthand, in fact, is the Apache, MySQL and PHP installed on the Linux system, to form an environment to run the PHP scripting language.
This article is to test the Apache and PHP combination and creation, building methods using a very standard approach (open SELinux), beginners can directly use.
2. Experimental part
2.1. Experimental environment
Lampser:
Hostname=lamp
ipaddress=10.168.0.170
Client
Hostnmae=client
ipaddress=10.168.0.8
2.2, the installation of Yum source
In Lampser
yum-y install httpd php mysql mysql-server php-mysqlyum-y install Policycoreutils-python
2.3. Configuration section
In Lampser
2.3.1, Step1
Note: If you do not want to know how PHP is loaded this step please skip directly
Check whether to introduce a PHP module (enabled by default), master configuration file:
grep ^include/etc/httpd/conf/httpd.conf
Contains the following content:
Include conf.d/*.conf
To view the PHP support module configuration file:
Less/etc/httpd/conf.d/php.conf
Contains the following content:
<ifmodule prefork.c> LoadModule php5_module modules/libphp5.so</ifmodule><ifmodule worker.c> LoadModule php5_module modules/libphp5-zts.so</ifmodule>addhandler php5-script. Phpaddtype text/html. Phpdirectoryindex index.php
2.3.2, Step2
To start the HTTPD&MYSQLD service:
/ETC/INIT.D/HTTPD startchkconfig httpd on/etc/init.d/mysqld startchkconfig mysqld on
Note: Please run the security configuration on MySQL, no more details here!
Mysql_secure_installation
2.3.3, Step3
Configuring the HTTPD Service
1) Enable and change the ServerName (remove the # before ServerName):
ServerName www.cmdschool.org:80
2) Create a new virtual directory:
mkdir/var/www/wwww.cmdschool.org
3) Add test page:
Echo ' <?php phpinfo ();?> ' >/var/www/www.cmdschool.org/index.php
4) Ensure that SELinux is in the enforcing state:
Getenforce
5) Restore the default SELinux type:
restorecon-rfvv/var/www/www.cmdschool.org/
Shown below:
Restorecon reset/var/www/www.cmdschool.org/index.php Context Unconfined_u:object_r:httpd_sys_content_t:s0-> System_u:object_r:httpd_sys_content_t:s0
6) Check the current SELinux type:
ll-dz/var/www/www.cmdschool.org/
7) Set the virtual directory:
Vim Editor/etc/httpd/conf.d/www.cmdschool.org.conf
<virtualhost *:80> documentroot/var/www/www.cmdschool.org ServerName WWW.CMDSCHOOL.ORG</VIRTUALHOST>&L t;directory/var/www/www.cmdschool.org> Options all allowoverride all</directory>
8) Restart Apache service:
/ETC/INIT.D/HTTPD restart
2.3.4, Step4
To set up a firewall:
Vim Editor/etc/sysconfig/iptables
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
To restart the firewall:
/etc/init.d/iptables restart
2.4.5, STEP5
In Lampser
Test server
1) Vim editor/etc/hosts
Ensure that a unique value that contains www.cmdschool.org points to 10.168.0.170:
10.168.0.170 www.cmdschool.org
2) Curl Test
Curl www.cmdschool.org
See information:
Official reference information
http://www.php.net/manual/zh/
http://php.net/manual/zh/install.unix.apache2.php
Http://linux.vbird.org/linux_basic/0440processcontrol.php#semanage
This article is from the "Old Tan Linux Blog" blog, please be sure to keep this source http://cmdschool.blog.51cto.com/2420395/1708325
Lamp Environment (linux+apache+mysql+php) configuration