apache+mysql+php

Source: Internet
Author: User
Tags deprecated script php
Reprinted from: http://blog.csdn.net/buutterfly/article/details/5630203

DEDECMS deployment-How to deploy apache+mysql+php (LAMP)?

1. Linux OS:

Linux os:red Hat Enterprise Linux as Release 4 (Nahant Update 6)

2.Deploy Apache 2.1 Download Apache

Download Apache2 source from http://httpd.apache.org/, download it directly under/root, unzip the tar package php-5.2.13.

2.2 Compiling Apache

CD httpd-2.2.15, compiling, generating makefile

./configure--prefix=/usr/local/apache/--Specify Apache installation directory

--enable-so/

--ENABLE-CGI/

--enable-info/

--enable-rewrite/

--enable-speling/

--enable-usertrack/

--enable-deflate/

--enable-ssl/

--enable-mime-magic

2.3 Make & make Install

There may be some problems with the make process, refer to section 5th.

Apache Deployment Reference: http://dan.drydog.com/apache2php.html

3. Deploy mysql 3.1 download mysql

Download MySQL source from http://dev.mysql.com/, select MySQL Community Server on the Downloads page and go to the download page. Select Red Hat Enterprise Linux. Because my OS is REHL4.6 and is 64-bit, download three packages:

mysql-server-community-5.1.47-1.rhel4.x86_64.rpm mysql-devel-community-5.1.47-1.rhel4.x86_64.rpm? must, Otherwise, Apache will compile with error mysql-client-community-5.1.47-1.rhel4.x86_64.rpm

3.2 Installing MySQL server

RPM? IVH mysql-server-community-5.1.47-1.rhel4.x86_64.rpm

After the server installation is complete, the test is successful to run netstat see if the MySQL port is open, such as open indicates that the service has been started and the installation is successful.

The default port for MySQL is 3306. The command is as follows: Netstat? nap |grep 3306

3.3 Installing the MySQL Client

RPM? IVH mysql-client-community-5.1.47-1.rhel4.x86_64.rpm

3.4 Installing MySQL Devel

RPM? IVH mysql-devel-community-5.1.47-1.rhel4.x86_64.rpm

3.5 Log in to MySQL

[Root@test1 local]# MySQL

Welcome to the MySQL Monitor. Commands End With; Or/g.

Your MySQL Connection ID is 1 to server Version:4.0.16-standard

Type ' help; ' or '/h ' for help. Type '/C ' to clear the buffer.

Mysql>

There is a "mysql>" prompt, congratulations, installation success!

The login format after adding the password is as follows:

Mysql-u root-p

Enter Password: (enter password)

Where-u followed by the user name,-p requires a password, enter the password at the input password.

Note: This MySQL file is in the/usr/bin directory, and the boot file/etc/init.d/mysql is not a file.

3.6 Modifying the MySQL password

MySQL does not have a password by default, the importance of increasing the password is self-evident.

1. Command

usr/bin/mysqladmin-u root password ' new-password '

Format: Mysqladmin-u username-P Old password password new password

2. Example

Example 1: Add a password to root 123456.

Type the following command:

[Root@test1 local]#/usr/bin/mysqladmin-u root password 123456

Note: Because Root does not have a password at the beginning, the-p old password can be omitted.

3. Test whether the modification is successful

1) Login without password

[Root@test1 local]# MySQL

ERROR 1045:access denied for user: ' Root@localhost ' (Using password:no)

An error is displayed stating that the password has been modified.

2) Log in with the modified password

[Root@test1 local]# mysql-u root-p

Enter Password: (Enter the modified password 123456)

Welcome to the MySQL Monitor. Commands End With; Or/g.

Your MySQL Connection ID is 4 to server Version:4.0.16-standard

Type ' help; ' or '/h ' for help. Type '/C ' to clear the buffer.

Mysql>

Success!

This is done by changing the password with the Mysqladmin command, or by modifying the library.

3.7 Start and stop

1. Start

After the MySQL installation is complete, start the file MySQL in the/ETC/INIT.D directory and run the following command when it needs to start.

[Root@test1 init.d]#/etc/init.d/mysql start

2. Stop

/usr/bin/mysqladmin-u root-p shutdown

3. Auto-start

1) See if MySQL is in the auto-start list

[Root@test1 local]#/sbin/chkconfig--list

2) Add MySQL to your system's start-up service group

[Root@test1 local]#/sbin/chkconfig?-add MySQL

3) Remove MySQL from the Startup service group.

[Root@test1 local]#/sbin/chkconfig?-del MySQL

MySQL Deployment reference: http://www.linuxidc.com/Linux/2007-12/9962p3.htm

3.8 using MySQL

(Optional use of this section for our Lamp environment deployment)

The default data file storage directory for MySQL is/var/lib/mysql. The following steps are required if you want to move the directory to/home/data:

1. Set up the data directory in the home directory

Cd/home

mkdir data

2. Stop the MySQL service process:

Mysqladmin-u root-p shutdown

3. Move/var/lib/mysql Entire directory to/home/data

mv/var/lib/mysql/home/data/

This will move the MySQL data file to/home/data/mysql.

4. Locate the MY.CNF configuration file

If there is no MY.CNF configuration file under the/etc/directory, locate the *.cnf file under/usr/share/mysql/, and copy one of them to/etc/and rename it to MY.CNF). The command is as follows:

[Root@test1 mysql]# cp/usr/share/mysql/my-medium.cnf/etc/my.cnf

5. Edit the MySQL configuration file/etc/my.cnf

To ensure that MySQL works correctly, you need to indicate where the Mysql.sock file is generated. Modify the value in the Socket=/var/lib/mysql/mysql.sock line to the right of the equals sign:/home/mysql/mysql.sock. The operation is as follows:

VI my.cnf (Edit the My.cnf file with VI tool, find the following data to modify)

# The MySQL server

[Mysqld]

Port = 3306

#socket =/var/lib/mysql/mysql.sock (original content, in order to be more secure with "#" Comment this line)

Socket =/home/data/mysql/mysql.sock (plus this line)

6. Modify MySQL startup script/etc/rc.d/init.d/mysql

Finally, the MySQL startup script needs to be modified/etc/rc.d/init.d/mysql, the path to the right of the equal sign in the Datadir=/var/lib/mysql line is changed to your current actual storage path: Home/data/mysql.

[Root@test1 etc]# Vi/etc/rc.d/init.d/mysql

#datadir =/var/lib/mysql (Note this line)

Datadir=/home/data/mysql (plus this line)

7. Restart MySQL Service

/etc/rc.d/init.d/mysql start

or restart Linux with the reboot command

If the work is moving properly, otherwise check the previous 7 steps.

4. Deploy PHP

The deployment of PHP is the most difficult part of the whole deployment, which is also a time-consuming and the longest answer on the web.

4.1 Download PHP

Download PHP source from http://www.php.net/

Note: Dedecms 5.6 or above is defective for php5.3 support! If you use the php5.3 version, after the installation of the CMS installation is successful, the system background page will prompt "Deprecated:function ereg_replace () is deprecated to appear after installation has finished".

There are two ways to solve this, see section 5th.

4.2 Compiling PHP

CD php-5.2.13, compile, generate makefile. Note: The configuration items in this place need to be selected according to their needs.

./configure/

--WITH-APXS2=/USR/LOCAL/APACHE/BIN/APXS/

--with-mysql/

--prefix=/usr/local/apache/php/

--with-config-file-path=/usr/local/apache/php/

--enable-force-cgi-redirect/

--DISABLE-CGI/

--with-zlib/

--with-gettext/

--WITH-GDBM/

--with-gd

4.3 Make & make Install 4.4 cp-p. Libs/libphp5.so/usr/local/apache/modules 4.5 cp PHP.ini

The command is as follows: Cp-p Php.ini-recommended/usr/local/apache/php/php.ini

4.6 Modifying httpd.conf

To modify/usr/local/apache/conf/httpd.conf, add the following:

1.

# Example:

# LoadModule Foo_module modules/mod_foo.so

#

LoadModule Php5_module modules/libphp5.so

AddHandler php5-script PHP

2.

# directoryindex:sets The file that Apache would serve if a directory

# is requested.

#DirectoryIndex index.html

DirectoryIndex index.php index.html index.shtml index.cgi

3.

# If The addencoding directives above is commented-out, then you

# Probably should define those extensions to indicate media types:

#

AddType application/x-compress. Z

AddType application/x-gzip. gz. tgz

AddType application/x-httpd-php. php. phtml

AddType Application/x-httpd-php-source. Phps

4.7 Restart Apache After the modification is complete

PHP Installation Reference: http://dan.drydog.com/apache2php.html

5. The problems encountered and the solutions 5.1 error:libpng. (A|SO) not found.

Description of the phenomenon:

When compiling Apache, Tip:

Checking for Floorf ... yes

If Configure fails try--with-jpeg-dir=

Configure:error:libpng. (A|SO) not found.

Workaround:

Through the above search actually know some reasons, configure general search compiled path is/usr/lib/, because PHP by default in/usr/lib/to find the relevant library file, and x64 machine is on:/usr/ Lib64. Then you can directly copy the required library files from the/usr/lib64 to the/usr/lib/.

Then remember to execute the following command before configure:

cp-frp/usr/lib64/libjpeg.*/usr/lib/

5.2 Error:cannot Find MySQL header files under Yes

Description of the phenomenon:

When compiling Apache, Tip:

Checking for specified location of the MySQL UNIX socket ... no

Configure:error:Cannot find MySQL header files under Yes.

Note that the MySQL client library isn't bundled anymore!

Workaround:

This is missing the Mysql-devel installation package, RPM? IVH Install the Devel package, mentioned earlier.

Similarities and differences of 5.3 mysql-server,mysql-devel,mysql-client

English Original:

In most cases, you have need to install the Mysql-server and mysql-client packages to get a functional MySQL installation. The other packages is not required for a standard installation. If you want to run a Mysql-max server then have additional capabilities, you should also install the Mysql-max RPM. However, you should does so only after installing the Mysql-server RPM.

If you get a dependency failure when trying to install the MySQL 4.0 packages (for example, ' error:removing these Packag ES would break dependencies:libmysqlclient.so.10 are needed by ... "), you should also install the package Mysql-shared-co Mpat, which includes both the shared libraries for backward compatibility (libmysqlclient.so.12 for MySQL 4.0 and Libmysql client.so.10 for MySQL 3.23).

The following RPM packages is available:

mysql-server-version.i386.rpm the MySQL server. You'll need this unless if want to connect to a MySQL server running on another machine. Note:server RPM files were called mysql-version.i386.rpm before MySQL 4.0.10. That's, they did isn't have-server in the name.

mysql-max-version.i386.rpm the Mysql-max server. This server has additional capabilities, the one provided in the Mysql-server RPM does not. You must install the Mysql-server rpm first and because the Mysql-max rpm depends on it.

MYSQL-CLIENT-VERSION.I386.RPM the standard MySQL client programs. You probably all want to the install this package.

MYSQL-BENCH-VERSION.I386.RPM Tests and benchmarks. Requires Perl and the Dbd::mysql module.

MYSQL-DEVEL-VERSION.I386.RPM the libraries and include files that is needed if you want to compile other MySQL clients, s Uch as the Perl modules.

MYSQL-SHARED-VERSION.I386.RPM the contains the shared libraries (libmysqlclient.so*) that certain languages and a Pplications need to dynamically load and use MySQL.

MYSQL-SHARED-COMPAT-VERSION.I386.RPM the includes the shared libraries for both MySQL 3.23 and MySQL 4.0. Install the instead of mysql-shared if you have applications installed that is dynamically linked against MySQL 3.23 want to upgrade to MySQL 4.0 without breaking the library dependencies. This package has been available since MySQL 4.0.13.

mysql-embedded-version.i386.rpm the embedded MySQL server library (from MySQL 4.0).

mysql-version.src.rpm this contains, the source code for all of the previous packages. It can also is used to rebuild the RPMs in other architectures (for example, Alpha or SPARC).

Chinese translation:

mysql-version.i386.rpm MySQL server. Unless you just want to connect with a MySQL server running on another machine, otherwise you will need it.

MYSQL-CLIENT-VERSION.I386.RPM standard MySQL client program. You may always need to install this package.

MYSQL-BENCH-VERSION.I386.RPM Testing and benchmarking procedures. Perl and Msql-mysql-modules RPM are required.

MYSQL-DEVEL-VERSION.I386.RPM the required libraries and include files. If you want to compile other MySQL client programs, such as Perl modules.

MYSQL-VERSION.SRC.RPM contains the source code for all of the above packages. It can also be used to try to construct RPMs for other hardware platforms (for example, Alpha or SPARC).

To view all the files in a RPM package:

shell>; RPM-QPL mysql-version.i386.rpm

To implement a standard minimum installation, run this command:

shell>; Rpm-i mysql-version.i386.rpm mysql-client-version.i386.rpm

5.4 Error:cannot Find Libmysqlclient under/usr

Description of the phenomenon:

Error:cannot Find Libmysqlclient Under/usr

Workaround:

In fact, the same as the 5.1 solution. Put/usr/lib64/mysql copy to/usr/lib/.

5.5 CMS Directory permissions issue

Description of the phenomenon:

After entering the Install page, it is suggested that some directories do not have read and write permissions, as follows:

/usr/local/apache/htdocs/uploads

Directory name Read permission Write permission

/[√] read [X] write----refer to/usr/local/apache/htdocs/uploads

/plus/* [√] read [X] Write

/dede/* [√] read [X] Write

/data/* [√] read [√] Write

/a/* [√] read [√] Write

/install [√] read [√] Write

/special [√] read [√] Write

/uploads/* [√] read [√] Write

Workaround:

When installing CMS, prompt permission is insufficient, need to modify uploads directory permission

Chmod 777 Uploads-r

5.6 Deprecated:function ereg_replace () is Deprecated

Note: Dedecms 5.6 or above is defective for php5.3 support! If you use the php5.3 version, after the installation of the CMS installation is successful, the system background page will prompt "Deprecated:function ereg_replace () is deprecated to appear after installation has finished".

There are two ways to solve this, see section 5th.

The first type:

Dedecms because the technician's habit problem may be for php5.3 or even later PHP support will be some errors, you can open the file dede/config.php

Find define (' Dedeadmin ', ereg_replace ("[///]{1,}", '/', dirname (__file__)));

There is no need to delete, just add "//" in front of this sentence to hide it, and then add a sentence below

Define (' Dedeadmin ', Strtr (DirName (__file__), '///', '//'));

You can do it! Upload overlay, then update under Look, should solve the problem!

The second type:

Re-download the php5.2 package. In fact, this use is not troublesome, is to recompile, but the most direct way to solve the problem. In order to prevent any further problems, I used the php5.2 recompile again.

The above operation regular expressions are interpreted as follows:

In regular expressions, backslashes are often combined with other characters to form a special structure, such as '/d ' used to match numeric characters, '/s ' to match whitespace characters, '/1 ' to reverse reference to the first grouped captured text.

But what if we just need to represent the backslash character itself in the regular expression?

In fact, the regular expression handling of this problem is the same as the processing of the string, that is, in the regular expression, you must use the escape sequence '//' to represent a single backslash.

This rule brings up an interesting question: the backslash character that appears alone in a regular expression, at the level of the regular expression, must be represented by the escape sequence '//', however, each backslash, in the string that represents the regular expression, must be represented by an escape sequence '//'. Therefore, in a string, you must write four backslashes '////' to correspond to a single backslash character that appears in the regular expression: at the string processing level, they are recognized as two backslashes '//', and at the level of the regular expression, they are recognized as a single backslash character '/'.

  • 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.