Page 1/2 of the configuration process of PHP + MYSQL + APACHE in Linux

Source: Internet
Author: User
Tags localhost mysql

The required software is as follows:
Apache: http://www.apache.org
Mysql: http://www.mysql.com
Php: http://www.php.net/downloads.php
Gd: http://www.boutell.com/gd/#buildgd
ZendOptimizer http://www.zend.org/products/zend_optimizer
Gettext http://ftp.gnu.org/pub/gnu/gettext/
Netpbm http://sourceforge.net/projects/netpbm/
The software version used is as follows:
Redhat Enterprise As 4
(Apacheappshttpd-2.0.50.tar.gz
Mysql-standard-5.0.18-linux-i686.tar.gz
Php-5.1.2.tar.gz
Gd-2.0.33.tar.gz
ZendOptimizer-2.6.2-linux-glibc21-i386.tar.gz
Imap
Gettext

1. Install the MYSQL mysql-standard-5.0.18-linux-i686.tar.gz
I downloaded all of them to the/usr/local/software Directory.
Go to the installation package Directory: cd/usr/local/software
1. [root @ localhost software] # chmod 755 mysql-standard-5.0.18-linux-i686.tar.gz
2, [root @ localhost software] # tar xfz mysql-standard-5.0.18-linux-i686.tar.gz
Decompress the package and generate the mysql-standard-5.0.18-linux-i686 directory. we enter this directory:
3. [root @ localhost software] # cd mysql-standard-5.0.18-linux-i686
After entering mysql, we will start to configure mysql. During the configuration process, we will set
In the installation directory, we set it to/usr/local/mysql to make it easier to manage files in one place. If you want more configuration information, use it. /configure -- help:
Here, I want to emphasize that MYSQL's default encoding should be selected during compilation, because GBK encoding is not supported in JSP if it is not selected to be installed by default.
So I compile it like this
Access to mysql requires a special user and corresponding access permissions. Here we set root and mysql to have access permissions.
7. Create a mysql and mysql user to access mysql:
[Root @ localhost mysql-standard-5.0.18-linux-i686] # groupadd mysql # create a mysql Group
8. [root @ localhost mysql-standard-5.0.18-linux-i686] # useradd mysql-g mysql # create a mysql user and add it to the mysql Group
9. initialize the table after the user is created (Note: You must perform this step before proceeding to the following steps)
[Root @ localhost mysql-standard-5.0.18-linux-i686] #./scripts/mysql_install_db -- user = mysql
# Initialize the table and set the access permission for the mysql and root users after accessing the initialization table ,;
10, [root @ localhost mysql-standard-5.0.18-linux-i686] # mv mysql-standard-5.0.18-linux-i686/usr/local/mysql
Then set permissions
Cd/usr/local/mysql

11. [root @ localhost mysql] # chown-R root. # Set root to access/usr/local/mysql
12. [root @ localhost mysql] # chown-R mysql data # Set the mysql user to access/usr/local/mysql/data, which contains the mysql database file
13. [root @ localhost mysql] # chgrp-R mysql. # Set the mysql group to access/usr/local/mysql.
14. After the configuration is complete, it will basically be installed. Okay, let's run our mysql:
[Root @ localhost mysql] #/usr/local/mysql/bin/mysqld_safe -- user = mysql &
If there is no problem, a prompt like this should appear:
[1] 42264
# Starting mysqld daemon with databases from/usr/local/mysql/var

This proves that the installation is successful.
Use the following command to change the root password. The default installation password is blank. To ensure security, you must change it immediately.
15./usr/local/mysql/bin/mysqladmin-uroot password xksoft321
The current password is xksoft321.
16. Set automatic start upon startup
Cp support-files/mysql. server/etc/init. d/



Ii. install apache
Go to the installation package Directory: cd/usr/local/software
1, # chmod 755 httpd-2.0.50.tar.gz
2, # tar xfz httpd-2.0.50.tar.gz
3, # cd httpd-2.0.50
Start configuring APACHE
4. #./configure -- prefix =/usr/local/apache2 -- enable-so -- enable-rewrite -- enable-mod-shared = most
#./Configure -- prefix =/usr/local/apache2 -- enable-so -- enable-module = most -- enable-shared = max -- enable-rewrite
#./Configure -- prefix =/usr/local/apache2 -- enable-so -- enable-rewrite -- enable-access
#./Configure -- prefix =/usr/local/apache2 -- enable-so -- enable-mod-shared = all -- enable-rewrite = shared

5. # make
6. # make install
7. Check the modules compiled into apache:
#/Usr/local/apache2/bin/httpd-l
Compiled-in modules:
Http_core.c
Mod_so.c
The above information indicates that apache supports dso. In this way, you can use dso to add the php and resin modules.

Iii. Install GD
Go to the installation package Directory: cd/usr/local/software
1. tar-zxvf gd-2.0.33.tar.gz
2. cd gd-2.0.33
3../configure -- prefix =/usr/local/gd2
4. make
5. make install

Gettext
1. tar xfz
2 cd
3./configure-with-prefix =/usr/local/gettext
4 make
5 make install

4. install php
Go to the installation package Directory: cd/usr/local/software
1. # tar xfz php-5.1.2.tar.gz
2. decompress the package and enter the directory:
# Cd php-5.1.2
3. configuration. This step is critical and must be properly configured, especially considering what you want to support, such as the GD library, xml, mysql, etc. If you want to know the detailed configuration, run. /configure -- help to get:
#. /Configure -- enable-mbstring = LANG -- with-mysql =/usr/local/mysql -- with-gd =/usr/local/gd2 -- with-apxs2 =/usr/local/apache2/ bin/apxs-with-gettext =/usr/local/gettext
-Enable-mbstring = LANG (solve the problem of php extension: mbstring)
If the above configuration is correct, the words "Thank you for using PHP" should be displayed at last, which proves that the configuration is successful. If the above configuration options are not supported, an error will be prompted.
For example, if you have not installed mysql, -- with-mysql cannot be used, so be sure to check whether the corresponding option system is supported. If an error occurs, install the corresponding program first, or remove the related options and compile the Configuration:
4. # make
After compilation is successful, the words "Build complete." appears, so you can install it:
5. # make install
6. Copy php. ini-dist to/usr/local/lib/and rename it php. ini.
# Cp php. ini-dist/usr/local/lib/php. ini
Basically, PHP is successfully installed here. If an error occurs in the middle, no errors will occur except when no correct option is selected during configuration.
7. To enable Apache to parse php directly, we need to make some configuration.
# Vi/usr/local/apache2/conf/httpd. conf
In the httpd. conf file, add the following two statements after other AddType statements)
AddType application/x-httpd-php. php. phtml
AddType application/x-httpd-php-source. phps
Make sure that the file contains the following sentence, and add it after all loadmodules if not:
LoadModule php5_module modules/libphp5.so
Add index. php to the following DirectoryIndex
DirectoryIndex index. php index.html. var
Okay, use ": wq" in vi to save the httpd. conf file and exit vi.
8. Start apache server:
#/Usr/local/apache2/bin/apachectl restart
Now apache can run php. Write a file and test it. In the/usr/local/apache2/htdocs directory, create a new phpinfo. php file,
There is only one line of code in the file:
<? Phpinfo ();?>
Save the file and enter http: // localhost/phpinfo. php in your browser. You should see the PHP system information.
If an error occurs, for example, if you are prompted to download phpinfo. php, apache cannot parse the php file. Check whether the above operations are correct.

5. ZendOptimizer
Go to the installation package Directory: cd/usr/local/software
1. # tar xfz ZendOptimizer-2.6.2-linux-glibc21-i386.tar.gz
2, # cd ZendOptimizer-2.6.2-linux-glibc21-i386
3. #./install. sh
4. When you ask Confirm the location of your php. ini file, enter/usr/local/lib/
Are you using Apache web server? Select YES.

VI,
1../configure -- prefix =/usr
2. make
3. make check
4. make install



Service configuration with system startup
If you want to run the httpd service when the computer starts, you can add these lines to the/etc/rc. d/rc. local file:
# Start apache
/Usr/local/apache2/bin/apachectl start

If the script cannot be started, grant the executable permission to the script.
For example, apache cannot start chmod a = x apachectl.


Do not enter a PATH similar to/usr/local/apache2/bin for future operations. Add the $ PATH variable to the/etc/profile file.
Add the apache, tomcat, and mysql paths


Appendix:
1. Create a virtual host for resin and apache
For example, two virtual hosts are created: tes1.jsp.com test2.jsp.com.

Vi/usr/java/httpd2/conf/httpd. conf
Copy the following content to httpd. conf.
NameVirtualHost 192.168.0. * IP address of the VM
<VirtualHost 192.168.1. *>
DocumentRoot/home/jsp1/file directory
ServerName tes1.jsp.com Domain Name
</VirtualHost>
VirtualHost 192.168.1. *>
DocumentRoot/home/jsp2/
ServerName test2.jsp.com
</VirtualHost>
Vi/usr/java/resin/conf/resin. conf
Find and modify the following code:

<Host id = "" root-directory = ".">
<! --
-Configures an explicit root web-app matching
-Webapp's ROOT
-->
<Web-app id = '/' document-directory = "/usr/java/httpd2/htdocs"/>
</Host>
<Host id = 'tes1 .jsp.com '>
<Web-app id = '/' document-directory = "/home/jsp1"/>
</Host>
<Host id = 'tes2 .jsp.com '>
<Web-app id = '/' document-directory = "/home/jsp2"/>
</Host>
Save from apache and resin
The tes1.jsp.com and tes2.jsp.com virtual hosts can run
You can test http: // localhost/caucho-status/
We can see that there are
Virtual Host: tes1.jsp.com: 80
Virtual Host: tes2.jsp.com: 80
It proves that the jsp vm is working normally.
Ii. Installation of linux software
Linux software packages found on websites or CDs. Common formats include rpm, deb, tar, gz, tgz, zip, and bz2. I'm afraid we usually use the most rpm and tgz. According to statistics, the most popular versions on the Internet should be redhat and mandrake, both of which are encapsulated by rpm.
Tar is the most common software package format. Almost every linux software provides a tar-format software package, because the software package in this format is supported by any version of linux, therefore, you should at least understand how to use tar and rpm. Deb can be converted to tgz or rpm using the alien tool. Bz2 can be unwrapped with bunzip2.
1. Install the RPM file
RPM is the abbreviation of RedHat Package Manager (RedHat Package management tool). Although the file format name is marked with RedHat, its original design concept is open, including OpenLinux, the distribution versions of Linux such as mandrake and Turbo Linux are adopted, which can be regarded as industry standards.
The RPM file is the easiest to install in Linux. Take the famous image processing software XV as an example:
In Terminal, the basic installation commands are as follows:
Rpm-I xv-3.10a-13.i386.rpm
If your network connection speed is fast enough, you can install the application software directly from the network. You only need to add the appropriate URL path before the file name of the software:
Rpm-I ftp://ftp.trilon.com/pub/xv/xv-3.10a-13.i386.rpm
As a software package management tool, RPM manages information about all RPM program components installed in the system. You can also use RPM to uninstall related applications.
Rpm-e xv
Common RPM parameters include:
-Vl: displays the installation progress;
-U: Upgrade the software package;
-Qpl: lists the file information in the RPM software package;
-Qpi: Describe the RPM software package;
-Qf: Find the RPM software package of the specified file;
-Va: checks all RPM software packages to find the lost files;
For more detailed parameters and usage, see the RPM help documentation.
In X-Window, the graphical installation and management methods of RPM files are more friendly to users. After installing the kpackage on kde, you only need to click the mouse to install the rpm, which is more convenient than windows 98. However, you must first install kde.
Let me introduce more common methods, take XV software as an example, find the xv-3.10a-13.i386.rpm file in the File Manager of Linux, right-click it with the mouse, in the pop-up menu, you can find three commands for the RPM software package: Show Info, Upgrade, and Install.
After selecting Show Info, we will see the package information window. The window is divided into three parts. The top displays the software name, size, creation and installation date, developer website, and other information. The box in the middle is an overview of the software; the following shows all the files in the software package and their path information. It tells you which directories of the files in the software package will be installed in the system,
Note that the benefit of this information is that you can easily find the path to the Startup Program.
Click the "Install" or "Upgrade" button at the bottom to Install or Upgrade the software. A Prompt window indicating the installation progress is displayed.
The RPM software package has many advantages over other types of software packages, but it does not mean that the installation of the RPM software is smooth sailing. Common Errors include the installation of a software that has been installed, the software to be installed, and the support of other software or system library files. (install these software or system library files first) in Windows.

2. Installation of tar
Files such as tar.gz, tar. Z, tgz, and bz2 must be decompressed to tar and then installed with tar. Examples of commands for decompression and unpacking are as follows:
1.xv.tar.gz: tar zxf xv.tar.gz
2.xv.tar. Z: tar zxf xv.tar. Z
3. Solution xv. tgz: tar zxf xv. tgz
4.release xv.bz2: bunzip2 xv.bz2
5. xv.tar: tar xf xv.tar
A bunch of files obtained after unpacking are usually stored in a directory. Depending on the author of the software, some will be compiled programs, and more is the source code that needs to be compiled by yourself. After entering the corresponding directory, run the "ls-F-color" command to display the executable program in bright green with the "*" mark. For compiled programs, directly type the command line with a path to run the program.
We recommend that you read the instruction file after decompression. You should first read important documents such as Readme and Install in the software directory using the vi and other document editors, here you will find detailed software compilation steps and precautions to understand the installation requirements and the need to modify the compilation configuration when necessary.
The source code of some software packages can be uninstalled by using the make install command after compilation and installation. If this function is not provided, the software must be manually deleted. Because the software may install files in multiple directories of the system, it is often difficult to delete the files, you should configure them before compilation, specify the path to which the software will be installed :. /configure -- prefix = directory name. In this way, you can run the "rm-rf Software Directory Name" command to thoroughly uninstall the directory. Compared with other installation methods, it is the most difficult to compile and install by yourself. It is suitable for users who already have some experience in Linux. It is generally not recommended for beginners.
The general compilation steps are as follows:
./Configure
Make
Make install (the command can be executed only when the root identity is obtained)
Uninstall available: make uninstall or manually delete
After compilation, you can easily find executable programs in the current directory or a subdirectory named src. So far, software installation has come to an end.

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.