In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Introduction to compilation and installation
In the work, based on a variety of production environments, yum installation may not meet our needs. At this time, we have to compile and install the package ourselves. Of course, as long as we master the skills, the compilation and installation is also very simple. This article will introduce how to compile and install under CentOS 6.7system: httpd-2.4.6 + php-5.6.4 + xcache-3.2.0 + mariadb-5.5.43, and build a Wordpress and phpMyAdmin based on LAMP environment after compilation.
two。 Compile and install 2.1 mariadb-5.5.43
Prepare the file system for data storage
Create a new logical volume and mount it to a specific directory, and the general database should be stored in a separate file system.
[root@ch ~] # mkdir / data/mydata/-pv # # create a directory for storing databases
The new user runs the process in a secure manner
[root@ch ~] # groupadd-r mysql # # New mysql Group [root@ch ~] # useradd-g mysql-r-s / sbin/nologin-M-d / data/mydata/ mysql # # New mysql system user [root@ch] # chown-R mysql.mysql / data/mydata/ # # modify the owner and group of the directory to mysql
Install and initialize mysql-5.5.43
Download the corresponding mysql version locally. Official download site: https://mariadb.org/download/. Here is 64 platform, so the corresponding version is mariadb-5.5.43-linux-x86_64.tar.gz.
Note that this is a binary version.
[root@ch ~] # tar xf mariadb-5.5.43-linux-x86_64.tar.gz-C / usr/local/ # # perform decompression [root@ch ~] # cd / usr/local/ [root@ch local] # ln-s mariadb-5.5.43-linux-x86_64 mysql # # create a symbolic link [root@ch local] # cd mysql/ [root@ch mysql] # chown-R mysql.mysql. # # modify all file owners and groups in mysql directory are mysql [root@ch mysql] # scripts/mysql_install_db-- user=mysql-- datadir=/data/mydata # # perform database initialization [root@ch mysql] # cp support-files/my-large.cnf / etc/my.cnf # # provide configuration file [root@ch mysql] # vim / etc/my.cnf # # edit configuration file thread for mysql _ concurrency = 2 # # here is the number of CPU * 2datadir = / data/mydata # # add rows to specify the location where mysql data is stored
Provide sysv service scripts for mysql
[root@ch mysql] # cp support-files/mysql.server / etc/rc.d/init.d/mysqld [root@ch mysql] # chmod + x / etc/rc.d/init.d/mysqld [root@ch mysql] # chkconfig-- add mysqld # # add to the service list [root@ch mysql] # chkconfig mysql on # # set boot
Start and configure the database [root@ch mysql] # service mysqld start # # start the service [root@ch mysql] # ss-tan # # see if 3306 is listening [root@ch mysql] # export PATH=/usr/local/mysql/bin/:/$PATH [root@ch mysql] # vim / etc/profile.d/mysql.sh # # modify the PATH environment variable Let the system directly use the mysql command export PATH=/usr/local/mysql/bin/:/$PATH [root@ch mysql] # vim / etc/man.config # # to output the man manual of mysql to the lookup path of the man command MANPATH / usr/local/mysql/man [root@ch mysql] # ln-sv / usr/local/mysql/include / usr/include/mysql # # output the header file of mysql to the system header file path / usr/include [root@ Ch mysql] # echo'/ usr/local/mysql/lib' > / etc/ld.so.conf.d/mysql.conf # # output the library file of mysql to find the path to the system library [root@ch mysql] # ldconfig # # Let the system reload the system library [root@ch mysql] # mysqladmin-uroot password '123.com' # # modify the database root user password [root@ch mysql] # mysql-uroot-pendant 123.com' # # Log in to the database MariaDB [(none)] > create database wp_DB # # create database MariaDB [(none)] > grant all on wp_DB.* to 'chen'@'172.18.20.%' identified by' 123.compose; # # authorize users to log in to database 2.2 httpd-2.4.6
Versions above httpd-2.4 require newer versions of apr and apr-util, so they need to be upgraded in advance. There are two ways to upgrade, one is to compile and install through the source code, and the other is to upgrade the rpm package directly. Here is a full demonstration through source code compilation and installation. Official download address: http://httpd.apache.org/
Compile and install apr-1.5.0 [root@ch tmp] # tar xf apr-1.5.0.tar.bz2 [root@ch tmp] # cd apr-1.5.0 [root@ch apr-1.5.0] #. / configure-- prefix=/usr/local/apr [root@ch apr-1.5.0] # make-j 4 & & make install
Compile and install apr-util-1.5.2 [root@ch tmp] # tar xf apr-util-1.5.2.tar.bz2 [root@ch tmp] # cd apr-util-1.5.2 [root@ch apr-util-1.5.2] #. / configure-- prefix=/usr/local/apr-util-- with-apr=/usr/local/apr [root@ch apr-util-1.5.2] # make-j 4 & & make install
Compile and install http-2.4.6 [root@ch httpd-2.4.6] # yum-y install pcre-devel [root@ch tmp] # tar xf httpd-2.4.6.tar.bz2 [root@ch tmp] # cd httpd-2.4.6 [root@ch httpd-2.4.6] #. / configure-- prefix=/usr/local/apache-- sysconfdir=/etc/httpd-- enable-so-- enable-ssl-- enable-fcgi-- enable-rewrite- -with-zlib-- with-pcre-- with-apr=/usr/local/apr-- with-apr-util=/usr/local/apr-util-- enable-modules=most-- enable-mpms-shared=all-- enable-mpm=worker [root@ch httpd-2.4.6] # make-j 4 & & make install
-enable-so supports dynamic module mechanism
-enable-ssl supports ssl function
-enable-fcgi-enable-rewrite supports fcgi and url rewriting
-enable-modules=all enables most common modules
-enable-mpms-shared=all compiles 3 modules of prefork/worker/event
-with-mpm-worker sets the default module to worker
-with-zlib supports compression
-with-pcre 's regular expression engine that supports pre extensions
Modify the main configuration file of httpd and set the path to its Pid file [root@ch tmp] # vim / etc/httpd/httpd.confPidFile "/ var/run/httpd.pid" # # add this line to the configuration file to LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so # # enable the fcgi module
Provide SysV service script [root@ch tmp] # vim / etc/rc.d/init.d/httpd # # content as follows: #! / bin/bash## httpd Startup script for the Apache HTTP Server## chkconfig:-85 description: Apache is a World Wide Web server. It is used to serve\ # HTML files and CGI.# processname: httpd# config: / etc/httpd/conf/httpd.conf# config: / etc/sysconfig/httpd# pidfile: / var/run/httpd.pid# Source function library.. / etc/rc.d/init.d/functionsif [- f / etc/sysconfig/httpd]; then. / etc/sysconfig/httpdfi# Start httpd in the C locale by default.HTTPD_LANG=$ {HTTPD_LANG- "C"} # This will prevent initlog from swallowing up a pass-phrase prompt if# mod_ssl needs a pass-phrase from the user.INITLOG_ARGS= "# Set HTTPD=/usr/sbin/httpd.worker in/ etc/sysconfig/httpd to use a server# with the thread-based" worker "MPM; BE WARNED that some modules may not# work correctly with a thread-based MPM Notably PHP will refuse to start.# Path to the apachectl script, server binary, and short-form for messages.apachectl=/usr/local/apache/bin/apachectlhttpd=$ {HTTPD-/usr/local/apache/bin/httpd} prog=httpdpidfile=$ {PIDFILE-/var/run/httpd.pid} lockfile=$ {LOCKFILE-/var/lock/subsys/httpd} RETVAL=0start () {echo-n $"Starting $prog:" LANG=$HTTPD_LANG daemon-- pidfile=$ {pidfile} $httpd $OPTIONS RETVAL=$? Echo [$RETVAL= 0] & & touch ${lockfile} return $RETVAL} stop () {echo-n $"Stopping $prog:" killproc-p ${pidfile}-d 10$ httpd RETVAL=$? Echo [$RETVAL = 0] & & rm-f ${lockfile} ${pidfile}} reload () {echo-n $"Reloading $prog:" if! LANG=$HTTPD_LANG $httpd $OPTIONS-t > & / dev/null; then RETVAL=$? Echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else killproc-p ${pidfile} $httpd-HUP RETVAL=$? Fi echo} # See how we were called.case "$1" in start) start;; stop) stop;; status) status-p ${pidfile} $httpd RETVAL=$?;; restart) stop start;; condrestart) if [- f ${pidfile}]; then stop start fi;; reload) reload; graceful | help | configtest | fullstatus) $apachectl $@ RETVAL=$?;; *) echo $"Usage: $prog {start | stop | restart condrestart | reload | status | graceful | help | help $configtest"
[root@ch tmp] # chmod + x / etc/rc.d/init.d/httpd # # Grant script execution permission [root@ch tmp] # chkconfig-- add httpd # # add to the service list [root@ch tmp] # service httpd start # # start the httpd service [root@ch tmp] # netstat-tan # # to see if port 80 is listening
As for library files, man documents, system commands and header files, you can still configure them in accordance with the compilation and installation of mariadb section 5.
Provide the server status page [root@ch httpd] # vim httpd.conf # # Edit the main configuration file SetHandler server-status Require ip 172.18.20.1 # # only allow 172.18.20.1 hosts to view
2.3 php-5.6.4
Resolve dependencies [root@ch tmp] # yum-y groupinstall "X Software Development"
If you want the compiled php to support mcrypt extensions, you also need to install the
[root@ch tmp] # yum-y install libmcrypt libmcrypt-devel mhash mhash-devel bzip2-devel
Compile and install php-5.6.4 [root@ch tmp] # tar xf php-5.6.4.tar.xz [root@ch tmp] # cd php-5.6.4 [root@ch php-5.6.4] #. / 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-- enable-fpm-- with-mcrypt-- with-config-file-path=/etc-- with-config-file-scan-dir=/etc/php.d-- with-bz2 [root@ch php-5.6.4] # make-j 4 & & make install
If you are using a version above PHP5.3, you can specify mysqlnd in order to link to the MySQL database, so that you do not need to install MySQL or MySQL development packages on the machine first. Mysqlnd is available since php 5.3 and can be bound to it at compile time (without having to rely on specific MySQL client library bindings), but it has been the default since PHP 5.4.
Configure php-fpm [root@ch php-5.6.4] # cp sapi/fpm/init.d.php-fpm / etc/rc.d/init.d/php-fpm # # provide SysV init script for php-fpm [root@ch php-5.6.4] # chmod + x / etc/rc.d/init.d/php-fpm [root@ch php-5.6.4] # chkconfig-add php-fpm # # add to service [ Root@ch php-5.6.4] # chkconfig php-fpm on # # set self-boot [root@ch php-5.6.4] # cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf # # provide php-fpm configuration file [root@ch php-5.6.4] # vim / usr/local/php/etc/php-fpm.conf # # Edit the configuration file listen = 172.18.20.21 usr/local/php/var/run/php-fpm.pidpm.max_children 9000 # # the address that the service listens to listen.allowed_clients = 172.18.20.20 # # which client is allowed to forward requests in response to pid = / usr/local/php/var/run/php-fpm.pidpm.max_children = 5pm.start_servers = 1pm.max_spare_servers = 3 [root@ch php] # mkdir / var/lib/ Php/session [root@ch php] # chown apache:apache / var/lib/php/session # # create a session directory And make sure that the user running the php-fpm process has read and write access to this directory [root@ch php-5.6.4] # service php-fpm start # # start the service [root@ch php-5.6.4] # netstat-tanlp | grep php-fpm # # verify whether port 9000 is listening
Compile and install xcache, accelerate [root@ch tmp] # tar xf xcache-3.2.0.tar.bz2 [root@ch tmp] # cd xcache-3.2.0 [root@ch xcache-3.2.0] # / usr/local/php/bin/phpize [root@ch xcache-3.2.0] #. / configure-- enable-xcache-- with-php-config=/usr/local/php/bin/php-config [root@ch xcache-3.2.0] # make-j 4 & & make install for php
After the installation is complete, Installing shared extensions: / usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ appears
Edit php.ini and integrate php and xcache [root @ ch xcache-3.2.0] # mkdir / etc/php.d [root@ch xcache-3.2.0] # cp xcache.ini / etc/php.d/ [root@ch xcache-3.2.0] # vim / etc/php.d/xcache.ini zend_extension = / usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/xcache.so
3. Integration Test 3.1 configure http [root@ch ~] # vim / etc/httpd/httpd.conf User apacheGroup apache # # modify the generic group and generic group running httpd service to apacheAddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps # # so that apache can recognize the page in php format And support the home page AllowOverride none Require all granted # # in php format to allow everyone to access # DocumentRoot "/ usr/local/apache/htdocs" # # disable the central host DirectoryIndex index.html index.php # # add an item to add a virtual host DocumentRoot "/ www/ch2" ServerName www.ch.com ProxyRequests Off # # for index.php # # to close the forward agent ProxyPassMatch ^ / (. *\ .php) $fcgi://172.18.20.21:9000/www/ch3/$1 # # sends the file request ending in .php to the php-fpm server Options none AllowOverride none Require all granted [root@ch ~] # useradd-r-s / sbin/nologin apache # # New apache system user [root@ch ~] # mkdir-pv / www/ch2 # # Directory required to create a web page [root@ch ~] # vim / www/ch2/index.html # # create html page 172.18.20.20 # # Edit the test page [root@ch ~] # / usr/local/apache/bin/httpd-t # # check the configuration file [root@ch ~] # service httpd reload # # reload the configuration file
Access http://172.18.20.20/index.html with client browser to ensure that http works properly
3.2 configure php-fpm [root@ch ~] # mkdir-pv / www/ch3 # # directory required to create a website [root@ch ~] # vim / www/ch3/index.php # # create a php test page
Visit http://172.18.20.20/index.php with a browser to ensure that http+php is working properly, check phpinfo information to see xcache information, and ensure that there is no problem with xcache configuration and installation.
Edit the php test page to make sure there is no problem with php connecting to mysql
[root@ch fpm] # vim / www/ch3/index.php
Using a browser to access http://172.18.20.20/index.php and OK indicates that it is normal to connect to the database
4. Install the website program 4.1 install wordpress [root @ ch ~] # cd / www/ch3/ [root@ch ch3] # unzip wordpress-4.3.1-zh_ ch ch3 [root @ ch ch3] # chown-R apache:apache wordpress [root@ch ch3] # chmod-R Grouw wordpress [root@ch ch3] # ln-s wordpress wp
You need to do the same on the http host and the php-fpm host, or you can set up a nfs server based on file system sharing.
Access the database information correctly configured by http://172.18.20.20/wp
Configure site information
Then the wordpress installation is complete. 4.1 install phpMyAdmin [root @ ch ch3] # yum-y install php-common php-mbstring [root@ch tmp] # unzip phpMyAdmin-4.3.5-all-languages.zip [root@ch tmp] # chown-R apache:apache phpMyAdmin-4.3.5-all-languages [root@ch tmp] # chmod-R admin [root@ch tmp] # ln-s phpMyAdmin-4.3.5-all-languages php [root@ch php] # cp Config.sample.inc.php config.ini.php # # copy the configuration file of phpmyadmin [root@ch php] # vim config.inc.php # # Edit the configuration file $cfg ['Servers'] [$] [' host'] = '172.18.20.22' # # change this entry to the IP address of the mariadb database
This is also where both php-fpm and httpd hosts need to be configured.
Configure on the httpd host as follows:
DocumentRoot "/ www/ch3/php" ServerName www.ch.com ProxyRequests Off ProxyPassMatch ^ / (. *\ .php) $fcgi://172.18.20.21:9000/www/ch3/php/$1 Options FollowSymLinks AllowOverride none Require all granted
Open a client browser, access http://172.18.20:8080 login data, and the following interface appears
5. Problems encountered
Open phpmyadmin and find that the page of the website cannot display pictures.
If you click on any picture and the following picture appears, you can see that there is a problem with the html resource path.
Check the static page configuration and find that there is a problem with the path, and then OK.
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.