重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
https://nginx.org/en/download.html
或
https://github.com/dollarphper/soft/blob/master/nginx/nginx-1.15.3.tar.gz
yum -y install pcre-devel
yum -y install zlib-devel
b. 安装nginx:
cd nginx的下载目录
tar -xzf nginx-1.15.3.tar.gz
cd nginx-1.15.3
./configure && make && make install
useradd -s /sbin/nologin -M nginx
b. 修改配置文件:
vim /usr/local/nginx/conf/nginx.conf
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 8M;
client_body_buffer_size 128k;
server {
listen 80;
server_name localhost;
gzip on;
gzip_min_length 1k;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ {
access_log off;
expires 1h;
}
location ~* ^.+\.(css|js|txt|xml|swf|wav)$ {
access_log off;
expires 1h;
}
location ~* ^.+\.(html|htm)$ {
expires 1h;
}
location ~* ^.+\.(eot|ttf|otf|woff|svg)$ {
access_log off;
expires max;
}
location / {
add_header 'Access-Control-Allow-Origin' '*';
autoindex on;
autoindex_localtime on;
root html;
index index.html index.htm;
if (!-f $request_filename) {
rewrite /(.*)$ /index.php/$1;
}
if (!-d $request_filename) {
rewrite /(.*)$ /index.php/$1;
}
}
location ~ \.php(.*)$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $1;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;
fastcgi_param PHP_VALUE "open_basedir=$document_root";
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
c. 创建测试文件:
echo "hello world" > /usr/local/nginx/html/index.html
/usr/local/nginx/sbin/nginx
b. 停止:
/usr/local/nginx/sbin/nginx -s stop
c. 重启:
/usr/local/nginx/sbin/nginx -s reload
d. 添加环境变量:
echo 'export PATH=$PATH:/usr/local/nginx/sbin/' >> /etc/profile
. /etc/profile
e. 添加启动脚本:
vim /etc/init.d/nginx
#!/bin/bash
function start()
{
/usr/local/nginx/sbin/nginx
}
function stop()
{
/usr/local/nginx/sbin/nginx -s stop
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage : start | stop | restart"
;;
esac
f. 加载nginx:
chmod +x /etc/init.d/nginx
systemctl daemon-reload
5.测试:
https://dev.mysql.com/downloads/mysql/
或
https://github.com/dollarphper/soft/blob/master/mysql/mysql-boost-8.0.12.tar.gz
yum -y install cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel
b. 创建用户:
useradd mysql -s /sbin/nologin -M
c. 创建文件夹:
mkdir -p /usr/local/mysql/data
d. 解压:
tar -xzf mysql-boost-8.0.12.tar.gz
e. 编译安装:
cd mysql-8.0.12
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DMYSQL_TCP_PORT=3306 \
-DWITH_BOOST=./boost
make && make install
chown -R mysql.mysql /usr/local/mysql
b. 修改配置文件:
vim /etc/my.cnf
[mysqld]
server-id=1
port=3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
ngram_token_size=2
c. 初始化:
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/usr/local/mysql/data
/usr/local/mysql/bin/mysql_ssl_rsa_setup
d. 启动服务:
/usr/local/mysql/bin/mysqld_safe --user=mysql &
e. 添加到环境变量:
echo 'export PATH=$PATH:/usr/local/mysql/bin/' >> /etc/profile
. /etc/profile
f. 添加启动脚本:
vim /etc/init.d/mysqld
#!/bin/bash
function start()
{
/usr/local/mysql/bin/mysqld_safe --user=mysql &
}
function stop()
{
/usr/bin/pkill mysqld
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage : start | stop | restart"
;;
esac
g. 加载mysqld:
chmod +x /etc/init.d/mysqld
systemctl daemon-reload
h. 添加用户:
CREATE USER `root`@`%` IDENTIFIED BY '123456';
i. 授权:
GRANT ALL ON *.* TO `root`@`%` WITH GRANT OPTION;
j. 删除系统预留用户:
delete from mysql.user where host<>'%';
k. 刷新权限:
flush privileges;
l. 允许远程登录:
l-1. 设置变量:
SET GLOBAL innodb_fast_shutdown = 1;
l-2. 退出:
quit
l-3. 升级:
mysql_upgrade -u root -p123456
http://us1.php.net/downloads.php
或
https://github.com/dollarphper/soft/blob/master/php/php-7.2.10.tar.gz
yum -y install libxml2 libxml2-devel
yum -y install curl-devel libjpeg-devel libpng-devel freetype-devel
yum -y install libicu-devel
yum -y install libxslt-devel
yum -y install openssl openssl-devel
b. 解压:
tar -xzf php-7.2.10.tar.gz
c. 编译:
cd php-7.2.10
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-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 \
--enable-intl \
--enable-pcntl \
--enable-ftp \
--with-gd \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-gettext \
--disable-fileinfo \
--enable-opcache \
--enable-maintainer-zts \
--with-xsl
d. 安装:
make && make install
e. 下载pthreads:
git clone https://github.com/krakjoe/pthreads.git
f. 安装pthreads:
cd pthreads
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
g. 开启pthreads扩展:
vim /usr/local/php/etc/php.ini
[pthreads]
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/pthreads.so
h. 安装phpunit:
h-1. 下载:
wget -O phpunit https://phar.phpunit.de/phpunit-6.phar
h-2. 授权:
chmod +x phpunit
h-3. 添加到环境变量:
mv phpunit /usr/local/php/bin
i. 安装xdebug:
i-1. 下载:
git clone git://github.com/xdebug/xdebug.git
i-2. 进入目录:
cd xdebug
i-3. 生成编译文件:
/usr/local/php/bin/phpize
i-4. 编译:
./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config
i-5. 安装:
make && make install
i-6. 配置:
[xdebug]
zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=172.20.10.2
xdebug.remote_port=9000
xdebug.idekey="PHPSTORM"
cp php.ini-production /usr/local/php/etc/php.ini
b. 配置文件参考:
[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
memory_limit = 512M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = on
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 20M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 99999999
date.timezone = PRC
[CLI Server]
cli_server.color = On
[Date]
[filter]
[iconv]
[intl]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
[Assertion]
zend.assertions = -1
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[dba]
[opcache]
[curl]
[openssl]
c. 添加php-fpm到系统启动目录:
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
systemctl daemon-reload
d. 创建配置文件:
touch /usr/local/php/etc/php-fpm.conf
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[nginx]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = nginx
listen.group = nginx
listen.mode = 0666
user = nginx
group = nginx
pm = dynamic
pm.max_children = 20
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 20
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log
systemctl start php-fpm
b. 停止:
systemctl stop php-fpm
c. 重启:
systemctl restart php-fpm
d. 开机启动:
chkconfig php-fpm on
e. 添加环境变量:
echo 'export PATH=$PATH:/usr/local/php/bin/' >> /etc/profile
. /etc/profile
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。