Software source code package storage location/usr/local/src source code package compilation and installation location (prefix) /usr/local/Comsenz/software_name script and maintenance program storage location/usr/local/Comsenz/sbinMySQL database location/data/mysql (which can be set as needed) apache website root directory/data/ww
System conventions
| Storage location of software source code package |
/Usr/local/src |
| Source code package compilation and installation location (prefix) |
/Usr/local/Comsenz/software_name |
| Script and maintenance program storage location |
/Usr/local/Comsenz/sbin |
| MySQL database location |
/Data/Mysql(Can be set as needed) |
| Apache website root directory |
/Data/wwwroot (which can be set as needed) |
| Apache virtual host log root directory |
/Data/wwwroot/logs (which can be set as needed) |
| Apache running account |
Www: www |
Related recommendations:PHP5.4 + Apache + Mysql server environment configuration
System environment initialization
1. check whether the system is normal
More/var/log/messages (check for system-level error messages)
Dmesg (check whether the hardware device has an error message)
Cat/proc/cpuinfo (check whether the CPU frequency is normal)
Top (check whether the number of CPU cores is normal and the memory size is normal by 1)
Ifconfig (check whether Nic settings are correct)
Ping www.163.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:
Atd
Crond
Irqbalance
Microcode_ctl
Network
Sendmail
Sshd
Syslog
Disable SElinux:
Modify selinux = to disabled in the/etc/SELINUX/config file
3. change the quick Source
Mv/etc/yum. repos. d/CentOS-Base.repo/etc/yum. repos. d/CentOS-Base.repo.old
Cd/etc/yum. repos. d/
Wget http://c.sihost.net/CentOS-Base-sohu.repo
Mv CentOS-Base-sohu.repo CentOS-Base.repo
Yum clean
Yum-y update
Lsb_release-
Yum-y erase mysql
Yum-y erase php
Yum-y erase httpd
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-devellibpng libpng-devel libtiff-devel libjpeg-6b libjpeg-devel-6bfreetype freetype-devel gd-devel fontconfig-devel zlibzlib-devel libevent-devel gcc -c ++ flex bison bzip2-devel libXpmlibXpm-devel ncurses-devel libmcrypt libmcrypt-devellibxml2 imake autoconf automake screen sysstatcompat-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/null2> & 1
6. download the package
Apache
Recommended stable version 2.2.21
Http://archive.apache.org/dist/httpd/
PHP
Recommended stable version 5.2.17
Http://cn.php.net/downloads.php
Mysql
Recommended stable version 5.5.18
Http://www.mysql.com/downloads/mysql/
The configuration files and scripts in this article are limited by space. Please download them at the following address (only wget download is supported in linux)
Apache control script
Http://c.sihost.net/jb/httpd
Apache configuration file
Http://c.sihost.net/jb/httpd.conf
Download list of the latest recommended programs listed above
Http://c.sihost.net/lamp_tools.list
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
Mkdir-p/data/wwwroot
Chmod + w/data/wwwroot
Chown www: www/data/wwwroot-R
8. restart
Init 6
Compile and install the environment
1. install MySQL
Cd/usr/local/src
Tar zxvf cmake-2.8.5.tar.gz
Cd cmake-2.8.5/
./Configure
Gmake & gmake install
Groupadd mysql
Useradd-g mysql
Mkdir-p/data/mysql
Chown-R mysql: mysql/data/mysql
Cd/usr/local/src
Tar zxvf mysql-5.5.18.tar.gz
Cd mysql-5.5.18
Cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/Comsenz/mysql-DMYSQL_DATADIR =/data/mysql-DSYSCONFDIR =/usr/local/Comsenz/etc/-DWITH_BLACKHOLE_STORAGE_ENGINE = 1
Make & make install
Cd/usr/local/Comsenz/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
Edit/etc/rc. d/init. d/mysqld
Find
Basedir =
Datadir =
Change
Basedir =/usr/local/Comsenz/mysql
Datadir =/data/mysql
Then
Mkdir-p/usr/local/Comsenz/etc
Cp./support-files/my-huge.cnf/usr/local/Comsenz/etc/my. cnf
Edit/usr/local/Comsenz/etc/my. cnf
Add in [mysqld]
Datadir =/data/mysql
Wait-timeout = 10
Max_connections = 512
Max_connect_errorrs = 10000000
Local-infile = 0
Modify in the [mysqld] Section
Max_allowed_packet = 16 M
Thread_cache_size = number of CPUs * 2
Comment out log-bin
Mv/usr/local/Comsenz/mysql/data/*/data/mysql
Service mysqld start
Bin/mysqladmin-u root password 'admin999'
Admin999 is the root password to be set.
2. install Apache
Cd/usr/local/src/
Tar zxvf httpd-2.2.21.tar.gz
Cd httpd-2.2.21
. /Configure -- prefix =/usr/local/Comsenz/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 includav_fs actions alias asis autoindex cache cern_meta cgicharset_lite deflate dir disk_cache env expires file_cache headersinclude info log_config logio mime mime_magic negotiation rewritesetenvif speling status unique_id userdir usertrackvhost_alias'
Make & make install
Cd/usr/local/src/
Mv/usr/local/Comsenz/apache/conf/httpd. conf/usr/local/Comsenz/apache/conf/httpd. conf. old
Cp-f/usr/local/src/httpd. conf/usr/local/Comsenz/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.
Tar zxvf libiconv-1.14.tar.gz
Cd libiconv-1.14/
./Configure -- prefix =/usr/local
Make & make install
Cd/usr/local/src/
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/
Tar zxvf mhash-0.9.9.9.tar.gz
Cd mhash-0.9.9.9/
./Configure
Make & make install
Cd/usr/local/src/
The 64-bit system executes the following:
Ln-s/usr/local/lib/libmcrypt. la/usr/lib64/libmcrypt. la
Ln-s/usr/local/lib/libmcrypt. so/usr/lib64/libmcrypt. so
Ln-s/usr/local/lib/libmcrypt. so.4/usr/lib64/libmcrypt. so.4
Ln-s/usr/local/lib/libmcrypt. so.4.4.8/usr/lib64/libmcrypt. so.4.4.4.8
Ln-s/usr/local/lib/libmhash. a/usr/lib64/libmhash.
Ln-s/usr/local/lib/libmhash. la/usr/lib64/libmhash. la
Ln-s/usr/local/lib/libmhash. so/usr/lib64/libmhash. so
Ln-s/usr/local/lib/libmhash. so.2/usr/lib64/libmhash. so.2
Ln-s/usr/local/lib/libmhash. so.2.0.1/usr/lib64/libmhash. so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
Ln-s/usr/local/lib/libiconv. so.2/usr/lib64/libiconv. so.2
The 32bit system executes the following:
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.
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
Ln-s/usr/local/lib/libiconv. so.2/usr/lib/libiconv. so.2
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.17.tar.gz
Cd php-5.2.17
. /Configure -- prefix =/usr/local/Comsenz/php5 -- with-config-file-path =/usr/local/Comsenz/etc -- enable-mbstring -- enable-ftp -- -gd -- with-jpeg-dir =/usr -- with-png-dir =/usr -- enable-magic-quotes -- with-mysql =/usr/local/Comsenz/mysql -- with-pear -- enable-sockets -- with-ttf -- with-freetype-dir =/usr -- enable-gd-native-ttf -- with-zlib -- enable-sysvsem -- enable-exif -- enable-sysvshm -- with-libxml-dir =/usr -- with-apxs2 =/usr/local/Comsenz/apache/bin/apxs -- with-iconv =/usr/local/libiconv -- 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 & make install
./Libtool -- finish/usr/local/src/php-5.2.17/libs
Cp php. ini-dist/usr/local/Comsenz/etc/php. ini
Echo 'ulimit-SHn 65535 '>/etc/rc. local
5. install the PHP Extension Module (this function is required for Discuz! X optional users)
APC
Cd/usr/local/src
Tar zxvf APC-3.1.9.tgz
Cd APC-3.1.9
/Usr/local/Comsenz/php5/bin/phpize
. /Configure -- enable-apc -- enable-mmap -- enable-apc-spinlocks -- disable-apc-pthreadmutex -- with-php-config =/usr/local/Comsenz/php5/bin/ php-config
Make & make install
Edit/usr/local/Comsenz/etc/php. ini
Search
Extension_dir =
Add
Extension_dir = "/usr/local/Comsenz/php5/lib/php/extension/ no-debug-non-zts-20060613 /"
Extension = "apc. so"
Apc. enabled = 1
Apc. shm_size = 64 M
Apc. stat = 1
Save
6. check and confirm the L.A. M.P environment information to improve PHP Security.
Save info. php to/data/www/and check whether the information in phpinfo is correct.
Phpinfo ();
?>
After confirming that PHP works properly, edit/usr/local/Comsenz/etc/php. ini to improve PHP Security.
Search
Disable_functions =
Modify
Disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, upper, lower, shell_exec, proc_get_status, ini_alter, ini_alter, lower, dl, pfsockopen, openlog, syslog, readlink, symlink, leak, popepassthru, stream_socket_server, popen
Then
Service httpd restart
More information:
1. how to build a local environment (php + mysql environment)
2. tips for using htaccess in Apache: 301 redirection and 404 error
3. how to bind multiple IP addresses and multiple domain names to Apache