How to install Nginx, php and mysql based on gentoo
1. First add the sync site to /etc/make.conf and use emerge for synchronization later.
Copy code The code is as follows:
sync="rsync://rsync.gentoo.org/gentoo-portage"
Execute emerge --sync synchronization portage tree.
2. Upgrade the portage version. Otherwise, when installing mysql later, you will be prompted that the portage version is old!
Copy code The code is as follows:
emerge portage
First define use:
Copy code The code is as follows:
/etc/portage/package.use
dev-lang/php cli ming xml ftp curl pdo mysqli mysql sqlite json cgi ctype gd hash
www-servers/nginx fastcgi
Edit /etc/portage/ package.keywords
www-servers/spawn-fcgi ~x86
3. Install mysql nginx php spawn-fcgi pecl-apc pecl-memcache.
Copy code The code is as follows:
emerge mysql nginx php spawn-fcgi pecl-apc pecl-memcache
4. Configure mysql.
Copy code The code is as follows:
mkdir -p /data0/mysql/data
mysql_install_db --user=mysql --basedir=/usr --datadir=/data0 /mysql/data
Configure my.cnf
Copy code The code is as follows:
rm -f /etc/mysql/my.cnf
vim / etc/mysql/my.cnf
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysql]
prompt="(\u: s135[\d]> "
no-auto-rehash
[mysqld]
bind-address = 173.252.207.109
user = mysql
port = 3306
socket = / var/run/mysqld/mysqld.sock
basedir = /usr
datadir = /data0/mysql/data
open_files_limit = 600
back_log = 20
max_connections = 100
max_connect_errors = 200
table_cache = 60
external-locking = false
max_allowed_packet = 16m
sort_buffer_size = 128k
join_buffer_size = 128k
thread_cache_size = 10
thread_concurrency = 8
query_cache_size = 0m
query_cache_limit = 2m
query_cache_min_res_unit = 2k
default_table_type = myisam
thread_stack = 192k
transaction_isolation = read-uncommitted
tmp_table_size = 512k
max_heap_table_size = 32m
/var /log/slow.log
/var/log/error.log
long_query_time = 1
log_long_format
server-id = 1
#log-bin = /usr/local/mysql/ data/binlog
binlog_cache_size = 2m
max_binlog_cache_size = 4m
max_binlog_size = 512m
expire_logs_days = 7
key_buffer_size = 4m
read_buffer_size = 1m
read_rnd_buffer_size = 2m
bulk_insert_buffer_size = 2m
myisam_sort_buffer_size = 4m
myisam_max_sort_file_size = 10g
myisam_max_extra_sort_file_size = 10g
myisam_repair_threads = 1
myisam_recover
[mysqldump]
quick
max_allowed_packet = 16m
mysql admin - uroot password ""
Start mysql
/etc/init.d/mysql start
5. Configure nginx
vim /etc/nginx/nginx.conf
Copy code The code is as follows:
user nginx nginx;
worker_processes 1;
error_log /var/log/nginx/nginx_error.log crit;
pid /var/run/nginx.pid;
#specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 52100;
events
{
use epoll;
worker_connections 52100;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 70 20;
tcp_nodelay on;
server_tokens off;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip off;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
server
{
server_name www.freebsdsystem.org;
root /data0/www/wwwroot/;
index index.html index.htm index.php;
location ~ .*\ .php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\. (js|css)?$
{
expires 1h;
}
log_format blog '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent " $http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /var/log/nginx/blog.log blog;
}
}
Configure spawn-fcgi
Copy code The code is as follows:
vim /usr/local/bin/php-fcgi
#!/bin/sh
# author:coralzd
# powered by www.freebsdsystem.org
bin=/usr/bin /php-cgi
case $1 in
start)
echo "starting php-cgi"
spawn-fcgi -a 127.0.0.1 -p 9000 -c 8 -u nginx -g nginx -f /usr/bin/php-cgi 2>&1 >/dev/null &
echo "done"
stop)
killall php-cgi
echo "php-cgi stop"
*)
echo "usage start|stop";;
esac
6. Start nginx mysql after booting up
Copy code The code is as follows:
rc-update add nginx default
rc-update add mysql default
The above is the detailed content of How to install Nginx, php and mysql based on gentoo. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

Steps to create a Docker image: Write a Dockerfile that contains the build instructions. Build the image in the terminal, using the docker build command. Tag the image and assign names and tags using the docker tag command.

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).
