1, uninstall the system built-inLAMPEnvironment 1) UninstallhttpdServices (Built-in Apache)
① using the rpm command to query the installed httpd service
② Uninstalling httpd service
If the above prompt, on behalf of the system does not allow us to uninstall the software, using forced uninstall -- nodeps
Uninstall other software in turn
2)UnloadingMySQLService
3) UninstallPhpService
2,LAMPEnvironmentInstallation Considerations
① must uninstall the built-in AMP from the Linux System
② Note the installation order of the software
First step: Install Apache Environment First
Step two: Install the MySQL environment
Step three: Install the PHP environment
3,ApacheInstallation of software
① First step: Copy software to Linux Server
② Second step: Copy or cut amp software into your home/root directory
③ step three: Go back to your home and unzip the package
Knowledge points to use: Implement extract to tar.gz package, instruction TAR-ZXVF tar package name
However, in practical applications, there are typically few parameter v, and no progress is shown.
Unzip it as shown in the following:
④ Fourth Step: Compiling the tar source package (gcc compiler ), generating the executable file
①./configure Pre-compilation configuration (configuring software Installation paths and parameters)
② configuration Software Installation path -- prefix
③--enable-so:apache Software Installation depends on the dynamic library
Installation Method 1:./configure(i am a space)--prefix=/usr/local/apache (I am a space)--enable-so
Although the above method can realize the configuration of the software, but a line of writing a number of code is not easy to use.
Installation Method 2:./configure(i am a space) \
--prefix=/usr/local/apache (I am a space) \
--enable-so Enter
Example code:
⑤ to compile Apache software using make instructions
The compilation process does not install the software, it just generates an executable file.
⑥ installing Apache using the make Install command
⑦ after the software installation is complete, it must be started or it will not run
After the Apache software installation is complete, its startup file is placed in the bin directory , we can enter and then call the start method to start.
After the boot is complete, open the browser input http://localhost, display the following interface to indicate the successful installation:
4,MySQLSoftwareThe installation
The MySQL we use is a green package in Linux and can be used directly
① unzip the MySQL compression pack as shown in:
② for MySQL folder renamed to MySQL, so good management
/usr/local/apache
/usr/local/mysql
③ migrating the MySQL folder to the/usr/local directory
Viewing the current directory structure using the LS –l directive
It was observed that the 3rd column and the 4 column in the group that should have shown the file owner and the file belonged to 8972, mainly because: the software we use is a packaged package on someone else's computer, However, our server does not have the corresponding owner and owning group, so 8972 is displayed by default.
installation of ④mysql software
1)groupadd mysql : Create a mysql group
2)useradd-g mysql mysql: Create a mysql user and specify the user to the MySQL group that belongs to
3) Configuring and initializing MySQL
First switch to the/usr/local/mysql directory , and then follow these steps:
scripts/mysql_install_db--user=mysql: initializing mysql database with MySQL user
By default, there is no data in the/usr/local/mysql/data/mysql directory , so the above instruction is the initialization of the current directory, the sample code:
① First please go back to the /usr/local/mysql directory
② initializing the database with instructions under scripts
After the initialization succeeds, the data in the/usr/local/mysql/data/mysql folder is as follows:
Next use,chown and chgrp change The file owner and file permissions in the MySQL directory:
Chown-r Root. ( I'm the dot), here's the. The dot number represents all the files in the current directory
Chown-r MySQL data, change The file owner of the Data folder to MySQL
Chgrp-r MySQL. ( I'm the dot), change all the files in the current directory to belong to the group MySQL
Bin/mysqld_safe--user=mysql &, this step is to start MySQL, do not forget the back of the &(background run)
to start the mysql software using bin/mysql :
5, forMysqlDatabase setup Password
Log in to MySQL again, as shown in:
6,PHPInstallation of software
① Unzip the PHP package as shown in :
② PHP is initialized using the following steps
③ build executables using make for compilation
④ Software Installation using make install
⑤ Create a index.php file under the /usr/local/apache/htdocs directory , and then use the browser to browse as shown:
⑥ let Aapche support PHP file parsing
1) open/usr/local/apache/conf/httpd.conf file
2) Find The following statement
3) add PHP file support for Apache
4) Restart Apache with bin/apachectl restart two times (may not be used at one time)
Run the php file again through the browser, as shown in the following:
7,ForPHPSetPHP. inifile
Define a php file and write the following code:
The results of the operation are as follows:
It is observed that the above program does not contain the php.ini file , so you need to manually configure this file
① into the php5.3 folder , locate the php.ini file
② copy php.ini-development to /usr/local/php/lib folder
③ into /usr/local/apache directory , use bin/apachectl restart to restart Apache
Open the browser again to display the effect as shown:
8, usingSoft links forApachewith theMysqlCreate a shortcut
① Creating a soft link file for Apache
We can use Apache Start|stop|restart to manage Apache software from anywhere in the future.
② Creating a soft link file for MySQL
9,ConfigurationApachewith theMySQLself-Starting service
Add the following two lines of code in the RC. Local Self -boot file vi/etc/rc.d/rc.local of the system:
/usr/local/apache/bin/apachectl start
/usr/local/mysql/bin/mysqld_safe--user=mysql &
Example code:
Comprehensive case: link MySQL with PHP
① creating databases and data tables
② Creating a add.php file in /usr/local/apache/htdocs
③ Open your browser to browse the add.php file and view the database as shown in:
Linux Lamp Environment Build (Apache installation, MySQL installation, PHP installation)