Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ To setup CentOS LAMP environment     - Gentoo: startx appeared Failed to load module Problem Solving (Linux)

- Linux CentOS configuration SVN + SVN hook (Server)

- Oracle restrict certain IP, the malicious user actions on important table (Database)

- Asynchronous JavaScript loading (Programming)

- CentOS yum source as the default setting methods in DVD (Linux)

- How to build Mono 3.4.0 / 3.4.1 on Windows (Linux)

- Linux virtual machine settings network, hostname ssh access (Linux)

- Use PuTTY to access the virtual machine Linux under Windows xp (Programming)

- Source MongoDB 3.2.1 installed on CentOS6.5 (Database)

- Zabbix monitoring different versions of RAID installation and monitoring and MySQL master-slave monitor (Server)

- Manage SQL Server services login (start) account and password (Database)

- Analysis of native Java keywords (Programming)

- Python2 ---- function using dictionaries (Programming)

- Python3 multi-thread download codes (Programming)

- Binary Packages Golang (Linux)

- Archlinux installation tutorial (Linux)

- Java Cookie Comments (Programming)

- Use dump restore mode fast backup and recovery system FreeBSD (Linux)

- Linux System Getting Started Learning: Statistical process a number of threads in Linux (Linux)

- Camera-based face recognition OpenCV crawl and storage format (Python) (Linux)

  To setup CentOS LAMP environment
  Add Date : 2018-11-21      
  Introduction: Here will show you how to build a LAMP environment under CentOS (all use source compiler installation) for the web server development.

LAMP: Linux + Apache + PHP + Mysql.
System: CentOS 7,64 bits.
CentOS installation

I selected 64 of the Linux CentOS 7 system, the installation process is very simple, not too much narrative, only a little more about my partitioning:

Partition Name Size
/ Boot 200MB
/ Swap 8GB (not more than physical partition can be)
/ 20GB
/ Home space
Apache compiled and installed

I chose this version httpd 2.2, you can refer to the official documentation.

Installation depends:

Installation depends need to use gcc, g ++ compiler:

######## Gcc, g ++

sudo yum install gcc
sudo yum install gcc-c ++
Here are two apache optimization tools:

######## Apr

wget http://labfile.oss.aliyuncs.com/apr-1.5.1.tar.gz
tar -zxvf apr-1.5.1.tar.gz
cd apr-1.5.1 /
./configure --prefix = / opt / apr
sudo make && make install
######## Apr-util

cd Downloads /
wget http://labfile.oss.aliyuncs.com/apr-util-1.5.4.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix = / opt / apr-util --with-apr = / opt / apr
sudo make && make install
Perl library compatible regular expression library:

cd Downloads /
wget http://labfile.oss.aliyuncs.com/pcre-8.36.tar.gz
tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure --prefix = / opt / pcre
sudo make && make install
Install apache:

cd Downloads /
wget http://labfile.oss.aliyuncs.com/httpd-2.2.29.tar.gz
tar -zxvf httpd-2.2.29.tar.gz
cd httpd-2.2.29
./configure --prefix = / opt / apache --with-apr = / opt / apr --with-apr-util = / opt / apr-util --with-pcre = / opt / pcre
sudo make && make install
sudo sed -i 's / ^ # ServerName. * / ServerName localhost /' /opt/apache/conf/httpd.conf

start up:

sudo / opt / apache / bin / apachectl start
Get server response (the last step has been installed apache server to localhost):

curl -I

shut down:

sudo / opt / apache / bin / apachectl stop

Compile and install MySQL

Installation depends:

Note: The version MySQL5.5 after use cmake to compile.

######## If you previously compiled, you just need to remove the compiler generated file CMakeCache.txt

rm -f CMakeCache.txt

sudo yum -y install gcc gcc-c ++ autoconf automake zlib * fiex * libxml * ncurses-devel libmcrypt * libtool-ltdl-devel * cmake cmake-gui libaio-devel bison-devel make
Compile and install (a long time):

cd Downloads /
wget http://labfile.oss.aliyuncs.com/mysql-5.6.24.tar.gz
tar -zxvf mysql-5.6.24.tar.gz
cd mysql-5.6.24
cmake -DCMAKE_INSTALL_PREFIX = / opt / mysql -DMYSQL_DATADIR = / opt / mysql / data -DWITH_INNOBASE_STORAGE_ENGINE = 1
sudo make
sudo make install
Create mysql user:

id mysql> / dev / null 2> & 1 || sudo useradd -r -s / sbin / nologin -M -d / opt / mysql / data mysql
Initialize the data directory:

sudo chown -R mysql: mysql / opt / mysql / data
sudo / opt / mysql / scripts / mysql_install_db --basedir = / opt / mysql --datadir = / opt / mysql / data --user = mysql --defaults-file = / opt / mysql / support-files / my-default .cnf
Modify the configuration file:

sudo sh -c 'cat >> /opt/mysql/my.cnf < < EOF
basedir = / opt / mysql
datadir = / opt / mysql / data
log-error = /opt/mysql/data/error.log
pid-file = /opt/mysql/data/mysql.pid
port = 3306
Remove residual files:

sudo sh -c 'for file in /etc/mysql/my.cnf /etc/my.cnf; do [-f $ file] && rm -f $ file; done'
start up:

sudo /opt/mysql/support-files/mysql.server start
Success is displayed:
Write image description here


/ Opt / mysql / bin / mysqladmin ping

View database:

/ Opt / mysql / bin / mysql -u root -e 'show databases;'
shut down:

sudo /opt/mysql/support-files/mysql.server stop

PHP compiler installation

cd Downloads /
sudo yum install zlib1g-dev libbz2-dev libcurl4-gnutls-dev libjpeg-dev libpng12-dev libfreetype6-dev libmcrypt-dev libxml2-dev
sudo yum install bzip2-devel.x86_64 -y
sudo yum -y install curl-devel
sudo yum install openssl.x86_64 openssl-devel.x86_64 -y
sudo yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y
sudo yum install libjpeg libjpeg-devel libpng libpng-devel

######## Installation Libmcrypt
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
sudo make
sudo make install Description: libmcript installed by default in / usr / local

######## Installation mhash
cd ..
tar -zxvf mhash-
cd mhash-
sudo make
sudo make install

######### Install mcrypt
cd ..
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
LD_LIBRARY_PATH = / usr / local / lib ./configure
sudo make
sudo make install
Compile and install:

cd Downloads /
wget http://labfile.oss.aliyuncs.com/php-5.5.21.tar.gz
tar -zxvf php-5.5.21.tar.gz
cd php-5.5.21
./configure --prefix = / opt / php --with-bz2 --with-curl --with-jpeg-dir --with-gd --enable-shared --enable-mbstring --with-mcrypt - with-mysql = / opt / mysql --with-pdo-mysql = / opt / mysql --with-mysqli = / opt / mysql / bin / mysql_config --enable-fpm --enable-phar --enable-bcmath - -with-zlib --enable-zip --enable-ftp --with-gettext --enable-sockets --with-freetype-dir --with-config-file-path = / opt / php / etc / php. ini --with-config-file-scan-dir = / opt / php / etc / conf.d --with-apxs2 = / opt / apache / bin / apxs
sudo make
sudo make install
sudo cp php.ini-production /opt/php/etc/php.ini
Check whether to support php mysql:

/ Opt / php / bin / php -m | grep mysql

Modify the apache configuration file, add php supported configurations:

sudo sh -c 'cat >> /opt/apache/conf/httpd.conf < < EOF
< IfModule mime_module>
AddType application / x-httpd-php .php
< / IfModule>
If you close the open apache, otherwise restart apache:

sudo / opt / apache / bin / apachectl -k restart

sudo sh -c 'echo "< php echo phpinfo ();??>"> /opt/apache/htdocs/test.php'
In the browser, enter:

http: //localhost/test.php

Adding third-party modules

Manually compile Apache modules using apxs:

Apxs on some presentation and data see here.
Here in metadata module, for example:

cd ~ / Downloads / httpd-2.2.29 / modules / metadata
sudo / opt / apache / bin / apxs -i -a -c mod_headers.c
################################################## #########
-c: This option indicates the compilation operation. It first compiles the C source files (.c) files into corresponding object code files (.o), and then connect these object files plus the remaining object files (.o and .a), to generate a dynamic shared object dsofile. If you do not specify a -o option, the output file name obtained from the files of the first file name speculation, therefore, by default, it will generally be mod_name.so
-i: This option indicates the installation operation and installs one or more dynamically shared objects into the modules directory on the server.
-a: This option automatically adds a file in httpd.conf LoadModule line to activate this mode block ## title ##, or, if it already exists, it is enabled.
################################################## #########
Use phpize manually compile PHP modules:

cd ~ / Downloads / php-5.5.21 / ext / ftp
/ Opt / php / bin / phpize
./configure --with-php-config = / opt / php / bin / php-config
sudo make
sudo make install
Load module in php.ini:

sudo sh -c 'echo "extension = ftp.so" >> /opt/php/etc/php.ini'
LAMP configuration

php configuration:

Profile /opt/php/etc/php.ini:

### General Configuration
    engine = On
    short_open_tag = Off #tags recognition
    asp_tags = Off #asp tags to identify
    precision = # 14 significant digits displayed in floating point type number
    output_buffering = 4096 # output buffer allows you to send text content header after output
    implicit_flush = Off # tell the output layer to refresh itself automatically after every output block data
    disable_functions = # to turn off specific functions
    display_errors = Off # display an error message
    log_errors = On # error is logged in the log file
    request_order = "GP" #GET POST
    register_argc_argv = On # argc and argv whether to declare variables
    post_max_size = 8M # Size Maximum POST
    file_uploads = On # allow HTTP file upload mode
    upload_tmp_dir = # for the temporary directory on the HTTP file upload
    upload_max_filesize = 2M # maximum size of uploaded files
    max_file_uploads = Maximum number of upload each file # 20
    allow_url_fopen = On # allow the URLs as http: .. or the file as ftp: ...
    default_socket_timeout = 60 # default timeout socker

    #MySQL Related
    mysql.allow_persistent = On # allow persistent connections
    mysql.cache_size = 2000 # cache size
    mysql.max_persistent = -1 # persistent connection does not limit the maximum number of -1
    mysql.max_links = -1 # maximum link
    mysql.connect_timeout = 60 # connection time

    #session Related
    session.save_handler = files # for storing / retrieving control data
    session.use_cookies = 1 # if the use of cookies
    session.name = PHPSESSID # setting cookies names
    session.use_only_cookies = 1 # SESSION ID must be passed in order to enforce COOKIE
    session.auto_start = 0 # initialize when requesting start session
    session.cookie_lifetime = 0 #cookies hold time

    #session garbage collection parameters
    session.gc_probability = 1 # percentage finishing
    session.gc_divisor = 1000 # 1/1000 have the opportunity to start each request "garbage collection" process

    #Session ID pass parameters
    session.use_trans_sid = 0 # Use URL way to pass session id
    session.hash_function = 0 # generate SID MD5 algorithm
    How many bit stored within session.hash_bits_per_character = 5 # specified in the SID string for each character

    # Common configuration parameters
    max_execution_time 30 # a script can use the number of CPU seconds
    max_input_time 60 # a script waiting for input data how long (in seconds)
    memory_limit 32M # before being canceled, a script can use much memory (bytes)
    Before output_buffering 4096 # data is sent to the client, how much data (bytes) to cache
apache configuration:

apache main configuration file /opt/apache/conf/httpd.conf:

#apache root directory services
ServerRoot "/ opt / apache"
# Service Administrator
ServerAdmin you@example.com
# Listening port
Listen 80
# Default Home
DirectoryIndex index.php
# Load php module
LoadModule php5_module modules / libphp5.so
# Parse php
AddType application / x-httpd-php .php

# Directory permissions parameters
DocumentRoot "/ opt / apache / htdocs" #WEB file in the root directory
< Directory "/ opt / apache / htdocs">
    # Official document links http://httpd.apache.org/docs/2.2/mod/core.html
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow, deny
    Allow from all # Allow all requests
< / Directory>
AllowOverride Detailed parameters:

none .htaccess not allowed to use any instruction.
AuthConfig allow all permissions instructions, including AuthDBMGroupFile AuthDBMUserFile AuthGroupFile AuthName AuthTypeAuthUserFile and Require.
FileInfo Allow use the file type of control instruction. Including AddEncoding AddLanguage AddType DEfaultType ErrorDocument LanguagePriority.
Indexes allow the use of inventory control type instructions. Including AddDescription AddIcon AddIconByEncoding AddIconByType DefaultIcon DirectoryIndex FancyIndexing HeaderName IndexIgnore IndexOptions ReadmeName.
Limit instruction allows the use of access control. It includes Allow Deny and Order.
Options allow the use of command control directory features, including Options and XBitHack.
Options Detailed parameters:

All means all properties except for MultiViews. This is the default setting Options command.
None said they did not enable any server features.
FollowSymLinks allows the server to use symbolic links in this directory. If the configuration option is located in the configuration section, it will be ignored.
Indexes If you enter the URL corresponds to a file directory on the server, and this directory has no DirectoryIndex directive
MultiViews are allowed mod_negotiation module offers consultations "multi-view." If the path is requested by the client may correspond to various types of files, the server will automatically choose a file that best matches the requirements of the client according to the specific circumstances of the client request.
Users SymLinksIfOwnerMatch server only the owner has the same symbolic link to the target file or directory of ID when using it. Only when the symbolic link and a symbolic link the owner of the target file or directory to the same user, will use symbolic links.
ExecCGI allowed mod_cgi module execute CGI scripts.
Includes permitted mod_include module provides server-side includes features
IncludesNOEXEC allow server side includes, but disable the "#exec cmd" and "#exec cgi". But you can still use "#include virtual" virtual CGI scripts from ScriptAlias directory.
# Logging configuration parameters
ErrorLog "logs / error_log"
LogLevel warn # error logging level

< IfModule log_config_module>
    LogFormat "% h% l% u% t \"% r \ "%> s% b \"% {Referer} i \ "\"% {User-Agent} i \ "" combined
    LogFormat "% h% l% u% t \"% r \ "%> s% b" common # custom log named common

    < IfModule logio_module>
      LogFormat "% h% l% u% t \"% r \ "%> s% b \"% {Referer} i \ "\"% {User-Agent} i \ "% I% O" combinedio
    < / IfModule>

    CustomLog "logs / access_log" common # log path using a custom format called the common
< / IfModule>
LogLevel logging level:

error error conditions.
warn Warning conditions.
info general information.
Error level debug information.
Log Format:
1.% h - the client's ip address or host name.
2.% l - The client identd This is the RFC 1413 identity is determined, the output of the symbol "-" indicates where information is invalid.
3.% u - customer name to access the page from the HTTP authentication system obtained. There are only valid certificate, the output of the symbol "-" indicates where information is invalid.
Time server to complete the processing of the request - 4.% t.
5. "% r" - quotes a request contains a lot of useful information sent by the client.
6.%> s - that is returned by the server to the client status code.
7.% b - this last is returned to the client, not including the response headers.
8. "% {Referer} i" - This indicates that the request is being submitted from a web page which over.
9. "% {User-Agent} i" - this is a browser identification information provided by the client browser.

# Actual access log - - [04 / Feb / 2015: 12: 52: 35 +0800] "GET / HTTP / 1.1" 200 25

# Name-based virtual hosts
< VirtualHost *: 80>
    DocumentRoot / web1
    ServerName web1.com
    ErrorLog / app / apache / logs / error_log
    CustomLog / app / apache / logs / access_log combined
< / VirtualHost>

< VirtualHost *: 80>
    DocumentRoot / web2
    ServerName web2.com
< / VirtualHost>

IP-based virtual host #
< VirtualHost>
    DocumentRoot / web1
    ServerName web1.com
< / VirtualHost>

< VirtualHost>
    DocumentRoot web2
    ServerName web2.com
< / VirtualHost>

# Port-based virtual hosts

< VirtualHost>
    DocumentRoot / web1
    ServerName web1.com
< / VirtualHost>

< VirtualHost>
    DocumentRoot / web2
    ServerName web2.com
< / VirtualHost>

#perfork mode parameters
    StartServers 50 # 50 pre-created process
    MinSpareServers 15 # maintained minimum idle process
    MaxSpareServers 30 # maintained maximum Idle Process
    MaxClients 225 # Maximum number of processes
    MaxRequestsPerChild 4000 # to control each process automatically destroyed after the processing of the number of times a request
Note: When setting perfork mode parameters, you need to use ps aux to view the number of process memory in order to adjust the parameters of the actual environment, prevent this consumes all resources.
- Correlation Analysis: FP-Growth algorithm (Programming)
- iOS constants, variables, properties and characteristics (Programming)
- JavaScript is implemented without new keywords constructor (Programming)
- Zabbix configuration external network mail alarm (Server)
- Linux virtual memory and physical memory (Linux)
- Ubuntu compiler installation R Full Record (Linux)
- Linux kernel boot to retain large memory method summary (Linux)
- JBoss7 configuration - Supports IPv4 and IPv6 dual-stack environment (Server)
- Web server security policy (Linux)
- How to monitor network usage by nload in Linux (Linux)
- To batch create users under Linux (Linux)
- MySQL optimization of the relevant Group By (Database)
- I use the desktop environment in GNU / Linux combination tool (Linux)
- Linux SVN installation and configuration graphic tutorials (Server)
- Fast Sort Algorithms (Programming)
- Graphical development environment to build Android under Ubuntu 11.04 (Linux)
- Kafka + Log4j log implement centralized management (Server)
- Mac OS X systems create Ubuntu USB boot disk for the Mac (Linux)
- How to monitor Nginx (Database)
- The ActiveMQ JMS installation and application examples for Linux (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.