前期准备
[root@localhost ~]# hostname lamp
[root@localhost ~]# bash
[root@lamp ~]# cd /usr/local/src
[root@lamp src]# ls
apr-1.6.5.tar.gz httpd-2.4.46.tar.gz php-7.3.25.tar.gz
apr-util-1.6.1.tar.gz mysql-5.6.50-linux-glibc2.12-x86_64.tar.gz
[root@lamp src]#
[root@lamp src]# tar -xzf mysql-5.6.50-linux-glibc2.12-x86_64.tar.gz
[root@lamp src]# mkdir /data
[root@lamp src]# useradd -r -s /sbin/nologin mysql
[root@lamp src]# yum -y install perl-Module-Install
[root@lamp src]# yum -y install libaio*
[root@lamp src]# yum -y install autoconf
[root@lamp src]# mkdir ../mysql
[root@lamp src]# mv mysql-5.6.50-linux-glibc2.12-x86_64/* ../mysql
[root@lamp src]# cd !$
cd ../mysql
[root@lamp mysql]#
[root@lamp mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@lamp mysql]# cp support-files/my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@lamp mysql]# vi !$
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
server_id = 155
socket = /tmp/mysql.sock
[root@lamp mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@lamp mysql]# vi !$
basedir= /usr/local/mysql
datadir= /data/mysql
[root@lamp mysql]# chkconfig --add mysqld
[root@lamp mysql]# chkconfig mysqld on
[root@lamp mysql]# service mysqld start
/etc/init.d/mysqld: line 46: /usr/local/mysql: Is a directory
/etc/init.d/mysqld: line 47: /data/mysql: Is a directory
Starting MySQL.Logging to '/data/mysql/lamp.err'.
SUCCESS!
[root@lamp mysql]# ps -ef | grep mysqld
[root@lamp mysql]# cd ../src
[root@lamp src]# yum -y install gcc
[root@lamp src]# tar -xzf apr-1.6.5.tar.gz
[root@lamp src]# cd apr-1.6.5
[root@lamp apr-1.6.5]# ./configure --prefix=/usr/local/apr
[root@lamp apr-1.6.5]# make -j64 && make install
[root@lamp src]# yum -y install expat-devel
[root@lamp src]# yum -y install libxml2*
[root@lamp src]# tar -xzf apr-util-1.6.1.tar.gz
[root@lamp src]# cd apr-util-1.6.1
[root@lamp apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@lamp apr-util-1.6.1]# make -j128 && make install
[root@lamp src]# yum -y install pcre-devel
[root@lamp src]# tar -xzf httpd-2.4.46.tar.gz
[root@lamp src]# cd httpd-2.4.46
[root@lamp httpd-2.4.46]# ./configure --prefix=/usr/local/apache2.4 --enable-so --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
[root@lamp httpd-2.4.46]# make -j128 && make install
[root@lamp src]# cd ..
[root@lamp php-7.3.25]# yum install -y openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel epel-release libmcrypt-devel
[root@lamp src]# tar -xzf php-7.3.25.tar.gz
[root@lamp php-7.3.25]# cd php-7.3.25
[root@lamp php-7.3.25]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir-with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
[root@lamp php-7.3.25]# make -j32 && make install
[root@lamp php-7.3.25]# /usr/local/apache2.4/bin/apachectl -M
Loaded Modules:
......
php7_module (shared)
停用apache
[root@bogon src]# /usr/local/apache2.4/bin/apachectl stop
安装服务版php
[root@bogon ~]# cd /usr/local/src/php-7.3.25
[root@bogon php-7.3.25]# make clean
[root@bogon php-7.3.25]# yum install curl-devel
[root@bogon php-7.3.25]# yum -y install libjpeg-devel
[root@bogon php-7.3.25]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-pear --with-curl --with-openssl
[root@bogon php-7.3.25]# make -j32 && make install
[root@bogon php-7.3.25]# echo $?
0
[root@bogon php-7.3.25]# cp php.ini-production /usr/local/php-fpm/etc/php.ini
[root@bogon php-7.3.25]#vim /usr/local/php-fpm/etc/php-fpm.conf
[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
listen = 9000
listen.mode = 666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
[root@bogon php-7.3.25]# /usr/local/php-fpm/sbin/php-fpm -t
[20-Dec-2020 19:52:05] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf
test is successful
[root@bogon php-7.3.25]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@bogon php-7.3.25]# ll !$
ll /etc/init.d/php-fpm
-rw-r--r-- 1 root root 2405 Dec 20 20:18 /etc/init.d/php-fpm
[root@bogon php-7.3.25]# chmod 755 !$
chmod 755 /etc/init.d/php-fpm
[root@bogon php-7.3.25]# useradd -s /sbin/nologin php-fpm
[root@bogon php-7.3.25]# service php-fpm start
Starting php-fpm done
[root@bogon php-7.3.25]# chkconfig php-fpm on
[root@bogon php-7.3.25]# ps aux|grep php-fpm
S 20:20 0:00 php-fpm: pool www
php-fpm 107021 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107022 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107023 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107024 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107025 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107026 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107027 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107028 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107029 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107030 0.0 0.5 115864 5756 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107031 0.0 0.5 115864 5760 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107032 0.0 0.5 115864 5760 ? S 20:20 0:00 php-fpm: pool www
php-fpm 107033 0.0 0.5 115864 5760 ? S 20:20 0:00 php-fpm: pool www
root 107097 0.0 0.0 112816 960 pts/0 R+ 20:21 0:00 grep --color=auto php-fpm
[root@bogon src]#tar -xzf nginx-1.18.0.tar.gz
[root@bogon src]#cd nginx-1.18.0
[root@bogon nginx-1.18.0]# ./configure --prefix=/usr/local/nginx
[root@bogon nginx-1.18.0]# make -j32 && make install
[root@bogon src]# vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start()
{
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload()
{
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart()
{
stop
start
}
configtest()
{
$NGINX_SBIN -c $NGINX_CONF -t
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart}configtest}"
RETVAL=1
esac
exit $RETVAL
[root@lamp src]# chmod u+x /etc/init.d/nginx
[root@bogon src]# >/usr/local/nginx/conf/nginx.conf
[root@bogon src]# vim /usr/local/nginx/conf/nginx.conf
user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log info;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 6000;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 3526;
server_names_hash_max_size 4096;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
' $host "$request_uri" $status'
' "$http_referer" "$http_user_agent"';
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 8 4k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm application/xml;
server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
include vhost/*.conf;
}
[root@bogon ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@bogon ~]# /etc/init.d/nginx start
Starting nginx (via systemctl): [ OK ]
[root@bogon ~]# ps -aux | grep nginx
root 63326 0.0 0.1 20704 1436 ? Ss 17:02 0:00 nginx: master process /usr/localnginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 66659 0.0 0.3 23100 3308 ? S 18:06 0:00 nginx: worker process
nobody 66660 0.0 0.3 23100 3808 ? S 18:06 0:00 nginx: worker process
root 66861 0.0 0.0 112816 960 pts/1 R+ 18:10 0:00 grep --color=auto nginx