Let me introduce it today. Linux Lower Lamp ( Apache + PHP + MySql ). Apache + MySQL + PHP Install RedHat Under OPT Directory Httpd , MySQL And PHP Directory to allow access through a browser Phpinfo And PhpMyAdmin The final purpose of the page.
Glossary:
LampYesLinux + Apache + MySQL + PHPIt refersA group of Open Source Software commonly used to build dynamic websites or servers:
* Linux, Operating system;
* Apache, Web server;
* MySQL, Database management system (or database server );
* PHPAnd sometimesPerlOrPython, Script language.
The following areLampInWikipediaExplanation in:Http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29
Environment preparation:
* RedHatOperating System(Installation requiredGccAndG ++)-> Rhel-server-5.3-x86_64
* MySQLSource code package->Mysql-5.1.57.tar.gz
* ApacheSource code package->Httpd-2.2.21.tar.gz
* PHPSource code package-> Php-5.2.17.tar.gz
* PhpMyAdminSource code packageÀ phpMyAdmin-3.4.7.1-english.tar.gz
The above is the Environment version for my experiments. You can download the desired version from the official website as needed. However, different versions may encounter different problems and you may need to search for solutions by yourself.
Installation:
This installation uses source code compilation and installation. Copy all source code packages /Usr/local/src . If you have installed Linux , MySQL , Apache And PHP , You must uninstall it first. Use Rpm Delete package installation Rpm Package statement: [Rpm-e Package name ] Statement used to query the package name: [Rpm-Qa | grep Package name ] . A dependency package must also be deleted once so that these packages can be deleted successfully. Rpm Package.
1. installation and configurationMySQL
Step 1: Compile and install
# Cd/usr/local/src
# Tar-zxvf mysql-5.1.57.tar.gz
# Cd mysql-5.1.57
# Groupadd-r MySQL //CreateMySQLUser Group
# Useradd-m-r-g mysql-D/var/lib/MySQL-S/bin/bash
>-C "MySQL Server" MySQL //Add User
#./Configure -- prefix =/opt/MySQL //SpecifyMySQLInstallation Directory
> -- Sysconfdir =/etc //SpecifyMySQLConfiguration file storage directory
> -- Localstatedir =/var/lib/MySQL //SpecifyMySQLDatabase storage directory
> -- Enable-local-infile //ActivateLoad data local infileStatementMySQLThis statement is supported.//Wait,No news is good news
# Make //Compile(It takes a long time)UntilMaking Install in win
# Make install //InstallMaking Install in win
# Make clean
# Make distclean
Step 2:Initialize Database
# Cd/opt/MySQL
#/Bin/mysql_install_db //Initialize System Database
# Ls/var/lib/MySQL //View the contents of directories in the database
# Chown-r MYSQL: MySQL/var/lib/MySQL //Modify database owner
Step 3: CopyLinux MySQLConfiguration file/EtcDirectory and renamedMy. CNF
# Cp/opt/MySQL/share/MySQL/my-large.cnf/etc/My. CNF
Step 4: Copy and generateLinux MySQLServer automatic and stop scripts
# Cp/opt/MySQL/share/MySQL. Server/etc/rc. d/init. d/MySQL
Step 5: SetLinux MySQLAdd the service to server management and set the auto-start status:
# Chkconfig -- list | grep MySQL //Check whether there areMySQLService
# Chkconfig -- add MySQL //AddMySQLService to Server Management
# Chkconfig -- list | grep MySQL //Query at this timeMySQLServer startup status
# Chkconfig -- level 35 MySQL on //Set in3,5The running level is also self-started.
Step 6: Start and TestLinux MySQLServer
# Service MySQL startOr/Etc/rc. d/init. d/MySQL start //StartMySQLServer
#/Opt/MySQL/bin/mysqladmin version //Test whether the server is started
#/Opt/MySQL/bin/mysqladmin Ping
Step 7: SetMySQLAdd Environment Variables
# Export Path =/opt/MySQL/bin: $ path
Step 8: ModifyRootPassword
# Mysqladmin-u Root Password "aha"
FinallyPHPWhen the source code is used, someMySQLLibrary files and header files, if the server also needs to providePHPDynamic Web Service will cause the corresponding file to not be found. The solution is to create a symbolic connection for the directory. The operation command is as follows:
# Ln-S/opt/MySQL/lib/MySQL/usr/lib/MySQL
# Ln-S/opt/MySQL/include/MySQL/usr/include/MySQL
So far,MySQLInstallation Complete
2. InstallationApache
Step 1: Install
# Cd/usr/local/src
# Tar-zxvf httpd-2.2.21.tar.gz
# Cd httpd-2.2.21
#./Configure -- prefix =/opt/httpd //SpecifyApacheInstallation Directory
> -- Enable-So //Declare the use of dynamic function libraries
> -- With-MPM = prefork
> -- Enable-modules = "setenvif rewrite deflate vhost_alias"
# Make
# Make install
#/Opt/httpd/bin/apachectl start
Step 2: SetApacheSelf-starting
# Echo "/opt/httpd/bin/apachectl start">/etc/rc. d/rc. Local
# Echo "/opt/httpd/bin/apachectl start"/opt/httpd/bin/apachectl start
Step 3: confirm the startup status
# Netstat-utl
TCP 0 0 *:HTTP*:*Listen
If the preceding information is displayed, the startup is successful.
3. install and configurePHP
Step 1: Install
# Tar-zxvf php-5.2.17.tar.gz
# Cd php-5.2.17
#./Configure -- prefix =/opt/PHP -- With-mysql =/opt/MySQL \
> -- With-apxs2 =/opt/httpd/bin/apxs //Easy to understand, not explained
# Make
# Make install
# Make clean
# Make distclean
Step 2: ApacheLoadPHPModule
# Cp PHP. ini-Dist/usr/local/lib/PHP. ini
# Vim httpd. conf
Check whether the following sentence exists. If not, add
Loadmodule php5_module modules/libphp5.so
Find"# Addtype application/X-gzip. GZ. tgz"Add
Addtype application/X-httpd-PHP. php. phtml
Addtype application/X-httpd-PHP-source. PHPs
Step 3: CreatePHPTest File
# Vi/opt/httpd/htdocs/test. php
<? PHP
Phpinfo ();
?>
: WQ
4. Configure and deployPhpMyAdmin
# Tar zxvf phpMyAdmin-3.4.7.1-english.tar.gz
# Mv phpMyAdmin-3.4.7.1-English/opt/httpd/htdocs/phpMyAdmin
# Cd/opt/httpd/htdocs/phpMyAdmin
# Cp./libraries/config. Default. php./config. Inc. php
# Vi config. Inc. php
$ Cfg ['pmaabsoluteuri '] = 'HTTP: // localhost/phpmyadmin ';
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'http ';
Test
RestartApacheServer
#/Opt/httpd/bin/apachectl restart
Enter http: // 127.0.0.1/test. php In the browser. The following page is displayed:
Input in the browser:Http: // 127.0.0.1/PhpMyAdmin, the following page appears
OK, Success
Conclusion
So far,LampThe installation and simple configuration process has been introduced. If you are interested, you can study it in depth.LampDetailed configuration process. Of course, due to differences in the source code version and hardware, various strange problems may occur during the process. You can find a solution based on the system prompts. Ability to solve problems and"Anti-destruction"CapabilityLinuxThe essential basic qualities of people.
Hope you can communicate with us more and wish you success!
PS: If you think that using lamp to develop web projects is outdated, you will have more options, writing a web application is not just lamp any more!