Learn about linux-build lamp-Linux Enterprise Application-Linux server application. For more information, see the following section. From: andrewxiao
I recently started to learn linux. As the saying goes, my good memory is not as bad as my head. So I decided to record what I learned on weekdays for review. Because I am a beginner, I have used a lot of online materials for reference. However, I wrote a record of my thoughts and multiple experiments here. If there is any problem, I also hope you can point out that I would be grateful!
Today we record the entire process of installing lamp: the platform is centos4.6 + httpd-2.2.9 + mysql-5.0.51b + php-5.2.6
The Development Tools must be installed on the host; otherwise, subsequent compilation cannot be performed.
1. Install Mysql
Go to the mysql decompressed source code file directory:
Cd/usr/src
Tar xvzf mysql-5.0.51b.tar.gz
Cd mysql-5.0.51b
You can enter./configure -- help to view available options:
Compile and install:
./Configure -- prefix =/usr/local/mysql # Set the installation path of mysql
Make & make install # compile and install.
Configure mysql
Groupadd mysql # Add a mysql Group
Useradd-g mysql # Add a mysql user and add it to the mysql Group
Cd/usr/local/mysql/# Switch to the cd/usr/local/mysql/directory
Chown-R root. # change the owner of the current directory to the root user.
Chgrp-R mysql. # change the group owner of the current directory to the mysql group.
Chmod 755. # change the root directory permission
# Copy this file as A/etc/my. cnf file (you can select different files based on the size of the website)
Cd bin/# To the/usr/local/mysql/bin directory
./Mysql_install_db -- user = mysql # initialize the database as mysql (reducing the risk caused by root user Startup)
./Mysqld_safe -- user = mysql & # Start the database with a mysql user (& indicates execution in the background)
./Mysqladmin-u root password 'admin' # Set the root user password of mysql to admin
Cd/usr/local/mysql
Chown-R mysql: mysql var # change the owner and group of var to mysql and mysql; (var is the path for storing mysql database files)
Chmod 755 var # modify the permissions of the var directory;
Cp/usr/src/mysql-5.0.51b/support-files/mysql. server \
>/Etc/init. d/mysqld (same line) # copy the file for automatic start upon startup
Chmod 755/etc/init. d/mysqld # Change mysqld permission
Chkconfig -- add mysqld # add the mysqld service to the System
Chkconfig mysqld on # Start the myslqd service at the default level
Service mysqld restart # restart the mysqld service
Test mysql:
Cd/usr/local/mysql/bin # Switch to the cd/usr/local/mysql/bin directory
./Mysql-u root-p # log on to mysql
Show databases; # view database tables
2. install Apache
First, check whether the apache that comes with linux is installed. If yes, uninstall it.
Command: rpm-qa | grep httpd # Check whether http software is installed
Rpm-e -- nodeps software name # uninstall the software without checking the dependency
Go to the source code directory after Apache Decompression
Cd/usr/src
Tar xvzf httpd-2.2.9.tar.gz
Cd httpd-2.2.9
You can enter./configure -- help to view available options:
Compile and install:
./Configure
-- Sysconfdir =/etc/# specify the path for storing Apache configuration files
-- With-mysql =/usr/local/mysql/# specify the mysql path;
-- Enable-modules # enable all modules.
(The above configuration is the same line! In this case, apache is installed in the default/usr/local/apache2 directory)
Make & make install # compile and install.
Configure Apache
Vi/etc/httpd. conf
Modify ServerName to make this line take effect. Add ip addresses, domain names, and ports.
Example: ServerName 127.0.0.1: 80
Modify DocumentRoot and change the path to your local settings, such as "/var/www/html/" in this example /". And the following lines Change Deny from all in to Allow from all.
Create an index.html file:
Echo "hi, welcome to here">/var/www/html/index.html
Test Apache:
Enter your own ip address and port in the browser for testing.
For example, enter http: // 127.0.0.1: 80 in the browser.
3. install Php
Go to the php decompressed source code file directory (the following configuration is in the same line !)
./Configure
-- Prefix =/usr/local/php # specify the php installation directory
-- With-mysql =/usr/local/mysql # specify the mysql installation directory -- with-apxs2 =/usr/local/apache2/bin/apxs # specify the apache directory.
Make & make install # compile and install.
Cp php. ini-dist/usr/local/php/lib/php. ini
Vi/etc/httpd. conf
Find "# AddType application/x-gzip. gz. tgz"
And add
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps
# The purpose of these two lines is to enable apache to recognize php.
Find "DirectoryIndex index.html"
Add index. php to make index. php a response page.
Test environment:
# Vi/var/www/html/index. php
Input:
Phpinfo ();
?>
# Service httpd restart apache server
For example, enter http: // 127.0.0.1/index. php In the browser to test the function. If it succeeds, related php instructions are displayed, and the source code is displayed if it fails.
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