In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following content mainly brings you the separation of php and MySQL to build LAMP testing and process. The knowledge mentioned here, which is slightly different from books, is summarized by professional and technical personnel in the process of contact with users, and has a certain value of experience sharing. I hope to bring help to the majority of readers.
Separate php and MySQL to build LAMP platform
Environment:
System: CentOS-7-x86_64-Minimal-1611
Apache:httpd-2.4.25.tar
MySQL:mysql-5.7.16.tar
Php:php-5.6.30.tar
192.168.57.144: install MySQL
192.168.57.143: install Apache+php
Create related directories
Create a user
Extract the installation package
Compilation and installation
(initialize)
Link bin directory
Copy script file, master configuration file
Configure the master profile
Script self-starting
Verification service
Verify the docking service
One compiler installs Apache
Yum install lrzsz
Cd / usr/local/
Tar-zxf httpd-2.4.25.tar.gz
Yum install gcc* gcc-c++*
Yum install apr* apr-util apr-devel pcre* pcre-devel openssl* openssl-devel-y
Compilation and installation
. / configure-prefix=/apps/svr/httpd-enable-so-enable-rewrite-enable-charset-list-enable-cgi
Or:
. / configure\
-- prefix=/apps/svr/httpd\
-- sysconfdir=/apps/conf/\
-- enable-so\
-- enable-ssl\
-- enable-cgi\
-- enable-rewrite\
-- with-zlib\
-- with-pcre\
-- with-mpm=prefork\
-- enable-modules=most\
-- enable-mpms-shared=all
Echo $?
Make
Make install
Configure http environment variables
Ln-s / apps/svr/httpd/bin/* / usr/local/bin/
Or: cat > export PATH=$PATH:/apps/svr/httpd/bin > > / etc/profile
Check the configuration file
Apachectl-t
Set apache to Linux service and realize boot self-startup
Cp / apps/svr/httpd/bin/apachectl / etc/init.d/httpd
Or: set Apache to Linux service and achieve boot self-startup
Mv / etc/rc.d/init.d/apachectl / etc/rc.d/init.d/httpd
Chmod + x / etc/init.d/httpd
Vim / etc/init.d/httpd
#! / bin/sh
# chkconfig:2345 80 80
# description:httpd
#
Chkconfig:2345 80 80
2345: is the service identification parameter, started at level 2345
The first 80: the service starts at the 80th.
The second 80: the service is shut down at the 80th
Description:httpd: service description information
Chkconfig-add httpd
Chkconfig httpd on
Chkconfig-list httpd
Cat / etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.57.141 www.a.org
Cat / apps/svr/httpd/conf/httpd.conf
# ServerName www.example.com:80
ServerName www.a.org
Service httpd restart
Netstat-anpt | grep httpd
Shut down the database
Systemctl stop firewalld
Http://xsboke.blog.51cto.com/12096269/1922949
Compile and install mysql-5.7.16
Groupadd-r mysql
Useradd-r-g mysql-s / bin/false-M mysql
Create mysql installation files, database storage files, my.cnf files
Mkdir-p / apps/svr/mysql
Mkdir-p / apps/mysqldb/data
Mkdir-p / apps/conf
Yum install-y gcc wget make cmake zlib-devel ncurses-devel bison gcc-c++ automake autoconf imake libxml2-devel expat-devel cmake gcc gcc-c++ libaio libaio-devel bzr bison libtool ncurses-devel libxml2-devel expat-devel openssl openssl-devel
Download Boost_1_59_0.tar.gz
Wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
Wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
Tar zxvf boost_1_59_0.tar.gz
Download mysql-5.7.13.tar.gz
Wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.13.tar.gz
Wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17.tar.gz
Tar zxvf mysql-5.7.17.tar.gz
Cd mysql-5.7.17
Cmake. -DCMAKE_INSTALL_PREFIX=/apps/svr/mysql\
-DMYSQL_DATADIR=/apps/mysqldb/data\
-DSYSCONFDIR=/apps/conf/my.cnf\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_ARCHIVE_STORAGE_ENGINE=1\
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\
-DWITH_READLINE=1\
-DWITH_LIBWRAP=0\
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock\
-DWITH_SSL=system\
-DWITH_ZLIB=system\
-DDOWNLOAD_BOOST=1\
-DWITH_BOOST=../boost_1_59_0\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci
Decompress boost_1_59_0 and put it in the upper directory of mysql
-
-DCMAKE_INSTALL_PREFIX= installation root directory
-DCMAKE_INSTALL_PREFIX= unix socket directory
-DDEFAULT_CHARSET= default character set
-DDEFAULT_COLLATION= default encoding
-DWITH_EXTRA_CHARSETS= extra coding, please use ALL to compile.
-DWITH_MYISAM_STORAGE_ENGINE=1 compiles myisam storage engine. Default storage engine can be added without adding it.
-DWITH_INNOBASE_STORAGE_ENGINE=1 supports the InnoDB storage engine, which is also installed by default
-DWITH_READLINE=1 uses the readline function
-DENABLED_LOCAL_INFILE=1 can import files locally using the load data infile command
-DMYSQL_DATADIR= database data directory
-
Number of grep processor / proc/cpuinfo x2
Make or: make-j $(grep processor / proc/cpuinfo | wc-l)
Make install
Cat > export PATH=$PATH:/apps/svr/mysql/bin > > / etc/profile
Source / etc/profile
Or: ln-s / apps/svr/mysql/bin / usr/local/bin
Chown-R mysql:mysql / apps/svr/mysql
Chown-R mysql:mysql / apps/conf
Chown-R mysql:mysql / apps/mysqldb
Rm-rf / etc/my.cnf
Export Profil
Cd mysql-5.7.16
Cp support-files/my-default.cnf / apps/conf/my.cnf
Cp support-files/my-default.cnf / etc/
Initialize the database
Note:
Prior to 1, mysql_install_db is under mysql_basedir/script, 5.7under the mysql_install_db/bin directory, and has been abandoned.
2 "--initialize" generates a random password (~ / .mysql_secret), while "--initialize-insecure" does not generate a password.
3-data files cannot be found in the datadir target directory
/ apps/svr/mysql/bin/mysqld-initialize-user=mysql-basedir=/apps/svr/mysql/-datadir=/apps/mysqldb/data/
Initialize password
# root@localhost: Ml-&jsWy (7j)
Configure mysql to start automatically
Cp / apps/svr/mysql/usr/lib/systemd/system/mysqld.service / usr/lib/systemd/system
Systemctl enable mysqld.service
Or
Cp / apps/svr/mysql/support-files/mysql.server / etc/init.d/mysqld
Chmod + x / etc/init.d/mysqld
Chkconfig-add mysqld
Chkconfig mysqld on
* Mysqld.pid files allow mysql users to access them.
Vi / usr/lib/systemd/system/mysqld.service
Change to: PIDFile=/apps/svr/mysql/mysqld.pid
# Start main service
ExecStart=/apps/svr/mysql/bin/mysqld--daemonize--pid-file=/apps/conf/mysql5.7/mysqld.pid $MYSQLD_OPTS
Dbrootpwd=oneinstack # Database root password
/ usr/local/mysql/bin/mysql-e "grant all privileges on *. * to root@'127.0.0.1' identified by\" $dbrootpwd\ "with grant option;"
/ usr/local/mysql/bin/mysql-e "grant all privileges on *. * to root@'localhost' identified by\" $dbrootpwd\ "with grant option;"
Change mysql login root user password
Mysqladmin-u root-p'Ml-&jsWy (7j) 'password' 2Zs63oQbPxpKYFjn6tyj'
Create users to allow 143remote (allow php links)
Grant all on *. * to root@192.168.57.143 identified by '123456'
Flush privileges
Show grants for root@192.168.57.143
Select user,host from mysql.user
Install extension tools such as data encryption (such as libmcrypt, mhash, mcrypt)
Note: these three packages mcrypt will be installed at last.
Yum install libxml2 libxml2-devel bzip2-devel libcurl-devel-y
Yum install php-mcrypt libmcrypt libmcrypt-devel mhash mhash-devel libevent libevent-devel
. / configure-- prefix=/apps/svr/php/\
-- with-openssl\
-- enable-mbstring\
-- with-freetype-dir\
-- with-jpeg-dir\
-- with-png-dir\
-- with-mysql\
-- with-zlib\
-- enable-xml\
-- enable-sockets\
-- with-apxs2=/apps/svr/httpd/bin/apxs\
-- with-config-file-path=/apps/conf\
-- with-bz2\
-- enable-maintainer-zts
Make
Make install
#-with-config-file-scan-dir=/apps/conf\
#-with-libxml-dir=/usr\
#-with-mysqli=/usr/local/mysql/bin/mysql_config\
#-add mysql module to with-mysql
#-with-apxs2=/usr/local/apache24/bin/apxs means to compile into a module
#-- enable-fpm compiled into fastCGI
#-No option is required for enable-maintainer-zts to compile fastCGI
Configuration php.ini file: under the unzipped installation package
Cp php.ini-development / apps/conf/php.ini
Set the configuration file path-- with-config-file-path=/apps/conf\
Short_open_tag = On
Asp_tags = On
* parsing
Short_open_tag
Determines whether the abbreviated form of the PHP code start flag is allowed (). If you want to use PHP with XML, you can disable this option to facilitate embedding. Otherwise, you can also output through PHP, for example:. If disabled, you must use the PHP code to start with the end of the logo.
Note: this directive also affects the use of ASP-style flags in addition to the abbreviated form flags. This also includes an abbreviation for the value of the output variable.
Note: ASP style logo support is new to version 3.0.4.
Integrate apache and php
Compile the Apache configuration file httpd.conf to support php with Apache. And the visited main page index.php
Vim / apps/conf/httpd.conf
Add a home page that supports php
DirectoryIndex index.php index.html
Load php program module file
LoadModule php5_module modules/libphp5.so
Add the following two lines of apache to recognize the php format page
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Check the configuration file for syntax errors
Httpd-t
Syntax OK
Restart the service
Service httpd restart
Test whether PHP and Apache are connected properly
Cd / apps/svr/httpd/htdocs/
Vim index.php
Integrate php and mysql
Since mysql and php are not on the same CVM, add the extension module of php
1. Install mysql-devel on the Apache+php server
Yum install mysql-devel-y
2. Enter the php decompression package to generate configuration file
Cd / root/php-5.6.30/ext/mysql
Execute phpize script to generate configure file
[root@client mysql] # pwd
/ root/php-5.6.30/ext/mysql
[root@client mysql] # / apps/svr/php/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
Unable to find autoconf. Please check your autoconf installation and
$PHP_AUTOCONF environment variable. Then, rerun the script.
(* error missing M4 autoconf package *)
Yum install m4
Yum install autoconf
3. Configure compilation and installation (generate a mysql.so module file under the extension block path after the installation is completed)
. / configure-with-mysql-with-php-config=/apps/svr/php/bin/php-config
-- with-mysql adds mysql module
-- the script location required for with-php-config=/apps/svr/php/bin/php-config to add a module
Make
Make install
4. Add mysql.so module to php.ini configuration file (/ apps/conf/php.ini)
[root@client htdocs] # cat / apps/conf/php.ini | grep mysql.so
Extension=/apps/svr/php/lib/php/extensions/no-debug-zts-20131226/mysql.so
Test whether PHP connects properly with MySQL (default root user login does not require a password)
Vim index.php
For the above about the separation of php and MySQL to build LAMP testing and process, if you need to know more, you can continue to pay attention to the innovation of our industry. If you need professional solutions, you can contact the pre-sales and after-sales on the official website. I hope this article can bring you some knowledge updates.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.