centos 7
先设置端口开通
firewall-cmd --list-ports
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=8098/tcp --permanent
firewall-cmd --zone=public --add-port=8099/tcp --permanent
firewall-cmd --zone=public --add-port=8097/tcp --permanent
firewall-cmd --reload
1)下载nginx1.6.1
http://nginx.org/en/download.html
2)移动文件到root下
mv nginx-1.16.1.tar.gz /root/
cd /root
tar -xzvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
pwd
/root/nginx-1.16.1
./configure --prefix=/usr/local/nginx --with-http_ssl_module
正确的应该是:
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module
若编译前报错(requires the PCRE library)执行如下
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
若编译前报错(SSL modules require the OpenSSL library)
yum -y install openssl openssl-devel
make && make install
cd /usr/local/nginx
/usr/local/nginx/sbin/nginx
执行报错
nginx: [emerg] unknown directive "stub_status" in /home/oscf/nginx/conf/conf.d/ngx_metric.conf:
解决方法:在编译时加上
./configure --prefix=/home/oscf/nginx --with-http_stub_status_module
ps aux | grep nginx 运行情况
netstat -tlnp 端口
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -s quit
killall nginx
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
编辑.bash_profile文件
vim ~/.bash_profile
在.bash_profile文件末尾加入以下内容
export PATH=$PATH:/usr/local/nginx/sbin
引用.bash_profile文件
source ~/.bash_profile
启动nginx
nginx
停止nginx
nginx -s quit
https://www.php.net/releases/
mv php-7.1.33.tar.gz /root
cd /root
tar -xzvf php-7.1.33.tar.gz
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysqli --with-pdo-mysql --with-mysql-sock=/usr/local/mysql/mysql.sock --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-curl --with-gd --with-gmp --with-zlib --with-xmlrpc --with-openssl --without-pear --with-snmp --with-gettext --with-mhash --with-libxml-dir=/usr --with-ldap --with-ldap-sasl --with-fpm-user=nginx --with-fpm-group=nginx --enable-xml --enable-fpm --enable-ftp --enable-bcmath --enable-soap --enable-shmop --enable-sysvsem --enable-sockets --enable-inline-optimization --enable-maintainer-zts --enable-mbregex --enable-mbstring --enable-pcntl --enable-zip --disable-fileinfo --disable-rpath --enable-libxml --enable-opcache --enable-mysqlnd
编译报错(error: libxml2 not found. Please check your libxml2 installation.):
解决:yum install libxml2-devel
编译报错(./configure: line 23626: curl-dir: No such file or directory)
解决:yum install libcurl-devel
编译报错:checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-webp-dir=
If configure fails try --with-jpeg-dir=
configure: error: png.h not found
解决:
yum install libpng -y
yum install libpng-devel -y
yum install libjpeg libjpeg-devel
编译报错:freetype-config
yum install freetype freetype-devel
编译报错:Configure: error: Unable to locate gmp.h
yum install gmp-devel
编译报错:configure: error: Cannot find ldap.h
解决:yum install openldap openldap-devel
编译报错:Cannot find ldap libraries in /usr/lib
cp -frp /usr/lib64/libldap* /usr/lib/
编译报错:Could not find net-snmp-config binary. Please check your net-snmp installation
yum -y install net-snmp-devel
更多报错查看 https://www.jianshu.com/p/48d82e6f6834
成功显示
make报错(liblber-2.4.so.2: error adding symbols: DSO missing from command line)
解决:
遇到这种类似的情况,说明「./configure 」沒抓好一些环境变数值。解决方法,来自老外的一篇文章:
在PHP源码目录下 vi Makefile 找到 EXTRA_LIBS 行,在行末添加 ‘ -llber ‘ 保存退出再次make即可。
成功:
移动php配置文件的位置,并修改名称
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.conf
复制php.ini文件
cd /root/php-7.1.33
cp ./php.ini-production /usr/local/php/etc/php.ini
复制php启动脚本到/etc/init.d/
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
添加执行权限,添加到启动项并设置卡机启动
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
启动php-fpm
/etc/init.d/php-fpm start
启动报错( ERROR: [pool www] cannot get uid for user 'nginx'
[15-Jan-2020 15:19:04] ERROR: FPM initialization failed)
解决:修改php-fpm.conf里面的组
cd /usr/local/php/etc/
sudo vi php-fpm.conf 23行处
/etc/init.d/php-fpm start
vim /usr/local/nginx/conf/nginx.conf
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
killall nginx
/usr/local/nginx/sbin/nginx
[root@centos7_4 ~]# vim /usr/local/nginx/html/index.php
访问报错 File not found
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /script$fastcgi_script_name;
include fastcgi_params;
}
fastcgi_param SCRIPT_FILENAME /script$fastcgi_script_name;
改为
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
cd /usr/local/nginx/conf
mkdir vhost
vim www.station-backend.conf
server
{
listen 8099;
#listen [::]:80;
server_name localhost;
index index.html index.htm index.php default.html default.htm default.php;
#root /home/wwwroot/station-dev-backend/station-backend/api/web/;
root /mnt/hgfs/rxyx-sys-2017/station-backend/api/web/;
include rewrite/yii2.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
#include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}
cd /usr/local/nginx/conf
pwd /usr/local/nginx/conf
mkdir rewrite
vim rewrite/yii2.conf
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php$is_args$args;
}
vim /usr/local/nginx/conf/nginx.conf 加上include vhost/*.conf;
https://dev.mysql.com/downloads/mysql/5.6.html
教程
https://www.cnblogs.com/dong3210/p/9627499.html
下载需要账号 账号:[email protected] 密码:Qw5851*(自己的)**
mv mysql-5.6.47.tar.gz /root
cd /root
tar -zxvf mysql-5.6.47.tar.gz
yum install openssl
yum install openssl-devel
yum install ncurses-devel
groupadd mysql
useradd -g mysql mysql -s /sbin/nologin
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
cp support-files/my-default.cnf /etc/my.cnf
vim /etc/my.cnf
[mysqld] 添加:
datadir=/usr/local/mysql/data
default-storage-engine=InnoDB
lower_case_table_names=1
vi /root/.bash_profile
在修改PATH=$PATH:$HOME/bin为: PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
source /root/.bash_profile //使刚才的修改生效
bin/mysqld_safe --user=mysql &
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
service mysql start
service mysql stop
添加到开机启动项
chkconfig --add mysql
修改root密码(前提是mysql启动成功)
cd /usr/local/mysql
./bin/mysqladmin -u root password
mysql 账户访问授权及远程访问授权及密码修改
mysql -uroot -p
mysql> use mysql;
mysql> desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //为root添加远程连接的能力
mysql> update user set Password = password('123456') where User='root'; //设置root用户密码
mysql> select Host,User,Password from user where User='root';
mysql> flush privileges;
mysql> exit
#至此mysql安装完成,进入mysql