lamp(还未配置apache)+lnmp(nginx配置成功)

字数 1842阅读 194

linux下安装mysql

使用yum安装

1.打开页面http://dev.mysql.com/downloads/repo/yum选择与linux相对应的版本点击download按钮进入下载页面选择no thanks复制下载链接

2.进入/usr/local/src目录下进行下载安装

a.安装yum源

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

tips:这里wget相对应版本的链接rpm -ivh my后面直接tab键进行补全,不要直接复制粘贴命令

b. yum安装mysql

yum install -y mysql-server

3.在/etc下已经存在my.cnf配置文件,如果启动自行配制,请自行修改

启动mysql服务

service mysqld start

现在可以进行登录了,但是还缺少临时密码,在启动日志文件通过grep命令中查找密码

grep temporary password

/var/log/mysqld.log

找到密码后就可以进行登录了

mysql -uroot -p

回车输入密码然后登录成功后修改密码,其中必须包含字母大小写,数字以及符号,否则会报错

SET PASSWORD=password('112233Qq.')

4.配置远程登录

进入mysql命令,关闭禁止远程登陆

grant all privileges on *.* to

'root'@'192.168.1.114' identified by '112233Qq.' with grant option

开启mysql3306端口

firewall-cmd --zone=public

--add-port=3306/tcp --permanent

重启网络服务

service firewalld.service restart

然后再windows的远程界面就可以进行登录了

bin/mysql -h192.168.1.202 -uroot -p

使用不带boost的mysql进行cmake编译安装

1.下载软件到usr/local/src目录下

cd /usr/local/src

wgethttp://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

wgethttp://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17.tar.gz

tip:如果下载不成功,可能版本有更新直接修改后面的数字即可

2.安装依赖,解压安装boost

yum -y install gcc gcc-c++ ncurses

ncurses-devel cmake

tar zxvf boost_1_59_0.tar.gz

cd boost_1_59_0

./bootstrap.sh

./b2 install

3.安装依赖,创建用户及用户组,安装mysql(进入src目录下进行操作)

cd /usr/local/src/

groupadd mysql

useradd -r -g mysql -s /bin/false mysql

mkdir -p /data/mysql

tar zxvf mysql-5.7.17.tar.gz

cd mysql-5.7.17

cmake .-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

-DMYSQL_DATADIR=/data/mysql\

-DDOWNLOAD_BOOST=1\

-DWITH_BOOST=/usr/local/boost_1_59_0\

-DSYSCONFDIR=/etc\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITH_MYISAM_STORAGE_ENGINE=1\

-DENABLED_LOCAL_INFILE=1\

-DENABLE_DTRACE=0\

-DDEFAULT_CHARSET=utf8mb4\

-DDEFAULT_COLLATION=utf8mb4_general_ci\

-DWITH_EMBEDDED_SERVER=1

其中第一行是安装目录,第二行是文件数据目录(就是上面创建的那个目录,第三行第四行是boost安装库,注意如果boost版本不对,则应该修改上面的文件路径)

make && make install

4.配置安装

cp

/usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

设置开机启动项

chmod +x /etc/init.d/mysqld

给mysqld赋予可执行权限

chkconfig --add mysqld

chkconfig mysqld on

cat > /etc/my.cnf << EOF

[client]

port = 3306

socket = /tmp/mysql.sock

default-character-set = utf8mb4

[mysqld]

port = 3306

socket = /tmp/mysql.sock

basedir = /usr/local/mysql

datadir = /data/mysql

pid-file = /data/mysql/mysql.pid

user = mysql

bind-address = 0.0.0.0

server-id = 1

init-connect = 'SET NAMES utf8mb4'

character-set-server = utf8mb4

#skip-name-resolve

#skip-networking

back_log = 300

max_connections = 1000

max_connect_errors = 6000

open_files_limit = 65535

table_open_cache = 128

max_allowed_packet = 4M

binlog_cache_size = 1M

max_heap_table_size = 8M

tmp_table_size = 16M

read_buffer_size = 2M

read_rnd_buffer_size = 8M

sort_buffer_size = 8M

join_buffer_size = 8M

key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1

query_cache_size = 8M

query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin

binlog_format = mixed

expire_logs_days = 30

log_error = /data/mysql/mysql-error.log

slow_query_log = 1

long_query_time = 1

slow_query_log_file =

/data/mysql/mysql-slow.log

performance_schema = 0

explicit_defaults_for_timestamp

#lower_case_table_names = 1

skip-external-locking

default_storage_engine = InnoDB

#default-storage-engine = MyISAM

innodb_file_per_table = 1

innodb_open_files = 500

innodb_buffer_pool_size = 64M

innodb_write_io_threads = 4

innodb_read_io_threads = 4

innodb_thread_concurrency = 0

innodb_purge_threads = 1

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 2M

innodb_log_file_size = 32M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M

myisam_sort_buffer_size = 8M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

interactive_timeout = 28800

wait_timeout = 28800

[mysqldump]

quick

max_allowed_packet = 16M

[myisamchk]

key_buffer_size = 8M

sort_buffer_size = 8M

read_buffer = 4M

write_buffer = 4M

EOF

5.初始化数据,开启mysql服务

/usr/local/mysql/bin/mysqld

--initialize-insecure --user=mysql --basedir=/usr/local/mysql

--datadir=/data/mysql

service mysqld start

6.修改环境变量

vi /etc/profile

#在profile文件末尾增加两行要在最末尾

PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH

export PATH

#使PATH搜索路径立即生效:

source /etc/profile

然后直接输出mysql -uroot命令就可以进行数据库管理了

php的安装

/usr/local/src目录下进行下载php.net官网右击复制下载链接

wgethttp://cn2.php.net/get/php-7.0.11.tar.gz/from/this/mirror

解压

tar zxvf mirror

安装依赖

yum install -y gcc gcc+ libxml2-devel

进入目录下操作

cd php-7.0.11/

./configure --prefix=/usr/local/php7

--enable-fpm

编译安装

make && make install

Apache的安装

/usr/local/src目录下进行下载http://httpd.apache.org或者查看一下版本直接修改数字

wgethttp://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.25.tar.gz

tar zxvf httpd-2.4.25.tar.gz

下载安装依赖包apr以及apr-util

wgethttp://archive.apache.org/dist/apr/apr-1.5.2.tar.gz

wgethttp://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz

tar zxvf apr-1.5.2.tar.gz

tar zxvf apr-util-1.5.4.tar.gz

去掉版本号,重命名,重命名命令mv

mv apr-1.5.2 apr

mv apr-util-1.5.4 apr-util

移动到httpd的srclib目录下

mv apr httpd-2.4.25/srclib/

mv apr-util httpd-2.4.25/srclib/

下载依赖包,编译安装

wgethttps://fossies.org/linux/misc/pcre-8.39.tar.gz

tar zxvf pcre-8.39.tar.gz

cd pcre-8.39

./configure

--prefix=/usr/local/pcre-8.39

make$$make install

进入Apache目录,进行编译安装

cd ../httpd-2.4.25

./configure --prefix=/usr/local/apache

-with-pcre=/usr/local/pcre-8.39/bin/pcre-config -with-included-apr

其中pcre的版本一定要更新,不能直接进行复制粘贴

make&&make install

cd /usr/local/apache/bin/

启动Apache服务

./apachectl -k start

开启80端口

firewall-cmd --zone=public

--add-port=80/tcp --permanent

service firewalld.service restart

然后在本机访问192.168.1.200发现it works字样

Nginx的安装

下载依赖pcre

wgethttps://fossies.org/linux/misc/pcre-8.39.tar.gz

安装依赖

yum -y install gcc gcc-c++ ncursesncurses-devel cmake

解压并进入目录

tar zxvf pcre-8.39.tar.gz

cd pcre-8.39

编译安装后面配置安装目录

./configure --prefix=/usr/local/pcre-8.39

make&&make install

下载解压安装

wgethttp://nginx.org/download/nginx-1.10.3.tar.gz

tar zxvf nginx-1.10.3.tar.gz

cd nginx-1.10.3

./configure --prefix=/usr/local/nginx--with-pcre=../pcre-8.39

make&&make install

启动nginx

./usr/local/nginx/sbin/nginx

启动php-fpm

cd /usr/local/php7/sbin/

./php-fpm

报错,缺少conf文件(后面修改www.conf文件进行对fpm管理操作)

mv /usr/local/php7/etc/php-fpm.conf.default/usr/local/php7/etc/php-fpm.conf

cd /usr/local/php7/etc/php-fpm.d/

mvwww.conf.defaultwww.conf

/usr/local/php7/sbin/php-fpm

修改开机启动项 以及配置fpm与nginx

设置开机启动项

修改nginx目录下conf中nginx.conf文件,将对php文件的操作写入进去

http {

server {

location ~ \.php$ {

fastcgi_pass127.0.0.1:9000;

fastcgi_indexindex.php;

include/usr/local/nginx/conf/fastcgi_params;

#include fastcgi_params;

fastcgi_split_path_info^(.+\.php)(/.+)$;

fastcgi_paramPATH_INFO$fastcgi_path_info;

fastcgi_paramPATH_TRANSLATED$document_root$fastcgi_path_info;

fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;

}

}

}

location ~ \.php$ {

fastcgi_pass127.0.0.1:9000;

fastcgi_indexindex.php;

include/usr/local/nginx/conf/fastcgi_params;

include fastcgi_params;

fastcgi_split_path_info^(.+\.php)(/.+)$;

fastcgi_param PATH_INFO$fastcgi_path_info;

fastcgi_param PATH_TRANSLATED$document_root$fastcgi_path_info;

fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;

}

在修改的时候注意上级大括号,以及插入的位置 复制粘贴的时候出现问题,可以先把#号去掉,统一格式,然后粘贴排版好在将他卸载

推荐阅读更多精彩内容