首页 > Lnmp点滴 > 阿里云代金券-centos7源码安装lnmp
2018
08-29

阿里云代金券-centos7源码安装lnmp

我的阿里云代金券地址:

https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=k9ijcm4l

https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=3ow2kbko

1,下载相应的软件

2,安装nginx

2.1安装必要的组件

yum install -y make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

2.2 安装pcre

tar xf pcre-8.36.tar.gz && cd pcre-8.36 && ./configure && make && make install

 

2.3 安装nginx

添加www用户

[root@iZwz9hzc7pd8k6u859n9rzZ src]# useradd www -s /sbin/nologin

tar xf nginx-1.10.3.tar.gz && cd nginx-1.10.3 && ./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_gzip_static_module –with-ipv6 –with-http_sub_module –with-pcre=../pcre-8.36 && make && make install

2.4 配置nginx

替换配置好的nginx.conf和nginx启动文件

[root@iZwz9hzc7pd8k6u859n9rzZ src]# cp nginx.conf /usr/local/nginx/conf/
cp: overwrite ‘/usr/local/nginx/conf/nginx.conf’? y

[root@iZwz9hzc7pd8k6u859n9rzZ src]# cp init.d.nginx /etc/init.d/nginx
[root@iZwz9hzc7pd8k6u859n9rzZ src]# chmod +x /etc/init.d/nginx
[root@iZwz9hzc7pd8k6u859n9rzZ src]# chkconfig nginx on

设置nginx加入到环境变量

[root@iZwz9hzc7pd8k6u859n9rzZ src]# echo “export PATH=\$PATH:/usr/local/nginx/sbin” >> /etc/profile
[root@iZwz9hzc7pd8k6u859n9rzZ src]# . /etc/profile

重启nginx

[root@iZwz9hzc7pd8k6u859n9rzZ home]# /etc/init.d/nginx restart
Stoping nginx… nginx is not running.
Starting nginx… done

nginx安装完毕!

3,安装mysql5.7

3.1 添加mysql用户

[root@iZwz9hzc7pd8k6u859n9rzZ home]# useradd mysql -s /sbin/nologin

3.2 解压mysql(源码版的)

[root@iZwz9hzc7pd8k6u859n9rzZ src]# tar xf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz

[root@iZwz9hzc7pd8k6u859n9rzZ src]# ln -s mysql-5.7.23-linux-glibc2.12-x86_64 mysql

3.3 授权mysql用户和组权限

[root@iZwz9hzc7pd8k6u859n9rzZ src]# chown -R mysql.mysql mysql-5.7.23-linux-glibc2.12-x86_64

3.4 配置/etc/my.cnf

3.5 初始化mysql

创建mysqldata目录,并授权。

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# mkdir data
[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# chown -R mysql.mysql data

初始化mysql

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# pwd
/usr/local/src/mysql
[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# bin/mysqld –initialize –user=mysql
bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

安装libaio

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# yum install libaio -y

重新初始化mysql

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# bin/mysqld –initialize –user=mysql
2018-08-29T07:19:02.012999Z 0 [ERROR] Can’t find error-message file ‘/usr/local/mysql/share/errmsg.sys’. Check error-message file location and ‘lc-messages-dir’ configuration directive.
2018-08-29T07:19:02.205242Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-08-29T07:19:02.950766Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-29T07:19:03.098656Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ce941add-ab5b-11e8-ad0e-00163e0472e8.
2018-08-29T07:19:03.102373Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.
2018-08-29T07:19:03.104621Z 1 [Note] A temporary password is generated for root@localhost: 9b)h.ko=bQr+

9b)h.ko=bQr+为mysql的临时密码

3.6 配置mysql

加入mysql到系统变量

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# echo “export PATH=\$PATH:/usr/local/src/mysql/bin” >> /etc/profile
[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# . /etc/profile

设置开机自动启动和修改mysql初始密码。

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# . /etc/profile
[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# cp support-files/mysql.server /etc/init.d/mysqld

修改/etc/init.d/mysqld

basedir=/usr/local/src/mysql
datadir=/usr/local/src/mysql/data

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# chmod +x /etc/init.d/mysqld
[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# chkconfig mysqld on

重启mysql

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# /etc/init.d/mysqld restart
Shutting down MySQL.. [ OK ]
Starting MySQL. [ OK ]

设置mysql密码

mysql> alter user root@localhost identified by ‘123456’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4,安装php

4.1 解压php

[root@iZwz9hzc7pd8k6u859n9rzZ src]# tar xf php-5.4.45.tar.gz

4.2 安装必要的组件

yum install -y make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel unzip tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel pcre pcre-devel

yum install -y epel-release
yum install -y libmcrypt-devel

4.3 安装php

[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –enable-fpm –with-fpm-user=www –with-fpm-group=www –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-iconv-dir –with-freetype-dir=/usr/local/freetype –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –enable-mbregex –enable-mbstring –with-mcrypt –enable-ftp –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –with-gettext –disable-fileinfo –enable-intl –with-xsl

编译和安装

[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# make && make install

4.4  配置php

[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# mkdir -p /usr/local/php/etc
[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# cp php.ini-production /usr/local/php/etc/php.ini

[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# mkdir -p /usr/local/php/etc
[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# cp php.ini-production /usr/local/php/etc/php.ini

修改php-fpm等参数

[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# vim /usr/local/php/etc/php-fpm.conf

设置php开机自动启动

[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# chmod +x /etc/init.d/php-fpm
[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# chkconfig php-fpm on
[root@iZwz9hzc7pd8k6u859n9rzZ php-5.4.45]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm warning, no pid file found – php-fpm is not running ?
Starting php-fpm done

php安装完毕!

mysql.nginx,php的配置需要的找我要,联系邮箱610232566@qq.com

 

 

最后编辑:
作者:dandahan
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。