Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation method of apache+php+mysql under CentOS

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to install apache+php+mysql under CentOS". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "the installation method of apache+php+mysql under CentOS".

To recommend a very good CentOS configuration system is very valuable to learn, here I mainly explain the application of CentOS configuration system, including the introduction of CentOS configuration knowledge and other aspects of centos configuration apache+php+mysql! About the installation of apache+php+mysql.

First of all

Download software; apache download address http://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gzphp download address: http://cn.php.net/distributions/php-5.2.6.tar.gzmysql download address: http://mysql.ntu.edu.tw/Downloads/MySQL-5.0/mysql-5.0.51a-linux-i686-glibc23.tar.gz

First

[root@localhost] # wget http://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gz-- 00VlV 47RV 30muri-http://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gz Resolving apache.mirror.phpchina.com... 221.194.139.225 Connecting to apache.mirror.phpchina.com | 221.194.139.225 |: 80. Connected. HTTP request sent, awaiting response... 200 OK Length: 6396996 (6.1m) [application/x-gzip] Saving to: `httpd-2.2.9.tar.gz.1' 0 [] 36300 41.3K/s [root@localhost] tar zxvf httpd-2.2.9.tar.gz

Decompress below

Httpd-2.2.9/srclib/apr-util/test/abts_tests.h httpd-2.2.9/srclib/apr-util/test/data/ httpd-2.2.9/srclib/apr-util/test/dbd.c httpd-2.2.9/srclib/apr-util/test/Makefile.in httpd-2.2.9/srclib/apr-util/test/Makefile.win httpd-2.2.9/srclib/apr-util/test/nw_misc.c httpd- 2.2.9/srclib/apr-util/test/nwgnuaputest

Then go to [root@localhost ~] cd httpd-2.2.9 and compile apache [root@localhost httpd-2.2.9]. / configure-- prefix=/usr/local/apache-- enable-track-vars-- enable-cgi-- with-config-file-path=/usr/local/apache/conf to compile this will take some time.

The following is a brief description of the meaning of compiled these-- prefix=//usr/local/mysql/apache specifies that apahce is installed in the / / usr/local/mysql/apache directory;-- enable-cgi supports CGI;--with-config-file-path=//usr/local/mysql/apache/conf to specify that apache configuration files are placed in / / usr/local/mysql/apache/conf; for example, httpd.conf configuration files are in this directory. -- enable-track-vars has almost been compiled to start tracking functions such as get/post of cookie.

Will prompt apache installation is successful, [root@localhost] make;make install / / and then enter compile this command is very simple: make;make install! Then enter to start the apache service. [root@localhost] server httpd restart go here to install apache successfully delete the default page rm-f / usr/local/apache/conf.d/welcome.conf to see the lovely 403 error!

2. Install CentOS and configure php

[root@localhost ~] # tar zxvf php-5.2.6.tar.gz / / extract the php file [root@localhost ~] # cd php-5.2.6 / / into the php installation directory [root@localhost php-5.2.6] #] #. / configure-- prefix=//usr/local/mysql/php-- with-mysql=//usr/local/mysql/mysql-- with-apxs2=//usr/local/mysql/apache/bin/apxs-- enable -track-vars-- enable-force-cgi-redirect-- with-config-file-path=//usr/local/mysql/php/etc / / compile php

CentOS configuration installation:

[root@localhost php-5.2.6] # make [root@localhost php-5.2.6] # make install

Copy php.ini-dist to php.ini and store it in the / usr/local/php directory! [root@localhost php-5.2.6] # cp php.ini-dist / usr/local/php/php.ini edit / usr/local/php/php.ini file, find the following line; default_charset = "iso-8859-1" add a line below this line default_charset = "gb2312//, combine apache+php to find the line # AddType application/x-tar .tgz, and add a line below. Don't add a # sign before it.

AddType application/x-httpd-php .php finds the following line and adds index.php at the end, which means that the default page of the website can also be used for index.php DirectoryIndex index.html index.html.var index.php. After we test the php page, edit vi / usr/www/html/test.php and write echo > > / usr/www/html/test.php. Here the php+apache is installed successfully.

3. Install CentOS and configure mysql

1] decompression

[root@localhost root] # cd / usr/local/mysql/software [root@localhost software] # ls mysql-4.0.16.tar.gz [root@localhost software] # tar zxvf mysql-4.0.16.tar.gz

2] compile and install: it is worth noting in this place that we need to install mysql-4.0.16 into our designated directory. For the sake of system and security and optimization, it is recommended to put all the server software installed with the source package in the / / usr/local/mysql directory. So here, we will install the CentOS configuration mysql-4.0.16 into the / / usr/local/mysql/mysql directory as well

[root@localhost software] # cd [root@localhost software] # cd mysql-4.0.16 [root@localhost mysql-4.0.16] #. / configure-prefix=//usr/local/mysql/mysql-with-mysqld-user=beinan-with-extra-charsets=all-with-unix-socket-path=//usr/local/mysql/mysql/var/mysql.sock

[note] A note on the options for configure:

-- prefix=//usr/local/mysql/mysql installs mysql-4.0.16 specified in the / / usr/local/mysql/mysql directory;-- with-extra-charsets=all support for multiple languages;-- with-unix-socket-path=//usr/local/mysql/mysql/var/mysql.sock this is after the specified mysql server starts

The location and file name of the online socket file, that is, if the CentOS configuration mysql server starts successfully, you will see the mysql.sock file in the / / usr/local/mysql/mysql/var directory. If you can't see it, it must be that mysql won't start.

-- with-mysqld-user=beinan this enables the mysql server to enable the ordinary user beinan in the system to start the mysql server. Of course, if you want to learn and use it, you can also replace beinan with ordinary users who already exist in your system. For example, if sir already exists in your system, just replace beinan with sir.

The advantage of using an ordinary user to start CentOS and configure mysql is that the mysql process will die and exit automatically. Of course, root users can, but sometimes some mysql processes die, but will not automatically exit, root itself can not kill. Therefore, using ordinary users has such an advantage. Most of the mysql processes will not be dead, but will not exit.

[root@localhost mysql-4.0.16] # make [root@localhost mysql-4.0.16] # make install so the installation is finished

3] configure mysql: installation is only a * * step, and we need to configure mysql accordingly.

In general, CentOS configuration mysql needs to find the configuration file my.cnf, which is located in the / etc directory, so we have to put the file my.cnf file in the / etc/ directory. So that the mysql server can be found when it starts.

After our CentOS configuration installs mysql, the configuration files should be in the / / usr/local/mysql/mysql/share/mysql directory. There are several CentOS configuration files, such as my-huge.cnf my-medium.cnf my-large.cnf my-small.cnf, websites with different traffic and server environments with different configurations. Of course, different configuration files are required. Under normal circumstances, the my-medium.cnf configuration file can meet most of our needs.

Go to the / usr/local/mysql directory and see if it has been installed.

[root@localhost mysql-4.0.16] # cd / / usr/local/mysql/mysql/ [root@localhost mysql] # ls bin include info lib libexec man mysql-test share sql-bench

Let's copy the my-medium.cnf in the / / usr/local/mysql/mysql/share/mysql directory as my.cnf to the / etc directory. [root@localhost mysql] # cp / / usr/local/mysql/mysql/share/mysql/my-medium.cnf / etc/my.cnf

After doing this work, you still have to create the MySQL authorization table, otherwise the database will not start. Mysql_install_db, that's what this command is for. Mysql commands are installed in the / / usr/local/mysql/mysql/bin directory. [root@localhost mysql] # / / usr/local/mysql/mysql/bin/mysql_install_db

After running the mysql_install_db command, we look at / / usr/local/mysql/mysql and find that there is a directory for var. This directory is used to install all the databases. For example, after we created the database of linuxsir, we have the directory of linuxsir in the / / usr/local/mysql/mysql/var directory. I think you understand this time.

4) it may be the easiest to start the CentOS configuration mysql server, but don't be happy too early, because sometimes there will be permission errors.

CentOS configuration mysql server startup, should be / / usr/local/mysql/mysql/share/mysql directory in the mysql.server startup method is: [root@localhost mysql] # / / usr/local/mysql/mysql/share/mysql/mysql.server start if you can not start, please run / usr/local/mysql/bin/mysqld_safe-- user=root will be able to start!

Then type / usr/local/mysql/mysql/share/mysql/mysql.server start to start successfully.

We set the password to 123456 / usr/local/mysql/bin/mysqladmin-u root password 123456 if no error is returned. Then type / usr/local/mysql/bin/mysql-u root-p to manage the mysql.

At this point, I believe you have a deeper understanding of "the installation method of apache+php+mysql under CentOS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report