CentOS5 + apache + mysql + php configuration

Source: Internet
Author: User
Tags localhost mysql
1. install Mysql1 and create the msyql User Group [root @ localhost ~] # Grepmysql/etc/group # check whether the mysql User group exists in the query system. If no user group exists, add it. [Root @ localhost ~] # Groupaddmysql # Add a user group named mysql 2. create a mysql User [root @ localhost ~] #

1. install Mysql
1. create an msyql User Group
[Root @ localhost ~] # Grep mysql/etc/group
# Check whether the user group mysql exists in the query system. If no user group exists, add it.
[Root @ localhost ~] # Groupadd mysql
# Add a user group named mysql
2. create a mysql User
[Root @ localhost ~] # Grep mysql/etc/passwd
# Check whether the user mysql exists in the query system. if the user does not exist, add the user.
[Root @ localhost ~] # Useradd mysql-g mysql-M-s/sbin/nologin
# Add a user named mysql.
-G: specifies the user group to which the new user belongs)
-M: Do not create a root directory
-S: defines the shell it uses./sbin/nologin indicates that the user cannot log on to the system.
3. decompress: mysql
[Root @ localhost ~] # Cd/usr/local/src/
[Root @ localhost src] # tar-zxvf mysql-5.0.27.tar.gz
#...... (Omitted information )......
# Decompress
3. set compiler compilation parameters
[Root @ localhost src] # cd/usr/local/src/mysql-5.0.27
[Root @ localhost mysql-5.0.27] #. /configure -- prefix =/usr/local/mysql -- with-unix-socket-path =/tmp/mysql. sock -- localstatedir =/usr/local/mysql/data -- with-charset = gbk -- without-debug -- enable-handler er -- without-isam -- with-client-ldflags =-all- static -- with-mysqld-ldflags =-all-static
# These settings tell the compiler how to compile apache:
? Prefix =/usr/local/mysql
Specify the msyql installation directory
? With-unix-socket-path =/tmp/mysql. sock
This specifies the location and file name of the online socket file after the mysql server is started.
? Localstatedir =/usr/local/mysql/data
Specify the mysql database Directory
? With-charset = gbk
Added support for gbk Chinese characters
? Without-debug
Remove debug mode
? Enable-cycler
Use the Assembly version of some character functions
? Without-isam
Removed the isam table type support and is rarely used now. the isam table is a platform-dependent table.
? With-client-ldflags =-all-static
? With-mysqld-ldflags =-all-static
4. Compile and install
[Root @ localhost mysql-5.0.27] # make
# The "make" command compiles the source file into executable binary files.
[Root @ localhost mysql-5.0.27] # make install
# "Make install" install binary files and configuration files in the appropriate directory
6. initialize the system Library
[Root @ localhost mysql-5.0.27] #./scripts/mysql_install_db
7. other settings
[Root @ localhost mysql-5.0.27] # cp support-files/my-medium.cnf/etc/my. cnf-fv
# Note:
-F: delete a file or directory with the same name in the target without any prompt.
# There are some other my. cnf configuration files. Suitable for different application scales. The type is my-*. cnf. Cp according to your needs.
[Root @ localhost mysql-5.0.27] # cp support-files/mysql. server/etc/init. d/mysqld
# Add to startup script
[Root @ localhost mysql-5.0.27] # chmod 700/etc/init. d/mysqld
[Root @ localhost mysql-5.0.27] # cd/usr/local
[Root @ localhost local] # chmod 750 mysql-R
# Note:
-R recursively changes the permissions of directories and their contents.
[Root @ localhost local] # chown-R mysql. mysql/usr/local/mysql
# Set the owner. mysql runs as a mysql User during startup, which improves system security.
[Root @ localhost local] # chown-R mysql. mysql/usr/local/mysql/data
[Root @ localhost local] # cd/usr/local/mysql/libexec
[Root @ localhost libexec] # cp mysqld. old
[Root @ localhost libexec] # strip mysqld
[Root @ localhost libexec] # chkconfig? Add mysqld
# Add a service. you can also manually add the service.
[Root @ localhost libexec] # chkconfig? Level 345 mysqld on
# Set start at startup
[Root @ localhost libexec] # service mysqld start
# Start the mysql service
[Root @ localhost libexec] # ln-s/usr/local/mysql/bin/mysql/sbin/mysql
[Root @ localhost libexec] # ln-s/usr/local/mysql/bin/mysqladmin/sbin/mysqladmin
[Root @ localhost libexec] # ln-s/usr/local/mysql/bin/mysqldump/sbin/mysqldump
[Root @ localhost libexec] # mysqladmin-uroot password "youpassword"
# Set the password for the root account
[Root @ localhost libexec] # mysql-uroot-p
# Enter your password
Mysql> use mysql;
Mysql> delete from user where password = "";
# Delete an empty password account used for anonymous connection to the local machine
Mysql> flush privileges;
Mysql> show databases;
+ ---- +
| Database |
+ ---- +
| Mysql |
| Test |
+ ---- +
2 rows in set (0.08 sec)
# Display the database and test whether mysql is installed normally.
Mysql> quit

If you forget your password, you can:
My system is linux. the newly installed mysql always has an error prompt when it comes to the mysql tool:
# Mysql-uroot-p
Enter password:
ERROR 1045 (28000): Access denied for user [email =] root @ localhost [/email] (using password: NO)
Use the methods described on the Internet to change the password of the root user:
# Mysqladmin-uroot-p password newpassword
Enter password:
Mysqladmin: connect to server at localhost failed
Error: Access denied for user [email =] root @ localhost [/email] (using password: YES)
Now I have found the solution as follows (please test method 3 first, thank you !) :
Method 1:
#/Etc/init. d/mysql stop
# Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &
# Mysql-u root mysql
Mysql> UPDATE user SET Password = PASSWORD (newpassword) where USER = root;
Mysql> flush privileges;
Mysql> quit
#/Etc/init. d/mysql restart
# Mysql-uroot-p
Enter password: <输入新设的密码newpassword>

II. install Apache
1. Download: apache
[Root @ localhost src] # chmod + x httpd-2.2.8.tar.gz
[Root @ localhost src] # tar-zxvf httpd-2.2.8.tar.gz
3) set compiler compilation parameters
[Root @ localhost src] # cd httpd-2.2.8
[Root @ localhost httpd-2.2.8] #./configure? Prefix =/usr/local/apache2? Enable-module = so
4) compilation and installation:
[Root @ localhost httpd-2.2.8] # make; make install
# If no error occurs, Apache is installed in the/usr/local/apache2 directory.
3. start the service:
[Root @ localhost httpd-2.2.8] #/usr/local/apache2/bin/apachectl start
4. confirm the startup status:
[Root @ localhost apache2] # netstat-utl
Tcp 0 0 *: http *: * LISTEN
# If you see this line, your Apache has been started.
# Access It works in a browser !, It indicates that apache has been installed successfully. Congratulations!

3. install PHP
1. prepare the directory:
Mkdir/usr/local/modules
# Jpeg Directory
Mkdir/usr/local/modules 6
Mkdir/usr/local/modules 6/bin
Mkdir/usr/local/modules 6/lib
Mkdir/usr/local/modules 6/include
Mkdir/usr/local/modules 6/man
Mkdir/usr/local/modules 6/man/man1
2. install zlib
# Tar xzvf zlib-1.2.3.tar.gz
# Music zlib-1.2.3/usr/local/src/
# Cd/usr/local/src/zlib-1.2.3
Do not use -- prefix to customize the installation directory, which affects gd installation.
#./Configure
# Make & make install
3. install freetype
# Tar xzvf freetype-2.3.5.tar.bz2
# Music freetype-2.3.5/usr/local/src/
# Cd/usr/local/src/freetype-2.3.5
#./Configure -- prefix =/usr/local/modules/freetype
# Make & make install
4. install libpng
# Tar jxvf libpng-1.2.20.tar.bz2
Do not use -- prefix to customize the installation directory, which affects gd installation.
# Music libpng-1.2.20/usr/local/src/
# Cd/usr/local/src/libpng-1.2.5
# Cp scripts/makefile. std makefile
# Make test
# Make install
5. install jpeg
# Tar xzvf restart src.v6b.tar.gz
# Music jpeg-6b/usr/local/src/
# Cd/usr/local/src/jpeg-6b
#./Configure -- prefix =/usr/local/modules 6 -- enable-shared -- enable-static
# Ma

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.