PHP + MYSQL + APACHE configuration process in Linux (abstract) page 1/2 _ PHP Tutorial

Source: Internet
Author: User
Tags localhost mysql
In Linux, PHP + MYSQL + APACHE configuration process (abstract) page 1. The required software is as follows: apache: www. apache. orgmysql: www. mysql. comphp: www. php. netdownloads. phpgd: www. boutell. comgd # buildgdZendOptimizer 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:

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

DocumentRoot/home/jsp1/file directory
ServerName tes1.jsp.com domain name

VirtualHost 192.168.1. *>
DocumentRoot/home/jsp2/
ServerName test2.jsp.com

Vi/usr/java/resin/conf/resin. conf
Find and modify the following code:











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.

Export apache: http://www.apache.org mysql: http://www.mysql.com php: http://www.php.net/downloads.php gd: http://www.boutell.com/gd/#buildgd ZendOptimizerhttp ://...

Related Article

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.