LAMP: Typical Linux + Apache + Mysql + PHP configuration

Source: Internet
Author: User
LAMP: typical configuration of Linux + Apache + Mysql + PHP-Linux Enterprise Application-Linux server application information. For details, refer to the following section. Debugging environment: Redhat9.0 Apache1.3.29 Mysql3.23.58 PHP4.3.4


I will not talk about Linux installation. This is a basic skill. In fact, this article is applicable to other linux systems similar to Redhat. You only need to master the methods I provide. Remember to install Redhat9. Do not install the default apache, mysql, php, and related software. Use rpm-e * to delete installed packages.


1. Install Mysql3.23.58


In fact, it is quite feasible to directly install the rpm package provided by the official Mysql website. The rpm package provided by his official website is basically synchronized with the tar package release, I like this very much. At least the rpm package will not be found in the mysql library file during subsequent debugging. However, it is necessary to talk about the steps for custom installation. After all, there are a lot of user-defined installation steps.


Software acquisition: http://www.mysql.com/downloads/index.html


Installation steps:


Tar zxvf mysql-3.23.58.tar.gz

Cd mysql-3.23.58


./Configure -- prefix =/usr/local/mysql -- sysconfdir =/etc -- localstatedir =/var/lib/mysql


Make


Make install


# Prefix =/usr/local/mysql target directory for mysql Installation


# Sysconfdir =/etc my. ini configuration file path


# Localstatedir =/var/lib/mysql database storage path


Initialize the database after installation. You do not need to perform this step if you upgrade the database;


/Usr/local/mysql/bin/mysql_install_db



If the system does not have a mysql user, do the following:


Useradd-M-o-r-d/var/lib/mysql-s/bin/bash-c "MySQL Server"-u 27 mysql


Then I start mysql


/Usr/local/mysql/bin/safe_mysqld &


OK. Check if mysql works properly.


Mysql-uroot mysql


Generally, the database cannot be connected normally. The error message is:


ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)


In fact, most of the questions on the Internet are the whole question. If you cannot find any link to mysqld. sock, you may wish to see the mysql error log to understand what is going on. Here, the error log is


/Var/lib/mysql /*. err, you will find that mysql cannot be started only because/var/lib/mysql does not allow access to the mysql service. By default, mysql calls the mysql user to start the service, since you know why it cannot be started, it's easy. As long


Chown-R mysql: mysql/var/lib/mysql. If it still cannot be started, you can debug the permission slowly. Generally, it is a permission issue if it cannot be started.


If you still cannot start it, use my complicated permission settings. I do this every time. Generally, there is no problem. See:


Chown-R root/usr/local/mysql

Chgrp-R mysql/usr/local/mysql

Chown-R root/usr/local/mysql/bin

Chgrp-R mysql/usr/local/mysql/bin

Chgrp-R mysql/var/lib/mysql

Chmod 777/var/lib/mysql

Chown-R root/var/lib/mysql

Chgrp-R mysql/var/lib/mysql

Chmod 777/var/lib/mysql

Chown-R root/var/lib/mysql /*

Chgrp-R mysql/var/lib/mysql /*

Chmod 777/var/lib/mysql /*

Chmod 777/usr/local/mysql/lib/mysql/libmysqlclient.




After completing the above steps, COPY a script in your compiled directory


Cp support-files/mysql. server/etc/rc. d/init. d/mysqld


Chkconfig -- add mysqld


Set ntsysv to enable mysql to run automatically at each startup.


Now that mysql is installed, you can start your mysql service.


/Etc/rc. d/init. d/mysqld start


The following steps are critical,


Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql

Ln-s/usr/local/mysql/include/mysql/usr/include/mysql


You can skip this step. You can customize the myslq library file path when compiling other software, but I still like to link the library file to the default location, so that you are compiling PHP like, when using software such as Vpopmail, you do not need to specify the mysql library file address.


2. Install Apache1.3.29. I didn't choose whether to install Apache2.0 or not, because the latest apache vulnerability published on the internet is basically for Version 2.0. Of course, you can choose to install the corresponding version on your own. I am talking about using DSO dynamic compiling to compile Apache.


As for the apache compilation method, you can refer to my previous article "apache static/dynamic compilation in apache + php + mysql application" http://www.5ilinux.com/apache01.html


Software acquisition: http://httpd.apache.org/


Tar zvxf apache_1.3.29.tar.gz

Cd apache_1.3.29

Modify src/include/httpd. h to increase the maximum number of threads


# Define HARD_SERVER_LIMIT 256


Change


# Define HARD_SERVER_LIMIT 2560


Save and exit apache Compilation



./Configure -- prefix =/usr/local/apache -- enable-module = so -- enable-module = rewrite -- enable-shared = max -- htdocsdir =/var/www &&

Make &&

Make install


# Here we use the enable-module parameter to tell the setup script. We need to start the so and rewrite modules. The so module is the core apache module used to extract DSO support, the rewrite module is intended to implement address rewriting. Because the rewrite module requires DBM support, if it is not compiled into apache at the first installation, in the future, you need to re-compile the entire apache to implement this function. Therefore, unless you are sure that the rewrite module will not be used in the future, we recommend that you compile the rewrite module during the first compilation.


Enable-shared = max when compiling apache, all apache standard modules except so are compiled into DSO modules. Instead of compiling it into the apache core.




It's easy to install apache. Start apache.


/Usr/local/apache/bin/apachectl start


Then use ie to view http: // your server address. You should be able to see the familiar apache feather flag.


3. Install PHP4.3.4


Software acquisition: http://www.php.net/downloads.php


Tar zvxf php-4.3.4.tar.gz

Cd php-4.3.4


./Configure \

-- Prefix =/usr/local/php \

-- With-mysql =/usr/local/mysql \

-- Enable-force-cgi-redirect \

-- With-freetype-dir =/usr \

-- With-png-dir =/usr \

-- With-gd -- enable-gd-native-ttf \

-- With-ttf \

-- With-gdbm \

-- With-gettext \

-- With-iconv \

-- With-jpeg-dir =/usr \

-- With-png \

-- With-zlib \

-- With-xml \

-- Enable-calendar \

-- With-apxs =/usr/local/apache/bin/apxs


Make


Make install




# Because the server needs to use the GD library, I added some compilation parameters that support GD. GD directly uses the GD library that comes with redhat. If you haven't installed it, you can install it from the installation disk, note: Besides GD, libjpeg, libpng, and other library files must be installed. In addition, -- with-mysql =/usr/local/mysql points to the path where you install mysql. -- With-apxs points to the path of apache apxs file.


Vi/usr/local/apache/conf/httpd. conf


Search;


Add in this range


AddType application/x-httpd-php. php

AddType application/x-httpd-php-source. phps




However, the configuration file of CPOPY PHP


Cp ../php4.3.4/php. ini. dist/usr/local/php/lib/php. ini


Modify the php. ini file

Register_globals = On



OK! Restart the apache server.

/Usr/local/apache/bin/apachectl restart


Then write a php test page info. php: The content is as follows:


Phpinfo ();

?>;


If it is normal, you should be able to see the php information. Congratulations on your Apche + Mysql + PHP installation.




Well, I have written so much, I hope it will help you !!!



See the document:


Application of apache static/dynamic compilation in apache + php + mysql
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.