Install Apache PHP MySql in Linux

Source: Internet
Author: User
Tags apache php php mysql zts

Install Apache in Linux

1. Decompress tar-zxvf httpd-2.2.15.tar.gz

2. Go to the httpd-2.2.15 directory and run

[admin@test208003 httpd-2.2.15]$./configure --prefix=/home/admin/apache --enable-so--enable-mods-shared=most --with-mpm=worker 

Prefix = <install_path> indicates that the compiled binary file is installed in the <install_path> directory and replaced with the actual installation path <install_path>, for example, -- prefix =/usr/local/Apache-2.2.15, if this configuration parameter is omitted, it is installed in the/usr/local/apache2 directory by default.

-- Enable-so indicates that the compiling dynamic loading module (DSO) supports httpd binary files. This module enables the functional modules of Apache to be separated from the core for compilation and dynamic loading during runtime. With DSO support, you only need to compile the relevant modules when upgrading and adding modules. You do not have to re-compile the entire system. The latest version of Apache compiles this module to the httpd binary file by default. If you are using an earlier version of Apache and need DSO support, you may need to explicitly specify this option.

-- Enable-mod-shared = <module-List> indicates the module to be compiled in DSO mode. <module-List> indicates the list of modules separated by spaces, including all or most, all indicates that all modules are included, and most indicates that most modules are included, such as -- enable-mod-Share = "rewrite deflate", -- enable-mod-Share = most, the effect is equivalent to multiple -- enable-<feature> = Share

-- With-MPM = <MPM> select the Apache Multi-path processing module, <MPM >={ BEOs | event | worker | prefork | mpmt_os2}, and prefork is the default processing module in UNIX systems, it runs a non-thread-type, pre-derived Web server. It is suitable for systems without thread security libraries and needs to avoid thread compatibility issues, it is the best MPM for each request to be independent from each other, so that if a request fails, it will not affect other requests. Worker is a multi-path processing module that supports mixed multi-thread, multi-process processing. because it uses threads to process requests, it can process massive requests. the overhead of system resources is less than the MPM Based on processes, it also uses multiple processes, and each process has multiple threads to obtain the stability of the process-based MPM. If your system is thread-safe, we recommend that you use worker instead of prefork, which will improve your system performance.

3. [admin @ test208003 httpd-2.2.15] $ make

4. [admin @ test208003 httpd-2.2.15] $ make install

5. Configure HTTP. conf (check whether port 80 is occupied,Root or sudo permissions are required to use ports within 1024 in Linux.)

User admin

Group Admin

The above two configurations are the security guarantee of Apache. After Apache opens the port, it sets itself as the user set for the two options.

And group permissions, thus reducing the risk of servers. This option is only used in standalone mode. The inetd mode is specified in inetd. conf.

The user who runs Apache. Because the server must perform the setuid () operation to change the identity, the initial process should have the root permission.

If you start aapche, this configuration will not work.

 

 

6. Switch to the bin directory of Apache.

[admin@test208003 bin]$ ./apachectl -k start

Install PHP in Linux

1. decompress the package and enter the Directory, which is the same as Apache

2. Run

[admin@test208003 php-5.2.14]$ ./configure --prefix=/home/admin/php--with-apxs2=/home/admin/apache/bin/apxs  --with-config-file-path=/home/admin/php/lib

3. Run make and make install, same as Apache,

Copy PHP. ini-recommended to the lib directory of PHP and change it to PhP. ini.

Modify the Apache configuration file and add addtype application/X-httpd-PHP. php

4. Install the independent extension in PHP. Take the curl extension as an example. Download the curl package and decompress it for installation.

[admin@test208003 curl-7.13.0]$ ./configure --prefix=/home/admin/curl[admin@test208003 curl-7.13.0]$ make[admin@test208003 curl-7.13.0]$ make install

Note that the GCC:/usr/lib/libidn. So: no such file or directory error may be reported during make:

Method 1: Execute ln-S/usr/lib64/libidn. so.11.4.6/usr/lib/libidn. So

Be sure to pay attention to the version number and lib directory of your libidn, which are related to the number of machine digits. The tested machine here is 64, so choose lib64.

Method 2:./configure -- prefix =/home/admin/curl -- With-libidn =/usr/lib64: Specify the path and run autoreconf.

Method 3:./configure ldflags =-L/usr/lib64 (specify an environment variable, which is to tell GCC where to find the. So file)

Compile and generate extensions to go To the PHP source code directory.

[admin@test208003 php-5.2.14]$ cd ext/[admin@test208003 ext]$ cd curl/[admin@test208003 curl]$ /home/admin/php/bin/phpize[admin@test208003 curl]$./configure --with-curl=/home/admin/curl        --with-php-config=/home/admin/php/bin/php-config[admin@test208003 curl]$make[admin@test208003 curl]$ make installInstalling shared extensions:     /home/admin/php/lib/php/extensions/no-debug-zts-20060613/[admin@test208003 curl]$ cd /home/admin/php/lib/php/extensions/no-debug-zts-20060613/[admin@test208003 no-debug-zts-20060613]$ ls  curl.so[admin@test208003 no-debug-zts-20060613]$

You can see curl. so has been generated, in PHP. INI, set the extension Directory: extension_dir =/home/admin/PHP/lib/PHP/extensions/no-debug-zts-20060613/"and add extension module reference: Extension = curl. so restart Apache.

5. Install the MySQL extension of PdO to go To the PHP source code directory.

[admin@test208003 php-5.2.14]$ cd ext/[admin@test208003 ext]$ cd pdo_mysql/[admin@test208003 pdo_mysql]$ /home/admin/php/bin/phpize[admin@test208003 pdo_mysql]$ ./configure --with-php-config=/home/admin/php/bin/php-config[admin@test208003 pdo_mysql]$ make[admin@test208003 pdo_mysql]$ make install

Modify PHP. ini and add extension = pdo_mysql.so. Restart Apache.

6.PHP installs MySQL, curl, and PdO extensions at one time. You only need to modify the configure parameter in a simpler way.

./configure --prefix=/home/admin/php --with-apxs2=/home/admin/apache/bin/apxs --with-config-file-path=/home/admin/php/lib --with-mysql=/home/admin/mysql --with-pdo-mysql=/home/admin/mysql --with-curl=/home/admin/curl --enable-mbstring

The premise for this configuration is that the MySQL database and curl have been installed.

Install MySql in Linux

1. decompress the MySQL source code package mysql-5.1.50.tar.gz and switch to the installation directory.

./configure --prefix=/home/admin/mysql --sysconfdir=/home/admin/mysql --localstatedir=/home/admin/mysql/data--with-unix-socket-path=/home/admin/mysql/tmp/mysql.sock --with-charset=gbk --with-plugins=innobase --with-client-ldflags=-all-static--with-mysqld-ldflags=-all-static

Sysconfdir indicates the path of the MySQL configuration file, localstatedir indicates the path of the data file, and socket configuration and the last two attributes are mainly used to improve performance.

If you want to use the InnoDB engine, add -- With-plugins = Innobase.

 make
 make install

2. Copy/home/admin/MySQL/share/MySQL/my-medium.cnf to the MySQL root directory and rename it my. CNF

Switch to the bin directory of MySQL and run

./mysql_install_db --basedir=/home/admin/mysql --datadir=/home/admin/mysql/data

3. Copy/home/admin/MySQL/libexec/mysqld to the bin directory of MySQL and start the MySQL service.

/home/admin/mysql/bin/mysqld_safe --ledir=/home/admin/mysql/bin --log-error=/home/admin/mysql/data/t.err --datadir=/home/admin/mysql/data --socket=/home/admin/mysql/tmp/mysql.sock --pid-file=/home/admin/mysql/data/mysqld.pid &

Run the ps command to check whether MySQL is started. If MySQL cannot be started, run the netstat command to check whether port 3306 is occupied. If yes, modify the port configuration of my. CNF.

Switch to the bin directory of MySQL and run./mysqladmin-u Root Password '000000' to change the root login password.

Modify/home/admin/MySQL/share/MySQL. server code

pid_file=/home/admin/mysql/data/mysqld.pid

Stop MySQL Service

/home/admin/mysql/share/mysql/mysql.server stop

For convenience, you can write commands for starting and stopping MySQL services as shell scripts.

We recommend that you add SQL-mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution" to my. CNF"

There are too many artificial intelligence algorithms written by the peach blossoms when there are too many artificial intelligence.

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.