Set up a dynamic Web server supporting Mysql in Linux

Source: Internet
Author: User
Article Title: Set up a dynamic Web server that supports Mysql in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

This article is the installation and configuration manual for installing PHP dynamic Web servers and Mysql Databases on Linux servers. By installing Apache, Mysql, PHP, and other functions on the server, you can build a PHP dynamic Web site. This article uses Redhat9.0 Linux as the operating system level. The Apache version is 1.3.29, the Mysql database card is 3.23.58, And the PHP version is 4.3.4!

The installation of the Linux system is not discussed here. This article is based on the Redhat 9.0 minimal installation and kernel development kit. For other software installed with apache, mysql and php. 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.

 

[1] [2] Next page

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.