In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "how to build a PHP environment under CentOS5.5", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to build a PHP environment under CentOS5.5" article.
1. Preparatory work
First, please confirm whether apache, mysql and php have been installed in the linux system you installed, and uninstall them first if you install them.
Check to see if it is installed (apache as an example)
[root@gamejzy linux] # rpm-qa | grep httpd
Note: rpm-qa is to view all the software that has been installed on this machine. Grep httpd is software that filters out httpd (apache)-related software. Note: grep php is to view php;grep mysql is to view mysql
If a blank occurs after executing the command, the apache software is not installed on the machine, and if a situation such as the following indicates that it has already been installed.
If it is as shown in the figure above, then you need to uninstall all three software.
The uninstall command is as follows:
[root@gamejzy linux] # rpm-e httpd-2.2.3-43.el5.centos-nodeps
Note:-- nodeps is a forced uninstall
Please make sure that your linux system has gcc and Gmail + compilers installed
To check whether the installation is easy, type "gc" or "g +" on the command line, press tab, and see if there is a command display below.
If not, it doesn't matter. The method of installing gcc and Gmail + is very simple.
Install gcc:
Yum-y install gcc
Install the galleys:
Yum install gcc-c++
Copy all the software packages (mostly tar packages) to / tmp/lamp and decompress them
Extract the tar.gz command (php software as an example): tar zxvf php-5.2.6.tar.gz
When this command is executed, a php-5.2.6 folder is created under the current directory, and all extracted files are placed in the php-5.2.6 folder
Please extract all packages in the same way and delete all * .tar.gz files
[root@gamejzy lamp] # rm-rf * .gz
The above command deletes all .gz files
IV. Introduction of compilation and installation software package
The procedure for installing each source code package on the linux system is as follows:
△ configuration (configure)
△ compilation (make)
△ installation (make install)
2. Build the lamp environment (please install it in the order given below)
All the software here is installed under / usr/local
First, install libxml
Installation sequence: 1, enter the libxml directory; 2, configuration parameters (including installation path; dependent software; installation functions, etc.); 3, compilation; 4, installation. Note: all software packages are installed similarly
[root@gamejzy lamp] # cd libxml2-2.6.30 / [root@gamejzy libxml2-2.6.30] #. / configure-- prefix=/usr/local/libxml2
. / configure configuration parameter command for the package.-- prefix indicates the specified installation directory. If most directories are not available, they will be created automatically, and some will not. We need to create them manually.
[root@gamejzy libxml2-2.6.30] # make & & make install
The above command will be compiled and installed together, because the software is small, the installation speed is relatively fast, if the large software, it may take a long time.
Second, install libmcrypt
[root@gamejzy lamp] # cd libmcrypt-2.5.8/ [root@gamejzy libmcrypt-2.5.8] #. / configure-- prefix=/usr/local/libmcrypt [root@gamejzy libmcrypt-2.5.8] # make & & make install
Third, install zlib
[root@gamejzy lamp] # cd zlib-1.2.3/ [root@gamejzy zlib-1.2.3] #. / configure [root@gamejzy zlib-1.2.3] # make & & make install
Do not follow the-- prefix parameter after. / configure, let it be installed in the default directory, because zlib will be used when installing libpng.
Fourth, install libpng
[root@gamejzy lamp] # cd libpng-1.2.31/ [root@gamejzy libpng-1.2.31] #. / configure-- prefix=/usr/local/libpng [root@gamejzy libpng-1.2.31] # make & & make install
5. Install jpeg6
The directory will not be created automatically when this software is configured, it needs to be created manually.
[root@gamejzy libpng-1.2.31] # mkdir / usr/local/jpeg6 [root@gamejzy libpng-1.2.31] # mkdir / usr/local/jpeg6/bin [root@gamejzy libpng-1.2.31] # mkdir / usr/local/jpeg6/lib [root@gamejzy libpng-1.2.31] # mkdir / usr/local/jpeg6/include [root@gamejzy libpng-1.2.31] # mkdir-p / usr/local/jpeg6/man/man1
Generation of directories is complete!
[root@gamejzy lamp] # cd jpeg-6b/ [root@gamejzy jpeg-6b] #. / configure-prefix=/usr/local/jpeg6/-enable-shared-enable-static [root@gamejzy jpeg-6b] # make & & make install
Parameter description in. / configure:
-- the libtool of gnu used by enable-shared to establish a shared library
-- libtool of gnu used by enable-static to build static libraries
6. Install freetype
[root@gamejzy lamp] # cd freetype-2.3.5/ [root@gamejzy freetype-2.3.5] #. / configure-- prefix=/usr/local/freetype [root@gamejzy freetype-2.3.5] # make & & make install
7. Install autoconf
[root@gamejzy lamp] # cd autoconf-2.61/ [root@gamejzy autoconf-2.61] #. / configure [root@gamejzy autoconf-2.61] # make & & make install
The software is installed directly in the default directory.
8. Install gd
[root@gamejzy lamp] # cd gd-2.0.35/ [root@gamejzy gd-2.0.35] # / configure-- prefix=/usr/local/gd2-- with-jpeg=/usr/local/jpeg6/-- with-png=/usr/local/libpng/-- with-freetype=/usr/local/freetype/ [root@gamejzy gd-2.0.35] # make & & make install
Parameter description in. / configure:
-- with-jpeg=/usr/local/jpeg6/ specifies where to find jpeg library files
-- with-png=/usr/local/libpng/ specifies where to find png library files
-- with-freetype=/usr/local/freetype/ specifies where to find the location of freetype 2.x font library
Note that the following errors may occur when installing this package, as shown in the following figure:
If such an error occurs, the solution:
[root@gamejzy gd-2.0.35] # vi gd_png.c
Find the key word "png.h" command: / png.h enter
To be replaced by: / usr/local/libpng/include/png.h
The effect is shown in the following figure:
Save the exit and continue with the "make & & make install" execution to successfully install it.
9. Install apache (key)
[root@gamejzy lamp] # cd httpd-2.2.9/ [root@gamejzy httpd-2.2.9] #. / configure-- prefix=/usr/local/apache2-- sysconfdir=/etc/httpd-- with-included-apr-- enable-so-- enable-deflate=shared-- enable-expires=shared-- enable-rewrite=shared-- enable-static-support [root@gamejzy httpd-2.2.9] # make & & make install
Parameter description in. / configure:
-- sysconfdir=/etc/httpd specifies the location where the configuration files (httpd.conf, etc.) of the apache server are stored
-- with-included-apr uses copies of the bundled apr/apr-util
-- enable-so compiled with dynamic shared objects (dso)
-- enable-deflate=shared support for narrowing transmission coding
-- enable-expires=shared expiration head control
-- enable-rewrite=shared rule-based url manipulation
Enable-static-support builds support for a statically linked version
Test the apache server
1. Check whether the apache2 directory appears under / usr/local/
2. Check whether the httpd directory appears under the / etc/ directory, that is, whether there are httpd.conf files, extra directory and so on.
3. Start the apache server
[root@gamejzy httpd] # / usr/local/apache2/bin/apachectl start
Stop (off), restart (restart)
4. Check whether the apache server is started, that is, whether port 80 is started.
[root@gamejzy httpd] # netstat-tnl | grep 80
After executing the command, it appears as follows, indicating that it has been started
Tcp 0 0: 80: * listen
5. Access in the browser
If you are on this machine, please enter: or
If it is a remote connection, such as a ssh connection, enter the ip address of linux in the browser address bar. For example:
If big characters appear in the web page. "
It works!
"indicates that apache was installed successfully.
The test is complete!
Add apache to start automatically every time you boot
[root@gamejzy /] # echo "/ usr/local/apache2/bin/apachectl start" > > / etc/rc.d/rc.local
Install mysql (important)
Set up a group and user name dedicated to managing mysql before installing mysql
Set up a group called mysql
[root@gamejzy /] # groupadd mysql
Set up a user named "mysql" to belong to the "mysql" group
[root@gamejzy /] # useradd-g mysql mysql [root@gamejzy lamp] # cd mysql-5.0.41/ [root@gamejzy mysql-5.0.41] #. / configure-- prefix=/usr/local/mysql-- with-extra-charsets=all [root@gamejzy mysql-5.0.41] # make & & make install
. / configure parameter description:
-- with-extra-charsets=all installs all character sets of mysql
Note that if the following error occurs during. / configure
Reason: missing ncurses installation package.
Solution: download and install the appropriate software package
Yum list | grep ncurses yum-y install ncurses-devel
After the ncurses installation is complete, proceed with the. / configure configuration!
After the mysql installation is complete, set up some content, which is very tedious, but very critical. I hope you will learn patiently.
1. Set the configuration file my.cnf and put it in the / etc/ directory.
[root@gamejzy mysql-5.0.41] # cp support-files/my-medium.cnf / etc/my.cnf
2. Initialize the database file. After installing mysql, the data file and data storage location of mysql will not appear.
First change to the installation directory of mysql
[root@gamejzy mysql-5.0.41] # cd / usr/local/mysql/
Initialize the database file with mysql_install_db under the bin directory, and use the mysql user built above
[root@gamejzy mysql] # bin/mysql_install_db-- user=mysql
After running, you will find that there will be an additional var directory in the mysql installation directory, where the database files will be placed, including the databases we have built.
3. Set the permissions of mysql installation directory
Change the owner of all files and directories under the directory to root
[root@gamejzy mysql] # chown-r root.
Change the owner of var directory to mysql user
[root@gamejzy mysql] # chown-r mysql. / var/
Change the user group of all directories and files to the mysql group
[root@gamejzy mysql] # chgrp-r mysql.
4. Start mysql
[root@gamejzy mysql] # / usr/local/mysql/bin/mysqld_safe-- user=mysql &
& indicates that it starts in the background
At this point, use netstat-tnl. If you see port 3306, the boot is successful.
Tcp 0 0 0.0.0.0 3306 0.0.0.015 * listen
5. Set permissions. If we directly use the mysql command in the bin directory now, we can log in.
[root@gamejzy mysql] # bin/mysql
It's too dangerous! Therefore, permissions need to be set.
Log in to mysql first and use the sql command to delete usernames whose host is not "localhost" (all users in mysql are user tables in the mysql library), leaving only accounts that are allowed to log in locally.
Mysql > delete from mysql.user where host! = 'localhost'
Refresh authorization table
Mysql > flush privileges
Set the password of a root user who allows native access to mysql
Mysql > set password for 'root'@'localhost'=password (' 123456')
Note: the password you set must be remembered, otherwise you will not be able to access the mysql database.
By this time, our root users have already set the password (password is "123456"). We can test it and type "exit" to exit mysql.
At this point, the command to log in to the mysql database cannot be as simple as bin/mysql, but should be as follows:
[root@gamejzy mysql] # bin/mysql-h 127.0.0.1-u root-p123456
-h specify hostname
-u user name
-p password
6. Shut down the mysql database server
[root@gamejzy mysql] # bin/mysqladmin-u root-p shutdown
The root user here is the user in mysql. After execution, you will be prompted to enter your password. Enter password:
Enter the password and enter to close the database.
To start the command, see this section 4
7. Add to boot and start by default
[root@gamejzy mysql] # echo "/ usr/local/mysql/bin/mysqld_safe-- user=mysql &" > / etc/rc.d/rc.local
Install php (important)
Here we install the high version of php php-5.3.19, there are many installation parameters, please pay attention.
[root@gamejzy lamp] # cd php-5.3.19/ [root@gamejzy php-5.3.19] #. / configure\ >-prefix=/usr/local/php\ >-- with-config-file-path=/usr/local/php/etc\ >-- with-apxs2=/usr/local/apache2/bin/apxs\ >-- with-mysql=/usr/local/mysql/\ >-- with-libxml-dir=/usr/local/libxml2/\ >-- with-png -dir=/usr/local/libpng/\ >-with-jpeg-dir=/usr/local/jpeg6/\ >-- with-freetype-dir=/usr/local/freetype/\ >-- with-gd=/usr/local/gd2/\ >-- with-mcrypt=/usr/local/libmcrypt/\ >-- with-mysqli=/usr/local/mysql/bin/mysql_config\ >-- enable-soap\ >-- enable-mbstring=all\ >-- enable-sockets
. / configure parameter description:
-- with-config-file-path=/usr/local/php/etc specifies the path where the php5 configuration file is saved
-- with-apxs2=/usr/local/apache2/bin/apxs tells php where to find apache2
-- with-mysql=/usr/local/mysql/ specifies the installation directory of mysql
-- with-libxml-dir=/usr/local/libxml2/ tells php where to put the libxml2 library
-- with-png-dir=/usr/local/libpng/ tells php where to put the libpng library
-- with-jpeg-dir=/usr/local/jpeg6/ tells php where to put the jpeg library
-- with-freetype-dir=/usr/local/freetype/ tells php where to put the freetype library
-- with-gd=/usr/local/gd2/ tells php where to put the gd library
-- with-mcrypt=/usr/local/libmcrypt/ tells php where to put the libmcrypt library
-- with-mysqli=/usr/local/mysql/bin/mysql_config variable activates the newly added mysqli function
-- enable-soap variable activates soap and web services support
-- enable-mbstring=all enables multibyte strings to support
-- enable-sockets variable activates socket communication characteristics
Possible problems with compilation:
The following error occurred:
Solution:
Cd / usr/local/mysql/lib/mysql/ ln-s libmysqlclient.so.15.0.0 libmysqlclient_r.so
After compiling ok, "thank you for using php." appears, indicating that the configuration is successful.
[root@gamejzy php-5.3.19] # make & & make install
Compile and install, it will take a long time, wait patiently!
After the compilation is complete, the following configuration is required
1. Set the php.ini configuration file
[root@gamejzy php-5.3.19] # cp php.ini-development / usr/local/php/etc/php.ini
Note: / usr/local/php/etc is the location specified during configuration
2. Integrate with apache
First open the configuration file httpd.conf of apache
[root@gamejzy php-5.3.19] # vi / etc/httpd/httpd.conf
You'll find something like this in the file.
Loadmodule php5_module modules/libphp5.so
This means that php has been loaded into the apache server, and all we have to do is tell the apache server which suffix names are resolved using php
Search for "addtype application/x-compress .z" in the vi editor
Add one at the end: addtype application/x-httpd-php .php
The effect of the modification is as follows
Save and exit, restart apache
[root@gamejzy php-5.3.19] # / usr/local/apache2/bin/apachectl stop [root@gamejzy php-5.3.19] # / usr/local/apache2/bin/apachectl start
3. Test whether the apache server can parse php.
Add a phpinfo.php file to the / usr/local/apache2/htdocs directory and type the following code:
Open a browser, access the file, and see the figure below, indicating that php was successfully installed and integrated with the apache server.
The above is about the content of this article on "how to build a PHP environment under CentOS5.5". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 269
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.