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

How to compile php-fpm module and combine it with apache2.4

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly shows you "how to compile php-fpm module and apache2.4 combination", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to compile php-fpm module and apache2.4 combination" this article.

Prepare 3 virtual machines, configure hostname and IP address, turn off firewall and selinux

Nfs startup sequence: start rpc- first > start nfs first

Nfs permission parameters

Rw: read and write

Ro: read-only

Sync: synchronous mode in which data in memory is written to disk from time to time

Async: write data in memory to disk periodically without synchronization

No_root_squash: with this option added, root users will have the highest permissions on shared directories, just as they do on local directories. Not safe, not recommended

Root_squash: when root is accessed through the network, it is changed to nfsnobody user, that is, the permission of root is restricted.

All_squash: no matter who uses NFS, his identity will be limited to nfsnobody.

Anonuid/anongid: to be used with root_squash and all_squash to specify the qualified uid and gid of the user using NFS, provided that this uid and gid exist in both the server and the client / etc/passwd

Shared file permissions are: the intersection of service permissions and file system permissions

Install and configure nfs services

[root@nfs ~] # mkdir-p / data/ {mydata,www} # is web Mysql creates a shared directory [root@nfs ~] # ls / data/mydata www [root@nfs ~] # groupadd-g 110 apache [root@nfs ~] # useradd-u 110-M-s / sbin/nologin apache [root@nfs ~] # chmod 777 / data/www/ [root@nfs ~] # groupadd-g 111 msyql [root@nfs ~] # useradd-u 111-M-s / sbin/nologin mysql [root@nfs ~] # chmod 777 / data/mydata/ [root@nfs ~] # yum Groupinstall-y "NFS file server" [root@nfs ~] # vi / etc/exports/data/www 192.168.0.11 (rw Root_squash) / data/mydata 192.168.0.20 (rw No_root_squash) [root@nfs ~] # service rpcbind restartStopping rpcbind: [OK] Starting rpcbind: [OK] [root@nfs ~] # service nfs startStarting NFS quotas: [OK] Starting NFS mountd: [OK] Starting NFS daemon: [OK] Starting RPC idmapd: [OK]

Install and configure mysql

[root@mysql ~] # mkdir-p / data/mydata [root@mysql ~] # showmount-e 192.168.0.30Export list for 192.168.0.30:/data/mydata 192.168.0.20/data/www 192.168.0.11 [root@mysql ~] # mount-t nfs 192.168.0.30:/data/mydata / data/mydata/ [root@mysql ~] # cd / data/mydata/ [root@mysql mydata] # lltotal 0 [root@mysql mydata] # touch aa [root@mysql mydata] # lltotal 0 root root Rafael-1 root root 0 Sep 29 22:23 aa [root@mysql mydata] # cd ~ [root@mysql ~] # groupadd-g 111msyql [root@mysql ~] # useradd-u 111-M-s / sbin/nologin mysql # create a mysql account [root@mysql ~] # chown-R mysql:mysql / data/mydata [root@mysql ~] # tar-xf mariadb-5.5.36-linux-x86_64.tar .gz-C / usr/local/ [root@mysql ~] # cd / usr/local [root@mysql local] # chown-R mysql:mysql mariadb-5.5.36-linux-x86_64/ [root @ mysql local] # ln-sv mariadb-5.5.36-linux-x86_64/ mysql [root@mysql mysql] # cd mysql [root@mysql mysql] # scripts/mysql_install_db-datadir=/data/mydata/-user=mysql [root@mysql mysql] # mkdir / etc/mysql [root@mysql mysql] # cp support-files/my-large.cnf / etc/mysql/my.cnf [root@mysql mysql] # vi / etc/mysql/my.cnf # add the following [mysqld]... datadir = / data/mydatainnodb_file_per_table = onskip_name_resolve = on [root@mysql mysql] # cp support-files/mysql.server / etc/rc.d/init.d/mysqld [root@mysql mysql] # ln-sv / usr/local/mysql under mysqld / include/ usr/include/mysql [root@mysql mysql] # echo'/usr/local/mysql/lib' > / etc/ld.so.conf.d/mysql.conf [root@mysql mysql] # ldconfig [root@mysql mysql] # chkconfig-- add mysqld [root@mysql mysql] # service mysqld start [root@mysql mysql] # bin/mysql_secure_installation # Database Security initialization Set root password, permissions and delete anonymous user [root@mysql mysql] # / usr/local/mysql/bin/mysql-uroot-p # verify whether you can log in to Enter password: Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 3Server version: 5.5.36-MariaDB-log MariaDB ServerCopyright (c) 2000, 2014, Oracle, Monty Program Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] > show databases +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | +-+ 3 rows in set (0.03 sec) MariaDB [(none)] > grant all on *. * to test@ "192.168.%.%" identified by 'chinoe-147' # # you can see MySQL metadata [root@nfs ~] # cd / data/mydata/ [root@nfs mydata] # lsaria_log.00000001 aria_log_control ibdata1 ib_logfile0 ib_logfile1 mysql mysql-bin.000001 mysql-bin.000002 mysql-bin.000003 mysql-bin.index mysql.pid performance_schema on the nfs server

Install and configure apache+php-fpm

Apache depends on packages apr-util-1.5.3.tar.bz2, apr-1.5.0.tar.bz2, pcre-devel

[root@httpd ~] # groupadd-g 110 apache [root@httpd ~] # useradd-u 110-M-s / sbin/nologin apache [root@httpd ~] # yum install-y pcre-devel [root@httpd ~] # tar-xf apr-1.5.0.tar.bz2 [root@httpd ~] # cd apr-1.5.0 [root@httpd apr-1.5.0] #. / configure-prefix=/usr/local/apr [root@httpd apr-1.5.0 ] # make & & make install [root@httpd apr-1.5.0] # cd. [root@httpd ~] # tar-xf apr-util-1.5.3.tar.bz2 [root@httpd ~] # cd apr-util-1.5.3 [root@httpd apr-util-1.5.3] #. / configure-- prefix=/usr/local/apr-util-- with-apr=/usr/local/apr [root@httpd apr-util-1.5.3] # make & & makeinstall [root@httpd apr-util-1.5.3] # cd. [root@httpd ~] # tar-xvf httpd-2.4.10.tar.bz2 [root@httpd ~] # cd httpd-2.4.10 [root@httpd httpd-2.4.10] #. / configure--prefix=/usr/local/apache-- sysconfdir=/etc/httpd-- enable-so-- enable-ssl--enable-cgi-- 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-- with-mpm=event [root@httpd httpd-2.4.10] # make & & make install### then you need to write your own httpd service startup script I am here to directly modify the rpm installation httpd script #! / 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/apachectl # modified to related path httpd=$ {HTTPD-/usr/local/apache/bin/httpd} # modified to related path prog=httpdpidfile=$ {PIDFILE-/var/run/httpd.pid} # modified to related path lockfile=$ {LOCKFILE-/var/lock/subsys/httpd} # modified to related path 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 | fullstatus | graceful | help | configtest}" exit 1esacexit $RETVAL [root@httpd ~] # chmod + x / etc/init.d/httpd [root@httpd ~] # chkconfig-add httpd [root@httpd ~] # vi / etc/profile.d/httpd.sh export PATH=/usr/local/apache/bin:$PATH [root@httpd ~] #. / etc/profile.d/httpd.sh # reread the configuration file compilation and installation apache must refer to before the service starts Specify the pid file path to add the pid file ServerRoot "/ usr/local/apache" PidFile "/ var/run/httpd.pid" to the global configuration of / etc/httpd/httpd.conf must be the same as the pidfile path in the service startup script httpd [root@httpd ~] # service httpd start [root@httpd ~] # curl-I 127.0.0.1HTTP/1.1 200 OKDate: Tue 29 Sep 2015 12:57:18 GMTServer: Apache/2.4.10 (Unix) Last-Modified: Mon, 11 Jun 2007 18:53:14 GMTETag: "2d-432a5e4a73a80" Accept-Ranges: bytesContent-Length: 45Content-Type: text/html#apache has been installed The test is normal

Php-fpm combines with apache as an independent module

Dependency package: bzip2-devel libmcrypt-devel libxml2-devel php-mysql

When mysql and php are not on the same physical machine, you also need to install mysql-devel package and mysql-libs package.

[root@httpd ~] # mkdir / etc/php5 { .d} [root@httpd ~] # mkdir / usr/local/php5 [root@httpd ~] # yum-y groupinstall "Desktop Platform Development" [root@httpd ~] # yum-y install bzip2-devel libmcrypt-devel libxml2-devel php-mysql [root@httpd ~] # yum install-y mysql-devel mysql-libs [root@httpd] # tar-xf php-5.5.29.tar.xz [root@httpd ~] # cd php-5.5.29 [root@httpd php-5.5. 29] # / configure-- prefix=/usr/local/php5/-- with-mysql-- with-openssl-- with-mysqli-- 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/php5/-- with-config-file-scan- Dir=/etc/php5.d-- with-bz2 [root@httpd php-5.5.29] # make-j 4 & & make install [root@httpd php-5.5.29] # cp php.ini-production / etc/php5/php.ini [root@httpd php-5.5.29] # cp sapi/fpm/init.d.php-fpm / etc/rc.d/init.d/php-fpm [root@httpd php-5.5.29] # chmod + x / etc/rc.d / init.d/php-fpm [root@httpd php-5.5.29] # chkconfig-- add php-fpm [root@httpd php-5.5.29] # cp / usr/local/php5/etc/php-fpm.conf.default / usr/local/php5/etc/php-fpm.conf### modify php-fpm parameter [root@httpd php-5.5.29] # vim / usr/local/php5/etc/php-fpm.confuser = apachegroup = apachelisten = 0.0.0 Under the pm = dynamic module, modify the parameter pm.max_children = 50pm.start_servers = 5pm.min_spare_servers = 2pm.max_spare_servers = 8pid = / usr/local/php5/var/run/php-fpm.pid [root@httpd php-5.5.29] # service php-fpm start [root@httpd php-5.5.29] # ss-tanlp | grep 9000LISTEN 0 128 127.0.0.1 *: * users: ("php-fpm" ("php-fpm", 114599), ("php-fpm", 114600), ("php-fpm", 114601), ("php-fpm", 114602), ("php-fpm", 114603)) [root@httpd php-5.5.29] # vi / etc/httpd/httpd.conf User apache # modify the process user Group apache # # comment out the center host Use virtual host # DocumentRoot "/ usr/local/apache/htdocs" # Options Indexes FollowSymLinks# AllowOverride None# Require all granted# to add LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so under related LoadModule, add AddType application/x-httpd-php .php under AddType to find DirectoryIndex index.html and modify it to: add virtual host servername www.test.com at the end of DirectoryIndex index.php index.html# Documentroot / data/www ProxyRequests Off ProxyPassMatch ^ / (. *\ .php) $fcgi://127.0.0.1:9000/data/www/$1 options none allowoverride none require all granted [root@httpd ~] # mkdir-p / data/www [root@httpd ~] # mount-t nfs 192.168.0.30:/data/www / data/www/ [root@httpd ~] # vi index.php

[root@httpd ~] # vi index.php # Test Database

Then test whether the database can be linked.

Already success

The above is all the content of the article "how to compile php-fpm module and combine apache2.4". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report