Home Operation and Maintenance Nginx How to configure CentOS+Nginx+PHP+MySQL standard production environment

How to configure CentOS+Nginx+PHP+MySQL standard production environment

May 19, 2023 pm 01:37 PM
php centos nginx

php 5.3.1

mysql 5.0.89

nginx 0.8.33 or 0.7.65 (optional)

This is comparable to the one-click installation circulating on the Internet The package is much better, and this method of installation is highly recommended, suitable for all novices and experts. Compiling and installing all the source code on my server is not much better, and it is still very laborious. My installation already includes some common extensions of PHP, such as pdo, eaccelerator, memcache, tidy, etc.

Minimal installation of centos, then create a new repo

# vi /etc/yum.repos.d/centos.21andy.com.repo

Put in the following content

[21andy.com]
name=21andy.com packages for enterprise linux 5 - $basearch
baseurl=http://www.21andy.com/centos/5/$basearch/
enabled=1
gpgcheck=0
protect=1

Enable epel repo

centos i386 Enter the following command

rpm -ihv http:// download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

centos x86_64 Enter the following command

rpm -ihv http:/ /download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm

Then import key

rpm --import /etc/ pki/rpm-gpg/rpm-gpg-key-epel

Copy code

ok, install it with one click

yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator

Finally yum -y update , all are the latest

If you want to use the latest stable version of nginx 0.7.65, replace

yum -y install nginx

with

yum -y install nginx-stable

That’s it

After installation, you can play like this

service mysqld start

service php-fpm start

service nginx start

Don’t forget to set the boot startup

chkconfig --level 345 mysqld on

chkconfig --level 345 php-fpm on

chkconfig --level 345 nginx on

The configuration files are all found under /etc

See how automatic the installation is

dependencies resolved

================================================= =========
package arch version repository size
============================== ============================
installing:
mysql x86_64 5.0.89-1.el5 21andy.com 3.5 m
mysql-server x86_64 5.0.89-1.el5 21andy.com 10 m
nginx x86_64 0.8.33-3.el5 21andy.com 422 k
php-cli x86_64 5.3.1-2.el5 21andy.com 2.4 m
php-eaccelerator x86_64 2:0.9.6-1.el5 21andy.com 118 k
php-fpm x86_64 5.3.1-2.el5 21andy.com 1.2 m
php- gd x86_64 5.3.1-2.el5 21andy.com 110 k
php-mbstring x86_64 5.3.1-2.el5 21andy.com 1.1 m
php-mcrypt x86_64 5.3.1-2.el5 21andy.com 27 k
php-mysql x86_64 5.3.1-2.el5 21andy.com 84 k
php-pdo x86_64 5.3.1-2.el5 21andy.com 91 k
php-pear noarch 1:1.9 .0-1.el5 21andy.com 420 k
php-pecl-memcache x86_64 2.2.5-3.el5 21andy.com 44 k
php-tidy x86_64 5.3.1-2.el5 21andy.com 31 k
php-xml x86_64 5.3.1-2.el5 21andy.com 115 k
php-xmlrpc x86_64 5.3.1-2.el5 21andy.com 48 k
installing for dependencies:
gmp x86_64 4.1.4-10.el5 base 201 k
libxaw x86_64 1.0.2-8.1 base 329 k
libxmu x86_64 1.0.2-5 base 63 k
libxpm x86_64 3.5.5-3 base 44 k
libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k
libmcrypt x86_64 2.5.8-4.el5.centos extras 105 k
libtidy x86_64 0.99.0-14.20070615.el5 epel 14 0 k
php -common x86_64 5.3.1-2.el5 21andy.com 554 k
sqlite2 x86_64 2.8.17-5.el5 21andy.com 165 k
t1lib x86_64 5.1.1-7.el5 epel 208 k
updating for dependencies:
libevent x86_64 1.4.12-1.el5 21andy.com 129 k

transaction summary
================== ========================================
install 26 package(s)
update 1 package(s)
remove 0 package(s)

The following tests the performance of nginx php-fpm on my local virtual machine and vps respectively

My local machine Virtual machine test, configured as pd930 dual-core 3.0g, 2g memory, 1g memory is allocated to the virtual machine, the installed system is centos 5.4 64bit

The test content is

500 Concurrency test, the cpu usage reached 30%, and the system load was at 10around, the page opens very quickly

[root@localhost ~]#webbench -c 500 -t 30 http://127.0.0.1/
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.

benchmarking: get http://127.0.0.1/
500 clients, running 30 sec.

speed=223504 pages/min, 21806556 bytes/sec.
requests: 111752 susceed, 0 failed.

2000 Concurrency test, cpu usage 35%, system load Around 18, the page opened very quickly

[root@localhost ~]#webbench -c 2000 -t 30 http://127.0.0.1 /
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.

benchmarking: get http://127.0.0.1/
2000 clients , running 30 sec.

speed=429494 pages/min, 39004788 bytes/sec.
requests: 214747 susceed, 0 failed.

5000 Concurrency test, cpu usage rate is 30%, system load reaches 35, page rendering speed is not bad, after looking at this data, the 15 million php request mentioned a few days ago is not there What's going on

[root@localhost ~]#webbench -c 5000 -t 30 http://127.0.0.1/
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.

benchmarking: get http://127.0.0.1/
5000 clients, running 30 sec.

speed =788986 pages/min, 66952700 bytes/sec.
requests: 394493 susceed, 0 failed.

Not enough, change it a bit, 10000 concurrency

10000 Concurrency, the CPU usage is still less than 30%, the system load rises from around 60 to around 1000, I faint! It can still be opened! Just a little stuck! When the load reaches more than 600, there is no lag! Crazy, this is still a virtual machine, and webbench is still opened on my own machine, sweat, it’s too powerful

[root@localhost ~]#webbench -c 10000 -t 30 http://127.0.0.1/
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.

benchmarking: get http://127.0 .0.1/
10000 clients, running 30 sec.

speed=1513718 pages/min, -17973622 bytes/sec.
requests: 756859 susceed, 0 failed.

And my vps, 2g memory, 8-core CPU test, but I did not use the above yum installation, but compiled and installed all with source code, the test results are as follows:

500 concurrency, cpu usage 20%, load around 2

#webbench -c 500 -t 30 http://127.0.0.1/index.php
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.

benchmarking: get http://127.0.0.1/index.php
500 clients, running 30 sec.

speed=120520 pages/min, -36244332 bytes/sec.
requests: 60260 susceed, 0 failed.

2000 concurrency , cpu usage is about 20%, load is about 2, no change

webbench -c 2000 -t 30 http://127.0.0.1/index.php
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.

benchmarking: get http://127.0.0.1/index.php
2000 clients , running 30 sec.

speed=111454 pages/min, -44285944 bytes/sec.
requests: 55727 susceed, 0 failed.

The above is the detailed content of How to configure CentOS+Nginx+PHP+MySQL standard production environment. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to optimize CentOS HDFS configuration How to optimize CentOS HDFS configuration Apr 14, 2025 pm 07:15 PM

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

Centos stops maintenance 2024 Centos stops maintenance 2024 Apr 14, 2025 pm 08:39 PM

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

PHP's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

How to check CentOS HDFS configuration How to check CentOS HDFS configuration Apr 14, 2025 pm 07:21 PM

Complete Guide to Checking HDFS Configuration in CentOS Systems This article will guide you how to effectively check the configuration and running status of HDFS on CentOS systems. The following steps will help you fully understand the setup and operation of HDFS. Verify Hadoop environment variable: First, make sure the Hadoop environment variable is set correctly. In the terminal, execute the following command to verify that Hadoop is installed and configured correctly: hadoopversion Check HDFS configuration file: The core configuration file of HDFS is located in the /etc/hadoop/conf/ directory, where core-site.xml and hdfs-site.xml are crucial. use

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP: An Introduction to the Server-Side Scripting Language PHP: An Introduction to the Server-Side Scripting Language Apr 16, 2025 am 12:18 AM

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

Centos shutdown command line Centos shutdown command line Apr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

See all articles