Build a phplinux Environment

Source: Internet
Author: User
Apache originated from the NCSAhttpd server and has been modified many times to become one of the most popular Web server software in the world. Apache is taken from the pronunciation of apatchyserver, which means a server full of patches. Because it is a free software, someone is constantly developing new functions, new features, and modifying the original defects for it. Apache features simplicity, high speed,

Apache originated from the NCSAhttpd server and has been modified many times to become one of the most popular Web server software in the world. Apache is taken from the pronunciation of a patchy server, which means a server full of patches, because it is a free software, so there are people who constantly develop new functions, new features, and modify the original defects for it. Apache features simplicity, high speed,

Apache originated from the NCSAhttpd server and has been modified many times to become one of the most popular Web server software in the world. Apache is taken from the pronunciation of "a patchy server", which means a server full of patches, because it is a free software, so there are people who constantly develop new functions, new features, and modify the original defects for it. Apache is simple, fast, and stable, and can be used as a proxy server.

I. system conventions

Software source code package storage location/usr/local/src

Source code package compilation and installation location (prefix)/usr/local/software_name

Script and maintenance program storage location/usr/local/sbin

MySQL database location/var/lib/mysql (can be set as needed)

Apache website root directory/home/www/wwwroot (can be set as needed)

Apache Virtual Host log root directory/home/www/logs (can be set as needed)

Apache running account www: www

Ii. System Environment Initialization

1. Check whether the system is normal

# More/var/log/messages (check for system-level error messages) # dmesg (check for hardware device errors) # cat/proc/cpuinfo (check whether the CPU frequency is normal) # top (by 1 check whether the number of CPU cores is normal, memory size is normal) # ifconfig (check whether the NIC settings are correct) # ping http://www.chinaz.com/(check whether the network is normal)

2. disable unnecessary services

# ntsysv

Only the services to be started are listed below. We recommend that you disable all services not listed:

atdcrondirqbalancemicrocode_ctlnetworksendmailsshdsyslog

Disable SElinux: Modify selinux = to disabled in the/etc/SELINUX/config file.

3. Change the quick source

# 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

4. Use the yum program to install the required development kit (The following is the standard RPM package name)

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

5. Timing correction server clock, timing synchronization with the Chinese National Time Service Center Time Service Server

# crontab -e

Add a row:

*/30 * * * * ntpdate 210.72.145.44 > /dev/null 2>&1

6. Download the package

Download the latest stable version from the official website of each program and store it in the/usr/local/src/directory.

Download Apache v2.4.3 for Unix

Interface Preview

    • Software size:7.90 MB
    • Software category:Foreign SOFTWARE | web Server
    • Software language:English
    • Running environment:Unix
    • Software authorization:Free Version
    • Updated on:9:52:17
    • Related links:Home Page

PHP v5.2.17 For Linux download

Interface Preview

    • Software size:8.67 MB
    • Software category:Foreign SOFTWARE | web Server
    • Software language:English
    • Running environment:Linux/Unix
    • Software authorization:Free Version
    • Updated on:2011-4-1 10:59:10
    • Related links:Home Page

MySQL Server v5.5.28 For Linux download

Interface Preview

    • Software size:59.04 MB
    • Software category:Foreign SOFTWARE | Data Server
    • Software language:English
    • Running environment:Linux
    • Software authorization:Open source software
    • Updated on:10:15:20
    • Related links:Home Page

Zend Optimizer v3.3.9 For linux-glibc21-i386 downloading

Interface Preview

    • Software size:9.30 MB
    • Software category:Foreign SOFTWARE | other categories
    • Software language:English
    • Running environment:Linux
    • Software authorization:Free Version
    • Updated on:10:44:31
    • Related links:Home Page

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

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

Apache control scripting http://z.down.chinaz.com/upload/httpd.txt

Apache configuration file http://z.down.chinaz.com/upload/httpdconfig.txt

Http://z.down.chinaz.com/upload/lamp_tools.txt of the latest stable Version Download list for programs listed above

Run the following command in the/usr/local/src directory:

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

7. Create a web running user

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

8. Restart

# init 6
Iii. Compile and install the environment

1. Install 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

Edit/etc/my. cnf

Add in [mysqld]

datadir = /var/lib/mysqlskip-innodbwait-timeout = 10max_connections = 512max_connect_errors = 10000000

Modify in the [mysqld] Section

Max_allowed_packet = 16Mthread_cache_size = number of CPUs * 2

Comment out log-bin

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

{Password}Is the root password to be set

2. Compile and install 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

3. Compile and install the supported libraries required by 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 ..

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/

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

4. Compile and install 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

5. Install the PHP extension module (optional)

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

Modify the php. ini file, path:/usr/local/etc/

Search:

extension_dir = "./"

Modify:

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

Next line

Add:

extension = "memcache.so"

Search:

output_buffering = Off

Modify:

output_buffering = On

Save.

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

-P
TCP port of the listener (default: 11211)

-D
Run Memcached in daemon mode

-U
The account running Memcached is not a root user.

-M
The maximum memory usage unit is MB. The default value is 64 MB.

-C
The default number of soft connections is 1024.

-V
Output warning and error messages

-Vv
Print client requests and returned information

-H
Print help information

-I
Print the copyright information of memcached and libevent

6. Install ZendOptimizer

# cd /usr/local/src# tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz# cd ZendOptimizer-3.3.3-linux-glibc23-i386# ./installPlease specify the location for installing 

Zend Optimizer:

Enter the Zend installation path and write it as follows.

/usr/local/ZendConfirm the location of your

Php. ini file:

Enter the php. ini path, and write it as follows.

/usr/local/etcAre you using Apache Web server? 

Select YES here.

Apache control component path/usr/local/apache/bin/apachectl

Restart Apache? YES, press ENTER

7. check and confirm L.A. M.P environment information to improve PHP security

Save the following content as info. php to/home/www/wwwroot/and check whether the information in phpinfo is correct.

 

After confirming that PHP works properly, edit/usr/local/etc/php. ini to improve PHP security.

Find:

disable_functions =

Add the following function name after the equal sign

exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.