Typical configuration of Linux+Apache+Mysql+PHP

巴扎黑
Release: 2016-11-24 09:26:50
Original
1028 people have browsed it

Linux+Apache+Mysql+PHP typical configuration

Debugging environment: Redhat9.0 Apache1.3.29 Mysql3.23.58 PHP4.3.4

I won’t go into the installation of the Linux system. This is the basic skill. In fact, this article is similar to Redhat It should also be applicable to other Linux, as long as you master the method I provided. Remember not to install the system default apache, mysql, php and related software when installing Redhat9.0. If it is already installed, please use rpm -e * to delete the installed package.

1. Install Mysql3.23.58

In fact, to be honest, it is a more feasible way to directly install the rpm package provided by the Mysql official website. The rpm package provided by its official website is basically synchronized with the tar package release. This is what I think I like it better. At least if you install the rpm package, the mysql library file will not be found during subsequent debugging. But it is still necessary to talk about the steps of custom installation here. After all, there are quite a lot of custom installations by netizens.

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 Path to my.ini configuration file

#localstatedir=/var/lib/mysql Database storage path

After installation, you need to initialize the database. Of course, you don’t need to do this step if you are upgrading;

/ usr/local/mysql/bin/mysql_install_db


If the system does not have the user mysql, it is best to do the following steps:

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, first see if mysql can work normally

mysql -uroot mysql

General In most cases, the database cannot be connected normally, and the error message is generally:

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

In fact, people online ask The most common problem is the whole problem, saying that mysqld.sock cannot be linked. In fact, you might as well look at the error log of mysql to understand what is going on. My error log here is in

/var/lib/mysql/*. err You will find that the reason why mysql cannot be started is because the permissions of /var/lib/mysql do not allow the mysql service to be accessed. By default, English mysql calls the mysql user to start the service. Well, now that you know the reason why it cannot be started, That's easy. All we need to do is

chown -R mysql:mysql /var/lib/mysql. If it still can’t start, then slowly debug the permissions. Anyway, it’s generally a permissions issue if it can’t start.

If you still can’t start it, then use my more complicated permission settings. Anyway, I do this every time, and there is usually no problem. See below:

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/mysql
chgrp -R mysql /var/lib/mysql/mysql
chmod 777 /var/lib/mysql/mysql
chown - R root /var/lib/mysql/mysql/*
chgrp -R mysql /var/lib/mysql/mysql/*
chmod 777 /var/lib/mysql/mysql/*
chmod 777 /usr/local/mysql/ lib/mysql/libmysqlclient.a



Complete the above steps, and then COPY a script in your compiled directory

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

chkconfig --add mysqld

Use ntsysv settings to make mysql run automatically every time it is started.

Okay, now mysql is installed, you can start your mysql service like this

/etc/rc.d/init.d/mysqld start

The next step is more critical,

ln -s /usr/local /mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql

You don’t have to do this step. You can customize the library file path of myslq when compiling other software, but I still like to link the library file to the default location, so that you don’t need to specify it when compiling software like PHP, Vpopmail, etc. The library file address of mysql.

2. Install Apache1.3.29. I did not choose to install Apache 2.0 because I was still worried about it, because the latest apache vulnerabilities published on the Internet are basically for 2.0. Of course, you can choose to install the corresponding version. What I’m talking about here is using DSO dynamic compilation method to compile Apache.

As for the compilation method of apache, you can refer to my previous article "Application of static/dynamic compilation of apache in apache+php+mysql" 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 Add Large maximum number of threads

#define HARD_SERVER_LIMIT 256

Changed to

#define HARD_SERVER_LIMIT 2560

Save and exit compilation apache


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

#Here we tell the setup script through the enable-module parameter that we need to start the so and rewrite modules, The so module is an apache core module used to provide DSO support, while the rewrite module is a module intended to implement address rewriting. Since the rewrite module requires DBM support, if it is not compiled into apache during the initial installation, it will need to be rewritten when needed in the future. This can only be achieved by compiling the entire apache. For this reason, unless you are sure that you will not use the rewrite module in the future, it is recommended that you compile the rewrite module during the first compilation.

enable-shared=max The function of this parameter is to compile all apache standard modules except so into DSO modules when compiling apache. Rather than being compiled into the apache core.



Okay, installing apache is very simple. Start apache and see

/usr/local/apache/bin/apachectl start

Then use IE to see http://your server address. You should see the familiar Apache feather logo.

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



# Since the server needs to use the GD library, I have added some compilation parameters that support GD. GD directly uses the GD library that comes with redhat. If you have not installed it, you can install it from the installation disk. , please note that in addition to installing GD, you also need to install libjpeg, libpng and other library files. In addition, --with-mysql=/usr/local/mysql points to the path where you installed mysql. --with-apxs points to the path of apache's apxs file.

vi /usr/local/apache/conf/httpd.conf

Find ;

Add in this scope

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



Ran CPOPY PHP configuration file

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

Modify 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();
?>;

Normal If so, you should be able to see the php information. Congratulations on your successful installation of Apche+Mysql+PHP.

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template