Configure httpd, MySQL and PHP Linux environment

This tutorial is centOS7 using Ali cloud ecs server, the local use of xshell, suitable for novices to learn the server's configuration, you can borrow this document to skilled some instructions, understand the software use and installation management, if only simple to install The installation is not recommended to use this tutorial.
Install from scratch, directly Ali cloud disk initialization, this step needs to operate on the site Ali cloud; then proceed to the installation process.

Step One: Download httpd archive and related dependencies.
1, using the wget command to download apr, apr-util, pcre and httpd;
1
cd / home // Here we will archive stored in the home directory
wget https://mirrors.huaweicloud.com/apache/apr/apr- 1.6.5.tar.gz
// apr download command
wget https://mirrors.huaweicloud.com/apache/apr/apr-util-1.6.1.tar.gz
// apr-download util command
wget https: // mirrors.huaweicloud.com/apache/httpd/httpd-2.4.41.tar.gz
// httpd download command
wget https://ftp.pcre.org/pub/pcre/pcre-8.36.tar.gz
// PCRE download command
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
2-extracting archive using the tar command
. 1
tar -zxvf On Apr-1.6.5.tar.gz
// extracting On Apr
tar -zxvf On Apr-util-1.6.1.tar.gz
/ / decompression apr-uti
-zxvf the httpd-2.4.41.tar.gz the tar
// extracting the httpd
the tar-8.36.tar.gz -zxvf PCRE
// decompression PCRE
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 3, mounting On Apr
. 1
CD-1.6.5 On Apr
enter apr directory
./configure -prefix = / usr / local / apr
the make
make install
// the make and make install these two commands can be written together: the make && make install
. 1
2
. 3
. 4
. 5
. 6
. 4, installation-util apr
. 1
CD. / apr-util
// enter the directory apr-util
// before installing apr-util, to install a dependency package called expat-devel, where we install directly with yum
yum -y install expat-devel
./configure -prefix = / usr / local / apr -util --with-apr = / usr / local / apr
// with-apr = apr mounted with the rear path, this must write to
the make
the make the install
. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 5, mounting PCRE
. 1
first installed gcc gcc-c ++ and assembly before installation

the install -Y-GCC GCC yum C ++
. 1
CD ./pcre-8.36
// enter pcre directory
./configure -prefix = / usr / local / pcre
the make
the make the install
. 1
2
. 3
. 4
. 5
. 6, mounting the httpd
. 1
CD ./httpd -2.4.41
./configure -prefix = / usr / local / apache2 --with-On Apr = / usr / local / On Apr --with-On Apr-util = / usr / local / On Apr-util = --with-PCRE / usr / local / pcre
all associated // before you want to come, so httpd must be the last installation of
the make the make install &&
1
2
3
4
so far, httpd installed, but want it to be able to access the local computer, also need to modify at the configuration file

Modify httpd configuration file
vi /usr/local/apache2/conf/httpd.cnf
// directly open httpd configuration file vi
/ ServerName
// direct input / ServerName find the keyword in the document and press Enter, press n to find the next a finding #ServerName: www.example.com: 80, change it to
ServerName: your ip address or domain name: 80
1
2
3
4
5
start httpd: / usr / local / apache2 / bin / apachectl start
1
Download and install MySQL
1, if it is a new virtual machine directly installed just fine, if the database is installed before too, you need to uninstall the previous MySQL should
see if there is residual rpm package:
available rpm -qa | grep mysql command to query, If you find the deleted with rpm -e;
look for remnants of MySQL package:
the find / -name MySQL
2, prior to installation, we must first install the relevant dependencies
yum -y install make gcc-c ++ cmake bison-devel ncurses-devel numactl libaio
. 3, to create users and user groups
the groupadd MySQL
the useradd -s / sbin / nologin -g -M MySQL MySQL
4, the download package and decompress the compressed packet may be downloaded to the local use and then upload rz command
wget https://downloads.mysql.com/archives/get/file/mysql-5.7.23-linux-glibc2.12 -x86_64.tar.gz
. 5, to decompress the compressed
the tar--zxvf MySQL 5.7.23-Linux-glibc2.12-x86_64.tar.gz
. 6, change the folder belongs
chown -R mysql.mysql / usr / local / mysql /
. 7, the relevant directory created mysql
mkdir -p / Data / mysql / {Data, logs, tmp}
. 8, to change the folder belongs
chown -R & lt mysql.mysql / Data / mysql /
. 9, arranged mysql.server
open / etc /init.d/mysql
modify the directory location of
the basedir = / usr / local / MySQL
DATADIR = / Data / MySQL / Data

Sign up boot services
chkconfig --add MySQL
chkconfig -list
10, add the environment variable
echo "the PATH = $ the PATH: / usr / local / MySQL / bin" >> / etc / Profile
Source / etc / Profile
1
2
3
4
5
6
. 7
. 8
. 9
10
. 11
12 is
13 is
14
15
16
. 17
18 is
. 19
20 is
21 is
22 is
23 is
24
25
26 is
27
28
29
30
31 is
32
, we also need to configure the profile MySQL

[client]
port= 3306
socke= /data/mysql/tmp/mysql.sock

[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/data
port = 3306

socket = /data/mysql/tmp/mysql.sock
pid-file = /data/mysql/tmp/mysqld.pid
tmpdir = /data/mysql/tmp
skip_name_resolve = 1
symbolic-links=0
max_connections = 2000
group_concat_max_len = 1024000
sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
lower_case_table_names = 1
log_timestamps=SYSTEM
character-set-server = utf8
interactive_timeout = 1800
wait_timeout = 1800
max_allowed_packet = 32M
binlog_cache_size = 4M
sort_buffer_size = 2M
read_buffer_size = 4M
join_buffer_size = 4M
tmp_table_size = 96M
max_heap_table_size = 96M
max_length_for_sort_data = 8096

#logs
server-id = 1003306
log-error = /data/mysql/logs/error.log
slow_query_log = 1
slow_query_log_file = /data/mysql/logs/slow.log
long_query_time = 3
log-bin = /data/mysql/logs/binlog
binlog_format = row
expire_logs_days = 15
log_bin_trust_function_creators = 1
relay-log = /data/mysql/logs/relay-bin
relay-log-recovery = 1
relay_log_purge = 1

#innodb
innodb_file_per_table = 1
innodb_log_buffer_size = 16M
innodb_log_file_size = 256M
innodb_log_files_in_group = 2
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
innodb_flush_neighbors = 0
innodb_flush_method = O_DIRECT
innodb_autoinc_lock_mode = 2
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_buffer_pool_size = 2G
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 is
27
28
29
30
31 is
32
33 is
34 is
35
36
37 [
38 is
39
40
41 is
42 is
43 is
44 is
45
46 is
47
48
49
50
51 is
52 is
53 is
54 is
55
56 is
57 is
58
59
after installation is simple modification of the MySQL.
MySQL Reference section: https: //blog.csdn.net/wanghao112956/article/details/90748883

Log Database
to start the database: MySQL Service Start
1
database initial password View: /var/log/mysqld.log grep "password"
1
Enter the password mysql -uroot -p // carriage return will not be displayed, be careful not to mistype
1
After logging can not operate the database, the first step is to set your own password
1
the ALTER the User 'root' @ 'localhost' IDENTIFIED by 'new new password';
1
flush privileges
1
new new password to your own password, attention must be uppercase and lowercase letters and symbols, or setting does not take effect, refreshed after setting.
Database settings remote connection
Update User Host SET = "%" = WHERE User "the root";
// authorize all ip,% by number, a single host server ip% transposition to want to allow
the flush privileges;
. 1
2
. 3
Note : If you can not connect, check the firewall port, can not connect, check Ali cloud network port.

PHP installation
1, install epel-release and webtatic-release of these two sources, because you want to install php package, these two sources are in for downloading

-Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm RPM

RPM -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
. 1
2
. 3
2 PHP installation kit

yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64
1
3、最后安装php70w-fpm php70w-opcache

FPM php70w the install php70w-yum-opcache -Y
. 1
installed
4, starting PHP-fpm

Start PHP-FPM systemctl
. 1
the connecting PHP and httpd
modified configuration file httpd

Found: # LoadModule foo_module modules / mod_foo.so
added: The proxy_module the LoadModule modules / mod_proxy.so
the LoadModule proxy_fcgi_module modules / mod_proxy_fcgi.so
. 1
2
. 3
Found:
adding it back: the AddType file application / X-.Z the compress
the AddType file application / X-the gzip .tgz .gz
the AddType file application / X-PHP the httpd-.php
the AddType file application / X-Source-the httpd-PHP. Phps
. 1
2
. 3
. 4
. 5
far configuration is complete, we hope to bring convenience.



Guess you like

Origin www.cnblogs.com/java67/p/11728779.html