Linux-real environment simulation (apache, MySQL, PHP, discuz)

♥️Author : Xiao Liu at Station C

♥️Personal homepage:  Xiao Liu's homepage 

♥️Efforts may not necessarily pay off, but there will be gains! Come on! Work hard together for a better life!

♥️ Learn the operation and maintenance experience summed up in two years, and a full set of network experiment tutorials for Cisco simulators. Column: Cloud Computing Technology

♥️Xiao Liu private message can ask casually, as long as you know it, you will not be stingy, thank you CSDN for letting you and me meet!

Table of contents

what is linux?

1. Install Apache (192.168.8.128)

2. Install mysql (start another centos7)

3. Install php

4. Test the static/dynamic separation of Apache and php

5. Deploy the Discuz forum


what is linux?

Linux, the full name of GNU/Linux, is a free-to-use and freely disseminated UNIX -like operating system. Its kernel was first released by Linus Benedict Torvalds on October 5, 1991. It is mainly inspired by the ideas of Minix and Unix . It supports 32-bit and 64-bit hardware and can run major Unix utilities, applications and network protocols. Linux inherits Unix's network-centric design idea and is a multi-user network operating system with stable performance. There are hundreds of different distributions of Linux, such as debian and archlinux based on community development, and Red Hat Enterprise Linux , SUSE , Oracle Linux and so on based on commercial development . On November 20, 2022, Linux submitted the last batch of drm-intel-next function patches, and Linux 6.2 will usher in the official support for Intel Ruixuan discrete graphics.

LAMP platform (distributed)
environment: three servers, turn off firewall and selinux
httpd: 192.168.8.128
myql: 192.168.8.129
php : 192.168.8.130

1. Install Apache (192.168.8.128)

    yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel

Write a script to install the prerequisite software:
mkdir /sh
cd /sh
vim qianti.sh
Add:
#!/bin/bash
cd /usr/src
tar zxf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr && make && make install

cd ..
tar zxf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install

cd ..
yum -y install zlib-*

tar zxf pcre-8.39.tar.gz
cd pcre-8.39
./configure --prefix=/usr/local/pcre && make && make install

cd ..
tar zxf openssl-1.0.1u.tar.gz
cd openssl-1.0.1u
./config -fPIC --prefix=/usr/local/openssl enable-shared && make && make install
public key

执行脚本:sh qianti.sh
    
    
3.安装Apache主程序
cd /sh
vim httpd.sh
添加:
#!/bin/bash
cd /usr/src
tar zxf httpd-2.4.25.tar.gz
cd httpd-2.4.25
./configure --prefix=/usr/local/httpd --enable-so --enable-cgi --enable-cgid --enable-ssl --with-ssl=/usr/local/openssl --enable-rewrite --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event --enable-proxy --enable-proxy-fcgi --enable-expires --enable-deflate && make && make install


save and exit

4. Optimize the link
ln -s /usr/local/httpd/bin/* /usr/local/bin

Add system service
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd
Locate to the second line: modify to
# chkconfig: 35 85 15 \\declare service startup level, startup sequence, shutdown sequence#
description: apache 2.4.25 \\service statement, brief information
save and exit
chkconfig --add httpd \\add httpd to the system Service
chkconfig httpd on \\Set the service to start automatically (equivalent to: systemctl enable httpd)
systemctl start httpd \\Enable the service (equivalent to: service httpd start)


2. Install mysql (start another centos7)


1. Copy the mysql5.6-rpm package to the virtual machine /root
cd /root/mysql5.6-rpm
yum -y localinstall *.rpm
systemctl start mysqld

3. Install php

1. Install prerequisite software
 yum -y install epel-release
 yum -y install gcc gcc-c++ libxml2-devel lzip2-devel libcurl-devel libmcrypt-devel openssl-devel bzip2-devel

2. Copy libmcrpt and php packages to /usr/src, install libmcrypt and PHP
mkdir /sh
vim php.sh
add:
#!/bin/bash
cd /usr/src
tar zxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7/
./configure --prefix=/usr/local/libmcrypt && make && make install

cd /usr/src
tar zxf php-5.6.27.tar.gz
cd php-5.6.27/
./configure --prefix=/usr/local/php5.6 --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt=/usr/local/libmcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts && make && make install

save and exit

sh php.sh


4. Provide php configuration file
cp /usr/src/php-5.6.27/php.ini-production /etc/php.ini

5. Provide scripts for php-fpm
cd /usr/src/php-5.6.27/
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on

6. Provide the php-fpm configuration file and edit
cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf
vim /usr/local/php5.6/etc/php-fpm.conf
to modify the content as follows:
pid = run/php-fpm.pid
listen = 192.168.8.130:9000
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
save and exit

7. Start the php-fpm service
systemctl start php-fpm


4. Test the static/dynamic separation of Apache and php

1. Enable proxy forwarding of Apache service. Find the following three lines
in vim /usr/local/httpd/conf/httpd.conf
and remove the # sign:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
Include conf/extra/httpd-vhosts.conf

Find the line where AddType is located and add:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Navigate to DirectoryIndex and change to:
DirectoryIndex index.php index.html

Save and exit
systemctl restart httpd

2. Configure the virtual host file
 vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
to:
<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot "/wwwroot"
 ServerName www.benet.com
 ServerAlias ​​benet.com
 ErrorLog "logs/benet.com-error_log"
 CustomLog "logs/benet.com-access_ log" common
 ProxyRequests Off
 ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://192.168.8.130:9000/wwwroot/$1

<Directory "/wwwroot">
 Options FollowSymLinks
 AllowOverride None
 Require all granted
</Directory>
</VirtualHost>
保存退出

systemctl restart httpd

5. Deploy the Discuz forum


(1) Copy the Discuz package to the /usr/src directory of the apache server, decompress it and rename the authorization (the steps are the same)
mkdir -p /wwwroot
cd /usr/src
unzip Discuz_X3.3_SC_UTF8.zip
mv upload/ /wwwroot/bbs
chmod -R 777 /wwwroot/bbs
scp -rp /wwwroot/ [email protected]. 130:/


(2) Modify the configuration file on the php server, restart the service
vim /etc/php.ini
find the following line and change it to:
short_open_tag = On
save and exit
service php-fpm restart

(3) Create bbs database and user on the mysql server
mysql> create database bbsdb;
mysql> grant all on bbsdb.* to runbbs@'%' identified by 'pwd@123';

(4) Visit Apache and install discuz forum
http://192.168.8.128/bbs

♥️Following is the driving force for my creation

♥️Like, is the greatest recognition for me

♥️This is Xiaoliu, I am inspiring to do every article well, thank you everyone

Guess you like

Origin blog.csdn.net/lzl10211345/article/details/131900996