Table of Contents
一、系统约定
二、系统环境初始化
Apache v2.4.3 for Unix下载
界面预览
PHP v5.2.17 For Linux下载
MySQL Server v5.5.28 For Linux下载
Zend Optimizer v3.3.9 For linux-glibc21-i386下载
三、编译安装环境
Home php教程 php手册 php linux 环境搭建

php linux 环境搭建

Jun 06, 2016 pm 07:45 PM
apache linux php build environment

Apache源于NCSAhttpd服务器,经过多次修改,成为世界上最流行的Web服务器软件之一。Apache取自a patchy server的读音,意思是充满补丁的服务器,因为它是自由软件,所以不断有人来为它开发新的功能、新的特性、修改原来的缺陷。Apache的特点是简单、速度快、

 Apache源于NCSAhttpd服务器,经过多次修改,成为世界上最流行的Web服务器软件之一。Apache取自“a patchy server”的读音,意思是充满补丁的服务器,因为它是自由软件,所以不断有人来为它开发新的功能、新的特性、修改原来的缺陷。Apache的特点是简单、速度快、性能稳定,并可做代理服务器来使用。

一、系统约定

软件源代码包存放位置              /usr/local/src

源码包编译安装位置(prefix)     /usr/local/software_name

脚本以及维护程序存放位置       /usr/local/sbin

MySQL 数据库位置                 /var/lib/mysql(可按情况设置)

Apache 网站根目录                /home/www/wwwroot(可按情况设置)

Apache 虚拟主机日志根目录    /home/www/logs(可按情况设置)

Apache 运行账户                   www:www

二、系统环境初始化

1. 检查系统是否正常

#more /var/log/messages(检查有无系统级错误信息)
#dmesg (检查硬件设备是否有错误信息)
#cat /proc/cpuinfo (检查CPU频率是否正常)
#top (按1检测CPU核数是否正常,内存大小是否正常)
#ifconfig(检查网卡设置是否正确)
#ping http://www.chinaz.com/(检查网络是否正常)
Copy after login

2. 关闭不需要的服务

# ntsysv
Copy after login

以下仅列出需要启动的服务,未列出的服务一律推荐关闭:

atd
crond
irqbalance
microcode_ctl
network
sendmail
sshd
syslog
Copy after login

关闭SElinux:修改/etc/selinux/config文件中的SELINUX= 为 disabled

3.更换快速源

# cd /etc/yum.repos.d/
# mv CentOS-Base.repo CentOS-Base.repo.old
# wget http://centos.ustc.edu.cn/CentOS-Base.repo.5
# mv CentOS-Base.repo.5 CentOS-Base.repo
# yum update
Copy after login

4. 使用 yum 程序安装所需开发包(以下为标准的 RPM 包名称)

# yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

5. 定时校正服务器时钟,定时与中国国家授时中心授时服务器同步

# crontab -e
Copy after login

加入一行:

*/30 * * * * ntpdate 210.72.145.44 > /dev/null 2>&1
Copy after login

6.下载程序包

请到各程序官方网站下载最新的稳定版本存放到/usr/local/src/目录

 

Apache v2.4.3 for Unix下载

php linux 环境搭建

 

php linux 环境搭建

界面预览

    • 软件大小:7.90MB
    • 软件类别:国外软件 | web服务器
    • 软件语言:英文
    • 运行环境:Unix
    • 软件授权:免费版
    • 更新时间:2012-8-22 9:52:17
    • 相关链接:Home Page

 

 

 

 

PHP v5.2.17 For Linux下载

php linux 环境搭建

 

php linux 环境搭建

界面预览

    • 软件大小:8.67MB
    • 软件类别:国外软件 | web服务器
    • 软件语言:英文
    • 运行环境:Linux/Unix
    • 软件授权:免费版
    • 更新时间:2011-4-1 10:59:10
    • 相关链接:Home Page

 

 

 

 

MySQL Server v5.5.28 For Linux下载

php linux 环境搭建

 

php linux 环境搭建

界面预览

    • 软件大小:59.04MB
    • 软件类别:国外软件 | 数据服务器
    • 软件语言:英文
    • 运行环境:Linux
    • 软件授权:开源软件
    • 更新时间:2012-9-29 10:15:20
    • 相关链接:Home Page

 

 

 

 

Zend Optimizer v3.3.9 For linux-glibc21-i386下载

php linux 环境搭建

 

php linux 环境搭建

界面预览

    • 软件大小:9.30MB
    • 软件类别:国外软件 | 其它类别
    • 软件语言:英文
    • 运行环境:Linux
    • 软件授权:免费版
    • 更新时间:2009-12-11 10:44:31
    • 相关链接:Home Page

 

 

 

Memcache http://z.down.chinaz.com/upload/wget/memcache-2.2.5.tgz

Memcached http://z.down.chinaz.com/upload/wget/memcached-1.4.5.tar.gz

Apache控制脚本 http://z.down.chinaz.com/upload/httpd.txt

Apache配置文件 http://z.down.chinaz.com/upload/httpdconfig.txt

以上列出的程序最新稳定版下载列表 http://z.down.chinaz.com/upload/lamp_tools.txt

在 /usr/local/src目录下执行

wget http://c.sihost.net/lamp_tools.list
# wget -i lamp_tools.list
Copy after login

7. 创建web运行用户

# groupadd www
# useradd -g www www
# mkdir -p /home/www/wwwroot
# chmod +w /home/www/wwwroot
# chown www:www /home/www/wwwroot -R
Copy after login

8. 重新启动

# init 6
Copy after login

三、编译安装环境

1. 安装MySQL

# cd /usr/local/src
# tar zxvf mysql-5.0.86-linux-i686-icc-glibc23.tar.gz
# mv mysql-5.0.86-linux-i686-icc-glibc23 /usr/local/ 
# ln -s /usr/local/mysql-5.0.86-linux-i686-icc-glibc23/ /usr/local/mysql
# groupadd mysql
# useradd -g mysql mysql -d /home/mysql -s /sbin/nologin
# chown -R mysql:mysql /usr/local/mysql
# chown -R mysql:mysql /usr/local/mysql-5.0.86-linux-i686-icc-glibc23/
# cd /usr/local/mysql
# ./scripts/mysql_install_db --user=mysql
# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 3 mysqld on
# cp ./support-files/my-huge.cnf /etc/my.cnf
# mv /usr/local/mysql/data /var/lib/mysql
# chown -R mysql:mysql /var/lib/mysql
Copy after login

编辑/etc/my.cnf

在 [mysqld] 段增加

datadir = /var/lib/mysql
skip-innodb
wait-timeout = 10
max_connections = 512
max_connect_errors = 10000000
Copy after login

在 [mysqld] 段修改

max_allowed_packet = 16M
thread_cache_size = CPU个数*2
Copy after login

将 log-bin 注释

# service mysqld start
# bin/mysqladmin -u root password {password}
Copy after login

 

<span>其中{password</span><em>}</em><span>是要设置的root 密码</span>
Copy after login

2.编译安装Apache

# cd /usr/local/src/
# tar jxvf httpd-2.2.15.tar.bz2
# cd httpd-2.2.15/
# ./configure --prefix=/usr/local/apache --enable-module=rewrite --disable-access --disable-auth --disable-charset-lite --disable-include --disable-log-config --disable-env --disable-setenvif --disable-mime --disable-status --disable-autoindex --disable-asis --disable-cgid --disable-cgi --disable-negotiation --disable-dir --disable-actions --disable-userdir --disable-alias --enable-so --enable-mods-shared=' access auth auth_anon auth_dbm auth_digest dav dav_fs actions alias asis autoindex cache cern_meta cgi charset_lite deflate dir disk_cache env expires file_cache headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias'
# make
# make install
# cd /usr/local/src/
# mv /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.old
# cp -f /usr/local/src/httpd.conf /usr/local/apache/conf/httpd.conf
# cp -f /usr/local/src/httpd /etc/init.d/httpd
# chmod 755 /etc/init.d/httpd
# chkconfig --add httpd
# chkconfig httpd on
Copy after login

3. 编译安装PHP 所需的支持库

Libiconv

# cd /usr/local/src/
# tar zxvf libiconv-1.13.1.tar.gz
# cd libiconv-1.13.1/
# ./configure --prefix=/usr/local
# make
# make install
# cd ..
Copy after login

Libmcrypt

# tar zxvf libmcrypt-2.5.8.tar.gz 
# cd libmcrypt-2.5.8
# ./configure
# make
# make install
# /sbin/ldconfig
# cd libltdl/
# ./configure --enable-ltdl-install
# make
# make install
# cd /usr/local/src/
Copy after login

Mhash

# tar zxvf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9/
# ./configure
# make
# make install
# cd ..
# ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
$ ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
$ ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
$ ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
# ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
# ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
# ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
# ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
$ ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
# tar zxvf mcrypt-2.6.8.tar.gz
# cd mcrypt-2.6.8
# /sbin/ldconfig
# ./configure
# make
# make install
Copy after login

4. 编译安装PHP

# cd /usr/local/src
# tar zxvf php-5.2.13.tar.gz
# cd php-5.2.13
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/etc --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-magic-quotes --with-mysql=/usr/local/mysql --with-pear --enable-sockets --with-ttf --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --enable-sysvsem --enable-sysvshm --with-libxml-dir=/usr --with-apxs2=/usr/local/apache/bin/apxs --with-iconv-dir=/usr/local --with-xmlrpc --enable-xml --enable-shmop --enable-zip --with-mhash --with-mcrypt --enable-discard-path --enable-bcmath --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --with-openssl
# make ZEND_EXTRA_LIBS='-liconv'
# make install
# ./libtool --finish /usr/local/src/php-5.2.13/libs
# cp php.ini-dist /usr/local/etc/php.ini
# echo 'ulimit -SHn 65535' >> /etc/rc.local
# service httpd start
Copy after login

5. 安装PHP扩展模块(选装)

Memcache

# cd /usr/local/src
# tar zxvf memcache-2.2.5.tgz
# cd memcache-2.2.5/
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make
# make install
Copy after login

修改php.ini文件,路径/usr/local/etc/

查找:

extension_dir = "./"
Copy after login

修改成:

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
Copy after login

在此句下面一行

添加:

extension = "memcache.so"
Copy after login

查找:

output_buffering = Off
Copy after login

修改成:

output_buffering = On
Copy after login

保存。

Memcached

# cd /usr/local/src
# tar zxvf libevent-1.4.13-stable.tar.gz
# cd libevent-1.4.13-stable
# ./configure --prefix=/usr/lib
# make
# make install
# cd ../
# tar zxvf memcached-1.4.5.tar.gz
# cd memcached-1.4.5
# ./configure --prefix=/usr/local --with-libevent=/usr/lib/
# make 
# make install
# /usr/local/bin/memcached -d -u www -m 128
Copy after login

-p
监听的TCP端口(缺省: 11211)

-d
以守护进程方式运行 以守护进程方式运行 Memcached Memcached

-u
运行运行 Memcached的账户 非root用户

-m
最大的内存使用单位是MB 缺省是64MB

-c
软连接数量缺省是1024

-v
输出警告和错误信息

-vv
打印客户端的请求和返回信息

-h
打印帮助信息

-i
打印memcached和libevent的版权信息

6. 安装ZendOptimizer

# cd /usr/local/src
# tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
# cd ZendOptimizer-3.3.3-linux-glibc23-i386
# ./install
Please specify the location for installing 
Copy after login

Zend Optimizer:

这里填写Zend的安装路径,按下面写即可

/usr/local/Zend
Confirm the location of your
Copy after login

php.ini file:

这里填写的是php.ini的路径,按下面写即可

/usr/local/etc
Are you using Apache Web server? 
Copy after login

这里选YES

Apache的控制组件路径
/usr/local/apache/bin/apachectl
Copy after login

是否重启Apache,YES,回车

7. 查看确认L.A.M.P环境信息、提升 PHP 安全性

保存以下内容为info.php到/home/www/wwwroot/,检查phpinfo中的各项信息是否正确。

<span></span>
<span>phpinfo</span><span>();</span>
<span>?></span>
Copy after login

确认 PHP 能够正常工作后,编辑/usr/local/etc/php.ini进行设置提升PHP安全性。

找到:

disable_functions =
Copy after login

在等号后添加下面的函数名字

exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source
Copy after login
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

DeepSeek is a powerful intelligent search and analysis tool that provides two access methods: web version and official website. The web version is convenient and efficient, and can be used without installation; the official website provides comprehensive product information, download resources and support services. Whether individuals or corporate users, they can easily obtain and analyze massive data through DeepSeek to improve work efficiency, assist decision-making and promote innovation.

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

There are many ways to install DeepSeek, including: compile from source (for experienced developers) using precompiled packages (for Windows users) using Docker containers (for most convenient, no need to worry about compatibility) No matter which method you choose, Please read the official documents carefully and prepare them fully to avoid unnecessary trouble.

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

BITGet official website installation (2025 beginner's guide) BITGet official website installation (2025 beginner's guide) Feb 21, 2025 pm 08:42 PM

BITGet is a cryptocurrency exchange that provides a variety of trading services including spot trading, contract trading and derivatives. Founded in 2018, the exchange is headquartered in Singapore and is committed to providing users with a safe and reliable trading platform. BITGet offers a variety of trading pairs, including BTC/USDT, ETH/USDT and XRP/USDT. Additionally, the exchange has a reputation for security and liquidity and offers a variety of features such as premium order types, leveraged trading and 24/7 customer support.

Ouyi okx installation package is directly included Ouyi okx installation package is directly included Feb 21, 2025 pm 08:00 PM

Ouyi OKX, the world's leading digital asset exchange, has now launched an official installation package to provide a safe and convenient trading experience. The OKX installation package of Ouyi does not need to be accessed through a browser. It can directly install independent applications on the device, creating a stable and efficient trading platform for users. The installation process is simple and easy to understand. Users only need to download the latest version of the installation package and follow the prompts to complete the installation step by step.

See all articles