1.安装gcc编译器
基本所有编译安装包都需要gcc编译器,而且编译安装gcc也需要一个编译器,这是一个悖论。所以,这里只能寻求rpm包安装。但是rpm包需要匹配特定的操作系统内核,所以没有一个通用的包,只能花心思去寻找了
以CentOS7.1.1503 为例,在http://vault.centos.org/中找到适合的版本对应的gcc-rpm
gcc-4.8.3-9.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/gcc-4.8.3-9.el7.x86_64.rpm |
mpfr-3.1.1-4.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/mpfr-3.1.1-4.el7.x86_64.rpm |
libmpc-1.0.1-3.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libmpc-1.0.1-3.el7.x86_64.rpm |
kernel-headers-3.10.0-229.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/kernel-headers-3.10.0-229.el7.x86_64.rpm |
glibc-headers-2.17-78.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/glibc-headers-2.17-78.el7.x86_64.rpm |
glibc-devel-2.17-78.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/glibc-devel-2.17-78.el7.x86_64.rpm |
cpp-4.8.3-9.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/cpp-4.8.3-9.el7.x86_64.rpm |
gcc c++依赖组件 | |
libstdc++-devel-4.8.3-9.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libstdc++-devel-4.8.3-9.el7.x86_64.rpm |
gcc-c++-4.8.3-9.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/gcc-c++-4.8.3-9.el7.x86_64.rpm |
下载完成后依次安装
rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm |
rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm |
rpm -ivh kernel-headers-3.10.0-229.el7.x86_64.rpm |
rpm -ivh glibc-headers-2.17-78.el7.x86_64.rpm |
rpm -ivh glibc-devel-2.17-78.el7.x86_64.rpm |
rpm -ivh cpp-4.8.3-9.el7.x86_64.rpm |
rpm -ivh gcc-4.8.3-9.el7.x86_64.rpm |
安装gcc c++ |
rpm -ivh libstdcdevel-4.8.3-9.el7.x86_64.rpm |
rpm -ivh gcc-c4.8.3-9.el7.x86_64.rpm |
查看版本,安装成功后会显示环境变量信息
gcc -v |
Using built-in specs. |
至此,gcc编译器安装完毕.
2.安装perl
在perl官网https://www.perl.org下载gz包
perl-5.22.1.tar.gz | http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz |
执行编译安装
tar -zxvf perl-5.22.1.tar.gz |
cd perl-5.22.1 |
./Configure -des -Dprefix=/usr/local/perl |
make |
make test |
make install |
完成安装后查看版本会显示环境变量
perl -v |
This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux Copyright 1987-2015, Larry Wall Perl may be copied only under the terms of either the Artistic License or the Complete documentation for Perl, including FAQ lists, should be found on |
至此,Perl安装完毕.
3.安装ncurses-devel rpm.
ncurses-devel-5.9-13.20130511.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/ncurses-devel-5.9-13.20130511.el7.x86_64.rpm |
rpm -ivh ncurses-devel-5.9-13.20130511.el7.x86_64.rpm |
至此,ok.
4.安装cmake
cmake-3.4.1.tar.gz | https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz |
tar -zxvf cmake-3.4.1.tar.gz |
cd cmake-3.4.1 |
./bootstrap |
make |
make install |
至此,ok.
5.安装mysql
下载mysql和boost_1_59_0.tar.gz
boost_1_59_0.tar.gz | http://120.52.73.44/nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz |
mysql-5.7.10.tar.gz | http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.10.tar.gz |
解压目录
tar -zxvf mysql-5.7.10.tar.gz |
cd mysql-5.7.10 |
创建账号
groupadd -r mysql |
useradd -s /sbin/nologin -g mysql -r mysql |
id mysql |
编译
|
编译参数细节
-DCMAKE_INSTALL_PREFIX=dir_name | 设置mysql安装目录 |
-DMYSQL_UNIX_ADDR=file_name | 设置监听套接字路径,这必须是一个绝对路径名。默认为/tmp/mysql.sock |
-DDEFAULT_CHARSET=charset_name | 设置服务器的字符集。 缺省情况下,MySQL使用latin1的(CP1252西欧)字符集。cmake/character_sets.cmake文件包含允许的字符集名称列表。 |
-DDEFAULT_COLLATION=collation_name | 设置服务器的排序规则。 |
-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 |
存储引擎选项:
MyISAM,MERGE,MEMORY,和CSV引擎是默认编译到服务器中,并不需要明确地安装。 静态编译一个存储引擎到服务器,使用-DWITH_engine_STORAGE_ENGINE= 1 可用的存储引擎值有:ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), 和PERFSCHEMA (Performance Schema) |
-DMYSQL_DATADIR=dir_name | 设置mysql数据库文件目录 |
-DMYSQL_TCP_PORT=port_num | 设置mysql服务器监听端口,默认为3306 |
-DENABLE_DOWNLOADS=bool | 是否要下载可选的文件。例如,启用此选项(设置为1),cmake将下载谷歌所使用的测试套件运行单元测试。 |
注:若从新配置需要删除CMakeCache.txt文件.
rm <安装包目录>/CMakeCache.txt |
make,编译所需内存最好大于2GB,否则可能会出现编译器内存不足自动结束进程
make |
make install |
创建数据库文件夹
mkdir /data |
mkdir /data/mysqldb |
chown -R mysql:mysql /data/mysqldb |
chown -R mysql:mysql /usr/local/mysql |
复制配置模板到/etc,MySQL默认加载配置文件路径是/etc/my.cnf,如需自定义配置文件路径,可以在初始化数据库的时候在mysqld命令加上--defaults-file=<配置项路径>
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf |
初始化数据库,5.7前后版本在初始化数据库方面有差异,因为5.7之后官方建议用mysqld来代替mysql_install_db,详情请参见官方文档
5.7之前版本 | /usr/local/mysql/bin/mysql_install_db --user=mysql --datadir=/data/mysqldb |
5.7之后版本 | /usr/local/mysql/bin/mysqld --initialize --user=mysql |
5.7之后版本,用--initialize-insecure代替--initialize后初始化的root账号将会为空密码,否则密码会被记录在--log-error[=file_name]配置项配置的文件中(或第一次启动时,会在root目录下生产一个随机的密码,文件名为.mysql_secret?) | /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql |
配置启动项
centOS7之前的启动方式 | |
把服务脚本模板复制到/etc/init.d下 | cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld |
chmod 755 /etc/init.d/mysqld |
|
如果不存在则运行chkconfig --add mysqld | chkconfig --list mysqld |
chkconfig --add mysqld |
|
设置MySQL在345等级自动启动 | chkconfig --level 345 mysqld on |
或用这个命令设置开机启动 | chkconfig mysqld on |
如果提示pid错误,重启一下系统 | service mysqld start |
service mysqld restart |
|
service mysqld stop |
修改root密码
新设密码 | /usr/local/mysql/bin/mysqladmin -u root password "123456" |
修改密码 | /usr/local/mysql/bin/mysqladmin -uroot -p123456 password "1234567" |
其他命令
查看mysqld进程 | ps -ef | grep mysql |
查看mysqld进程详情,包括正在运行的服务配置文件情况 | ps aux|grep mysqld |
自定义配置参数启动mysqld | ./mysqld --defaults-file=../my.cnf |
开启firewalld3306tcp端口例外 | firewall-cmd --permanent --zone=public --add-port=3306/tcp |
6.安装pcre-devel
pcre-devel-8.32-14.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/pcre-devel-8.32-14.el7.x86_64.rpm |
rpm -ivh pcre-devel-8.32-14.el7.x86_64.rpm |
ok.
7.安装zlib-devel
zlib-devel-1.2.7-13.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/zlib-devel-1.2.7-13.el7.x86_64.rpm |
rpm -ivh zlib-devel-1.2.7-13.el7.x86_64.rpm |
ok.
8.安装openssl
openssl-1.0.1e-42.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/openssl-1.0.1e-42.el7.x86_64.rpm |
keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm |
libcom_err-devel-1.42.9-7.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libcom_err-devel-1.42.9-7.el7.x86_64.rpm |
libsepol-devel-2.1.9-3.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libsepol-devel-2.1.9-3.el7.x86_64.rpm |
pkgconfig-0.27.1-4.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/pkgconfig-0.27.1-4.el7.x86_64.rpm |
libselinux-devel-2.2.2-6.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libselinux-devel-2.2.2-6.el7.x86_64.rpm |
libverto-devel-0.2.5-4.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libverto-devel-0.2.5-4.el7.x86_64.rpm |
krb5-devel-1.12.2-14.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/krb5-devel-1.12.2-14.el7.x86_64.rpm |
openssl-devel-1.0.1e-42.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/openssl-devel-1.0.1e-42.el7.x86_64.rpm |
rpm -ivh openssl-1.0.1e-42.el7.x86_64.rpm |
rpm -ivh keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm |
rpm -ivh libcom_err-devel-1.42.9-7.el7.x86_64.rpm |
rpm -ivh libsepol-devel-2.1.9-3.el7.x86_64.rpm |
rpm -ivh pkgconfig-0.27.1-4.el7.x86_64.rpm |
rpm -ivh libselinux-devel-2.2.2-6.el7.x86_64.rpm |
rpm -ivh libverto-devel-0.2.5-4.el7.x86_64.rpm |
rpm -ivh krb5-devel-1.12.2-14.el7.x86_64.rpm |
rpm -ivh openssl-devel-1.0.1e-42.el7.x86_64.rpm |
9.安装nginx,下载gz包
nginx-1.9.9.tar.gz | http://nginx.org/download/nginx-1.9.9.tar.gz |
创建nginx用户和组
groupadd -r nginx |
useradd -s /sbin/nologin -g nginx -r nginx |
id nginx |
解压,编译
tar -zxvf nginx-1.9.9.tar.gz |
cd nginx-1.9.9 |
配置
./configure --with-http_stub_status_module --with-http_ssl_module --user=nginx --group=nginx |
配置结束后会列出配置摘要,按照上面安装的组件和配置参数,摘要应该是这样的
Configuration summary nginx path prefix: "/usr/local/nginx" |
编译,安装
make |
make install |
编辑pid文件
打开pid文件 |
vi /usr/local/nginx/logs/nginx.pid |
随机设置一个pid值 | 5692 |
编辑nginx全局配置文件 |
vi /usr/local/nginx/conf/nginx.conf |
开启启动pid,路径是上面创建的pid文件 | pid /usr/local/nginx/logs/nginx.pid; |
启动/重启/停止服务命令
/usr/local/nginx/sbin/nginx |
/usr/local/nginx/sbin/nginx -s reload |
/usr/local/nginx/sbin/nginx -s stop |
创建开机启动项
centOS7之后的启动方式 |
|
CentOS 7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,像需要开机不登陆就能运行的程序,还是存在系统服务里吧,即:/usr/lib/systemd/system目录下 每一个服务以.service结尾,一般会分为3部分:[Unit]、[Service]和[Install] 这里创建一个mysql.service服务 |
vi /usr/lib/systemd/system/nginx.service |
编辑nginx.service | [Unit] Description=nginx After=network.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop PrivateTmp=true [Install] WantedBy=multi-user.target |
开启开机加载 | systemctl enable nginx.service |
添加防火墙允许http服务
firewall-cmd --permanent --zone=public --add-service=http |
systemctl restart firewalld |
10.安装libxml2-devel
xz-devel-5.1.2-9alpha.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/xz-devel-5.1.2-9alpha.el7.x86_64.rpm |
libxml2-devel-2.9.1-5.el7_0.1.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libxml2-devel-2.9.1-5.el7_0.1.x86_64.rpm |
rpm -ivh xz-devel-5.1.2-9alpha.el7.x86_64.rpm |
rpm -ivh libxml2-devel-2.9.1-5.el7_0.1.x86_64.rpm |
11.安装bzip2 bzip2-devel
bzip2-1.0.6-12.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/bzip2-1.0.6-12.el7.x86_64.rpm |
bzip2-devel-1.0.6-12.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/bzip2-devel-1.0.6-12.el7.x86_64.rpm |
rpm -ivh bzip2-1.0.6-12.el7.x86_64.rpm |
rpm -ivh bzip2-devel-1.0.6-12.el7.x86_64.rpm |
12.安装curl-devel
libcurl-devel-7.29.0-19.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libcurl-devel-7.29.0-19.el7.x86_64.rpm |
rpm -ivh libcurl-devel-7.29.0-19.el7.x86_64.rpm |
13.安装readline-devel
readline-devel-6.2-9.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/readline-devel-6.2-9.el7.x86_64.rpm |
rpm -ivh readline-devel-6.2-9.el7.x86_64.rpm |
14.安装freetype freetype-devel
freetype-2.4.11-9.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/freetype-2.4.11-9.el7.x86_64.rpm |
freetype-devel-2.4.11-9.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/freetype-devel-2.4.11-9.el7.x86_64.rpm |
rpm -ivh freetype-2.4.11-9.el7.x86_64.rpm |
rpm -ivh freetype-devel-2.4.11-9.el7.x86_64.rpm |
15.安装libjpeg-turbo libpng libjpeg-turbo-devel libpng-devel
libjpeg-turbo-1.2.90-5.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libjpeg-turbo-1.2.90-5.el7.x86_64.rpm |
libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm |
libpng-1.5.13-5.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libpng-1.5.13-5.el7.x86_64.rpm |
libpng-devel-1.5.13-5.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/libpng-devel-1.5.13-5.el7.x86_64.rpm |
rpm -ivh libjpeg-turbo-1.2.90-5.el7.x86_64.rpm |
rpm -ivh libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm |
rpm -ivh libpng-1.5.13-5.el7.x86_64.rpm |
rpm -ivh libpng-devel-1.5.13-5.el7.x86_64.rpm |
16.安装openldap openldap-devel
openldap-2.4.39-6.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/openldap-2.4.39-6.el7.x86_64.rpm |
cyrus-sasl-2.1.26-17.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/cyrus-sasl-2.1.26-17.el7.x86_64.rpm |
cyrus-sasl-devel-2.1.26-17.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/cyrus-sasl-devel-2.1.26-17.el7.x86_64.rpm |
openldap-devel-2.4.39-6.el7.x86_64.rpm | http://vault.centos.org/7.1.1503/os/x86_64/Packages/openldap-devel-2.4.39-6.el7.x86_64.rpm |
rpm -ivh openldap-2.4.39-6.el7.x86_64.rpm |
rpm -ivh cyrus-sasl-2.1.26-17.el7.x86_64.rpm |
rpm -ivh cyrus-sasl-devel-2.1.26-17.el7.x86_64.rpm |
rpm -ivh openldap-devel-2.4.39-6.el7.x86_64.rpm |
17.安装libmcrypt,下载gz包
libmcrypt-2.5.7.tar.gz | ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz |
tar -zxvf libmcrypt-2.5.7.tar.gz |
cd libmcrypt-2.5.7 |
./configure |
make |
make install |
18.安装PHP-FPM,下载gz包
php-7.0.1.tar.gz | http://cn2.php.net/distributions/php-7.0.1.tar.gz |
为了编译程序能够找到相关依赖类库,必须编辑一下类库识别路径
vi /etc/ld.so.conf.d/local.conf |
|
添加该行(32位),注意,如果是64位系统继续添加下一句 | /usr/local/lib |
添加该行(64位,32位系统不需要) | /usr/local/lib64 |
:wq | |
使之生效 | ldconfig -v |
解压
tar -zxvf php-7.0.1.tar.gz |
cd php-7.0.1 |
配置,可参考官方文档相关配置项说明:http://php.net/manual/zh/configure.about.php
./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --disable-fileinfo |
编译,安装
make |
make install |
安装成功后,如果没有自定义过目录,常用配置用到的默认目录如下
/usr/local/php/sbin/php-fpm |
/usr/local/php/etc/php-fpm.conf.defualt |
/usr/local/php/etc/php.ini |
加载配置项
复制php-fpm配置模板 |
cp php-fpm.conf.default php-fpm.conf |
cd php-fpm.d |
|
复制www配置模板 |
cp www.conf.default www.conf |
编辑php-fpm配置 |
vi /usr/local/php/etc/php-fpm.conf |
开启pid固定参数文件,以便下面的启动参数有效 | pid = /usr/local/php/var/run/php-fpm.pid |
开启错误日志文件 | error_log = log/php-fpm.log |
启动参数
测试php-fpm配置命令 | /usr/local/php/sbin/php-fpm -t |
测试php-fpm配置,配合php.ini | /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf -t |
启动php-fpm | /usr/local/php/sbin/php-fpm |
启动php-fpm,配合php.ini | /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf |
关闭php-fpm | kill -INT `cat /usr/local/php/var/run/php-fpm.pid` |
重启php-fpm | kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` |
修改nginx-server的fastcgi部分,参考下面常见配置
|
支持pathinfo的配置
|
创建php.ini在编译时指定的配置项文件夹内,例如这次的安装配置路径是在/usr/local/php/etc/下,重启后会生效
vi /usr/local/php/etc/php.ini |
常用php.ini配置项解析
开启PDO,否则使用不到PDO对象 | extension = pdo.so |
开启MySQL PDO驱动,PDO默认只支持SQLite | extension = pdo_mysql.so |
开启MySQLi | extension = mysqli.so |
开启MySQL | extension = mysql.so |
设置时区 | date.timezone = 'Asia/Shanghai' |
设置MySQL socket文件位置,否则不能通过uinx socket来连接数据库,例如利用主机名字localhost将会失效 | mysql.default_socket = /var/lib/mysql/mysql.sock |
设置PDO MySQL socket文件位置,否则不能通过uinx socket来连接数据库,例如利用主机名字localhost将会失效 | pdo_mysql.default_socket = /var/lib/mysql/mysql.sock |
设置MySQLi socket文件位置,否则不能通过uinx socket来连接数据库,例如利用主机名字localhost将会失效 | mysqli.default_socket = /var/lib/mysql/mysql.sock |
创建开机启动项
centOS7之后的启动方式 |
|
CentOS 7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,像需要开机不登陆就能运行的程序,还是存在系统服务里吧,即:/usr/lib/systemd/system目录下 每一个服务以.service结尾,一般会分为3部分:[Unit]、[Service]和[Install] 这里创建一个mysql.service服务 |
vi /usr/lib/systemd/system/php-fpm.service |
编辑php-fpm.service | [Unit] Description=php-fpm After=network.target [Service] Type=forking PIDFile=/usr/local/php/var/run/php-fpm.pid ExecStart=/usr/local/php/sbin/php-fpm ExecReload=kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` ExecStop=kill -INT `cat /usr/local/php/var/run/php-fpm.pid` PrivateTmp=true [Install] WantedBy=multi-user.target |
开启开机加载 | systemctl enable php-fpm.service |