LAMP mysql + php

Source: Internet
Author: User
Tags zts
Mysql + php LAMP followed by: http://wskfnso.blog.51cto.com/4025557/1761877

II. install mariadb10.0.24

1. install mariadb, obtain the source program, decompress the package, and create a soft connection.

[Root @ master1 ~] # Tar mariadb-10.0.24-linux-x86_64.tar.gz-C/usr/local/

[Root @ master1 ~] # Cd/usr/local/

[Root @ master1 local] # ln-sv mariadb-10.0.24-linux-x86_64 mysql
'Mysql'-> 'mariadb-10.0.24-linux-x86_64'

2: Create mysql system users and groups

[Root @ master1 local] # groupadd-r mysql
[Root @ master1 local] # useradd-r-g mysql-s/sbin/nologin

3: Create a data directory to store data, and change the data directory to mysql Users and Groups.

[Root @ master1 local] # mkdir-pv/mydata/data
[Root @ master1 local] # chown-R mysql. mysql/mydata/data/

4. install the database

[Root @ master1 mysql] # scripts/mysql_install_db -- datadir =/mydata/data/-- user = mysql -- basedir =/usr/local/mysql/

5. provide the configuration file for mysql and modify the file as follows:

[Root @ master1 mysql] # cp support-files/my-large.cnf/etc/my. cnf

Thread_concurrency = 2 // change to twice the cpu

Basedir =/usr/local/mysql // database installation directory
Datadir =/mydata/data // data Directory
Innodb_file_per_table = on // open the innodb engine
Skip_name_resolve = on // skip DNS resolution

6. provide the startup script and enable it to start automatically.

[Root @ master1 mysql] # cp support-files/mysql. server/etc/rc. d/init. d/mysqld

[Root @ master1 mysql] # chkconfig -- add mysqld

[Root @ master1 mysql] # chkconfig -- list mysqld
Mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off

7. start mysql

[Root @ master1 mysql] # service mysqld start

8. modify the header file and library file.

(1): output the mysql header file to the system header file path/usr/include:

# Ln-sv/usr/local/mysql/include/usr/include/mysql

(2): output the mysql database file to the system database search path:

# Echo '/usr/local/mysql/lib'>/etc/ld. so. conf. d/mysql. conf

Then let the system reload the system database:

# Ldconfig

# Ldconfig-p | grep 'mysql'

(3): modify the PATH environment variable so that the system can directly use mysql-related commands.

Create the mysql. sh file in the/etc/profile. d/directory! Write the following content:

Export PATH =/usr/local/mysql/bin: $ PATH

# Source mysql. sh

# Touch/etc/profile. d/mysql. sh

# Echo "export PATH =/usr/local/mysql/bin: $ PATH">/etc/profile. d/mysql. sh

# Source mysql. sh

9: delete password User:

Mysql> drop user ''@ 'localhost ';

Query OK, 0 rows affected (0.00 sec)


Mysql> drop user ''@ 'localhost. localdomain ';

Query OK, 0 rows affected (0.00 sec)


Mysql> drop user 'root' @ 'localhost. localdomain ';

Query OK, 0 rows affected (0.00 sec)


Mysql> drop user 'root' @ ': 1 ';

Query OK, 0 rows affected (0.00 sec)


Mysql> set password for 'root' @ 'localhost' = password ('123 ');

Query OK, 0 rows affected (0.00 sec)


Mysql> set password for 'root' @ '192. 0.0.1 '= password ('20140901 ');

Query OK, 0 rows affected (0.00 sec)


3. install php5.6

Note:

-- Enable-maintainer-zts

(1): to support the apache worker or event MPM, use -- enable-maintainer-zts during compilation.

(2): If php5.3 or later is used, you can specify mysqlnd to connect to the mysql database, so that the local machine does not need to install MYSQL or MYSQL to start the package. Mysqlnd is available from php5.3 and can be bound to it during compilation. (Instead of relying on other specific databases ).

Php5.4 is the default setting.

#./Configure -- with-mysql = mysqlnd -- with-pdo-mysql = mysqld -- with-mysqli = mysqld


LAMP: important points:

Apache uses three methods to connect to PHP

(1) module mode: only libphp5.so modules are used when prefork processes are used. If it is working at work, the event thread is used as a libphp5-zts.so

(2) GGI

(3): FastCgi socket communication php-fpm


1: install php

[Root @ master1 ~] # Tar xf php-5.6.18.tar.gz
[Root @ master1 ~] # Cd php-5.6.18

[Root @ master1 php-5.6.18] #. /configure -- prefix =/usr/local/php -- with-mysql = mysqlnd -- with-pdo-mysql = mysqlnd -- with-mysqli = mysqlnd -- with-openssl -- enable-mbstring -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- enable-sockets -- with-apxs2 =/usr/local/httpd/bin/apxs -- with-mcrypt -- with-config-file-path =/etc -- with-config-file-scan-dir =/etc/ php. d -- with-bz2 -- enable-maintainer-zts

[Root @ master1 php-5.6.18] # make & make install


2: provide configuration files for php

[Root @ maid php-5.6.18] # cp php. ini-production/etc/php. ini

3: edit the apache configuration file httpd. conf. to support php

# Vim/etc/httpd. conf

Add the following content:

AddType application/x-httpd-php. php

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

4: Add index. php to DirectoryIndex index.html to support php


4. install xcache for php acceleration

1: install xcache

Root @ master1 ~] # Tar xf xcache-3.2.0.tar.gz

[Root @ master1 ~] # Cd xcache-3.2.0

[Root @ master1 xcache-3.2.0] #/usr/local/php/bin/phpize
Processing ING:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[Root @ master1 xcache-3.2.0] #./configure -- enable-xcache -- with-php-config =/usr/local/php/bin/php-config

[Root @ master1 xcache-3.2.0] # make & make install


At the end of installation, the following lines will appear:

Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20131226/


2: integrate xcache and php. first, import the sample configuration provided by xcache to php. ini.

# Mkdir/etc/php. d

# Cp xcache. ini/etc/php. d

Note: The xcache. ini file is in the xcache source code directory.


3: edit/etc/php. d/xcache. ini, find the line starting with zend_extension, and change it to the following line:

Extension =/usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache. so

Note: If the php. ini file contains multiple zend_extension command lines, make sure that the new lines are ranked first.

4: httpd restart and load the module

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.