


How to configure Debian Apache log rotation
This article introduces how to configure Apache log rotation in the Debian system, mainly using the logrotate
tool.
Step 1: Verify that logrotate
is installed
Check with the following command:
logrotate --version
If not installed, execute:
sudo apt-get update sudo apt-get install logrotate
Step 2: Locate the Apache log rotation configuration file
The configuration file is usually located in the /etc/logrotate.d/
directory, and the file name may be apache2
or httpd
. Use the following command to find:
ls /etc/logrotate.d/apache2 # or ls /etc/logrotate.d/httpd
Step 3: Edit the Apache log rotation configuration file
Open the configuration file using a text editor such as nano
or vim
:
sudo nano /etc/logrotate.d/apache2 # or sudo nano /etc/logrotate.d/httpd
Step 4: Configure logrotate
parameters
In the configuration file, you can customize the log rotation frequency, the number of retained log files, the compression method, etc. Here is a sample configuration:
<code>/var/log/apache2/*.log { daily missingok rotate 7 compress delaycompress notifempty create 640 root adm sharedscripts postrotate if [ -x /usr/sbin/invoke-rc.d ]; then /usr/sbin/invoke-rc.d apache2 reload >/dev/null 2>&1 fi endscript }</code>
Parameter description:
-
daily
: daily rotation. -
missingok
: No error is reported when the log file is missing. -
rotate 7
: Keep 7 log files. -
compress
: Compress old logs. -
delaycompress
: Delay compression until the next rotation. -
notifempty
: The empty log file does not rotate. -
create 640 root adm
: Create a new log file with permissions of 640, belongs to the main root, belongs to the group adm. -
sharedscripts
: When multiple log files are used, thepostrotate
script is executed only once. -
postrotate ... endscript
: The script executed after log rotation, reload the Apache configuration here. (Use more generalif [ -x ... ]
to check if the script exists)
Step 5: Test the configuration
Test the configuration with the following command:
sudo logrotate -d /etc/logrotate.d/apache2 # -d parameter is test mode and will not be actually executed
The -d
parameter is used for testing mode, and does not actually perform rotation, and only checks whether the configuration syntax is correct. If there is no error, then execute sudo logrotate /etc/logrotate.d/apache2
for actual rotation.
Step 6: Confirm the timing task
logrotate
is usually automatically executed by the system cron task. You can check the /etc/cron.daily/logrotate
file to make sure it exists and is configured correctly.
After completing the above steps, your Debian system Apache log rotation configuration is completed. If you have any questions, please check the configuration file syntax and permission settings.
The above is the detailed content of How to configure Debian Apache log rotation. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Best practices for writing JavaScript code in VSCode include: 1) Install Prettier, ESLint, and JavaScript (ES6) codesnippets extensions, 2) Configure launch.json files for debugging, and 3) Use modern JavaScript features and optimization loops to improve performance. With these settings and tricks, you can develop JavaScript code more efficiently in VSCode.

How to view Git history and changes in VSCode include: 1. Open VSCode and make sure the project has initialized the Git repository. 2. Click the "Source Code Management" icon in the left sidebar. 3. Select "...(more options)" and click "Git:ShowGitOutput". 4. View commit history and file changes. 5. Right-click the file and select "Git:ShowFileHistory" to view the file change history. Through these steps, you can efficiently view Git history and changes in VSCode to improve development efficiency.

In the 2025 currency exchange rankings, the top ten exchanges attracted much attention for their security, liquidity, user experience and innovation.

What is encryption jump? How is encryption rush to take shape? How to avoid encryption jumping? The crypto field is a rush to make profits by unconfirmed transactions, leveraging the transparency of blockchain. Learn how traders, bots, and validators manipulate transaction sorting, their impact on decentralized finance, and possible ways to protect transactions. Below, the editor of Script Home will give you a detailed introduction to encryption and rush forward! What is the rush to the encryption field? Taking the lead has long been a problem in the financial market. It originated in the traditional financial field, and refers to brokers or insiders using privileged information to trade before clients. Such behavior is considered immoral and illegal, and the regulator will investigate and punish it.

Handling Git commit conflicts in VSCode can be effectively resolved through the following steps: 1. Identify the conflicting file, and VSCode will be highlighted in red. 2. Manually edit the code between conflict marks and decide to retain, delete or merge. 3. Keep branches small and focused to reduce conflicts. 4. Use GitLens extension to understand code history. 5. Use VSCode to build-in Git commands, such as gitmerge--abort or gitreset--hard. 6. Avoid relying on automatic merge tools and carefully check the merge results. 7. Delete all conflict marks to avoid compilation errors. With these methods and tricks, you can handle Git conflicts efficiently in VSCode.

In VSCode, you can use Git for code version fallback. 1. Use gitreset--hardHEAD~1 to fall back to the previous version. 2. Use gitreset--hard to fall back to a specific commit. 3. Use gitrevert to safely fall back without changing history.

Investors and traders can view cryptocurrency markets for free, including Ouyi, Binance, Huobi and Sesame Open. 1. Visit Ouyi’s official website and navigate to “Quotes” to view real-time data. 2. Visit Binance official website and click "Quotes" to view real-time data and analysis tools. 3. Visit Huobi’s official website and navigate to “Quotes” to view real-time data. 4. Visit the official website of Sesame Open Door to view the market data directly

If users want to pursue profit maximization, they can maximize the value of the stablecoin through profit-based stablecoins. Earnings stablecoins are assets that generate returns through DeFi activities, derivatives strategies or RWA investments. Currently, this type of stablecoins accounts for 6% of the market value of the US$240 billion stablecoins. As demand grows, JPMorgan believes that the proportion of 50% is not out of reach. Income stablecoins are minted by depositing collateral into an agreement. The deposited funds are used to invest in the income strategy, and the income is shared by the holder. It's like a traditional bank lending out the funds deposited and sharing interest with depositors, except that the interest rate of the income stablecoin is higher
